Skip to content

Commit acd288d

Browse files
committed
Clean up and use a CodeCell to render and execute the code
1 parent dce59aa commit acd288d

File tree

16 files changed

+347
-56
lines changed

16 files changed

+347
-56
lines changed

.eslintignore

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
1-
node_modules
1+
**/node_modules
2+
**/lib
3+
**/package.json
4+
**/patches
25
dist
36
coverage
47
**/*.d.ts
58
tests
9+
10+
.github
11+
binder
12+
jupyterlab_blockly/labextension
13+
.eslintignore
14+
.eslintrc.js
15+
.gitignore
16+
.pre-commit-config.yaml
17+
.prettierignore
18+
.prettierrc
19+
CHANGELOG.md
20+
install.json
21+
LICENSE
22+
MANIFEST.in
23+
pyproject.toml
24+
README.md
25+
RELEASE.md
26+
tsconfig.json
27+
yarn.lock

.eslintrc.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ module.exports = {
33
'eslint:recommended',
44
'plugin:@typescript-eslint/eslint-recommended',
55
'plugin:@typescript-eslint/recommended',
6-
'plugin:prettier/recommended'
6+
'plugin:prettier/recommended',
7+
'plugin:react/recommended'
78
],
89
parser: '@typescript-eslint/parser',
910
parserOptions: {
@@ -15,11 +16,11 @@ module.exports = {
1516
'@typescript-eslint/naming-convention': [
1617
'error',
1718
{
18-
'selector': 'interface',
19-
'format': ['PascalCase'],
20-
'custom': {
21-
'regex': '^I[A-Z]',
22-
'match': true
19+
selector: 'interface',
20+
format: ['PascalCase'],
21+
custom: {
22+
regex: '^I[A-Z]',
23+
match: true
2324
}
2425
}
2526
],

.github/workflows/binder-on-pr.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Reference https://mybinder.readthedocs.io/en/latest/howto/gh-actions-badges.html
2+
name: Binder Badge
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
7+
permissions:
8+
pull-requests: write
9+
jobs:
10+
binder:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: comment on PR with Binder link
14+
uses: actions/github-script@v3
15+
with:
16+
github-token: ${{secrets.GITHUB_TOKEN}}
17+
script: |
18+
var PR_HEAD_USERREPO = process.env.PR_HEAD_USERREPO;
19+
var PR_HEAD_REF = process.env.PR_HEAD_REF;
20+
github.issues.createComment({
21+
issue_number: context.issue.number,
22+
owner: context.repo.owner,
23+
repo: context.repo.repo,
24+
body: `[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/${PR_HEAD_USERREPO}/${PR_HEAD_REF}?urlpath=lab) :point_left: Launch a Binder on branch _${PR_HEAD_USERREPO}/${PR_HEAD_REF}_`
25+
})
26+
env:
27+
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
28+
PR_HEAD_USERREPO: ${{ github.event.pull_request.head.repo.full_name }}

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: prettier
5+
name: prettier
6+
entry: 'npm run prettier'
7+
language: node
8+
- id: eslint
9+
name: eslint
10+
entry: 'npm run eslint'
11+
language: node

.prettierrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"singleQuote": true,
33
"trailingComma": "none",
4-
"arrowParens": "avoid"
5-
}
4+
"arrowParens": "avoid",
5+
"endOfLine": "auto"
6+
}

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,33 @@
55
Blockly extension for JupyterLab.
66

77
## Blockly
8+
89
Blockly is a library from Google for building beginner-friendly block-based programming languages.
910

1011
Docs: https://developers.google.com/blockly/guides/overview
1112
Repo: https://github.com/google/blockly
1213

13-
1414
## Requirements
1515

16-
* JupyterLab == 3.4
16+
- JupyterLab == 3.4
1717

1818
## Install
1919

2020
To install the extension, execute:
2121

2222
```bash
23-
micromamba create -n blockly -c conda-forge python ipykernel xeus-python xeus-lua
23+
micromamba create -n blockly -c conda-forge python jupyterlab==3.4 ipykernel xeus-python xeus-lua jupyterlab-language-pack-es-ES jupyterlab-language-pack-fr-FR
2424
micromamba activate blockly
2525
pip install jupyterlab_blockly
2626
```
2727

2828
#### Kernels
29-
* ipykernel
30-
* xeus-python
31-
* xeus-lua
32-
* [JavaScript](https://github.com/n-riesco/ijavascript#installation)
33-
* [JavaScript](https://github.com/yunabe/tslab)
29+
30+
- ipykernel
31+
- xeus-python
32+
- xeus-lua
33+
- [JavaScript](https://github.com/n-riesco/ijavascript#installation)
34+
- [JavaScript](https://github.com/yunabe/tslab)
3435

3536
## Uninstall
3637

@@ -40,7 +41,6 @@ To remove the extension, execute:
4041
pip uninstall jupyterlab_blockly
4142
```
4243

43-
4444
## Contributing
4545

4646
### Development install
@@ -52,12 +52,14 @@ The `jlpm` command is JupyterLab's pinned version of
5252
`yarn` or `npm` in lieu of `jlpm` below.
5353

5454
```bash
55-
micromamba create -n blockly -c conda-forge python nodejs yarn jupyterlab==3.4 jupyter-packaging
55+
micromamba create -n blockly -c conda-forge python nodejs pre-commit yarn jupyterlab==3.4 jupyter-packaging jupyterlab-language-pack-es-ES jupyterlab-language-pack-fr-FR ipykernel xeus-python xeus-lua
5656
micromamba activate blockly
5757
# Clone the repo to your local environment
5858
# Change directory to the jupyterlab_blockly directory
5959
# Install package in development mode
6060
pip install -e .
61+
# Installing pre-commit to run command when adding commits
62+
pre-commit install
6163
# Link your development version of the extension with JupyterLab
6264
jupyter labextension develop . --overwrite
6365
# Rebuild extension Typescript source after making changes

RELEASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Python package. Before generating a package, we first need to install `build`.
1515
pip install build twine
1616
```
1717

18-
To create a Python source package (``.tar.gz``) and the binary package (`.whl`) in the `dist/` directory, do:
18+
To create a Python source package (`.tar.gz`) and the binary package (`.whl`) in the `dist/` directory, do:
1919

2020
```bash
2121
python -m build

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@
3737
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
3838
"clean:labextension": "rimraf jupyterlab_blockly/labextension",
3939
"clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
40-
"eslint": "eslint . --ext .ts,.tsx --fix",
40+
"eslint": "jlpm eslint:check --fix",
4141
"eslint:check": "eslint . --ext .ts,.tsx",
4242
"install:extension": "jlpm run build",
43+
"lint": "jlpm stylelint && jlpm prettier && jlpm eslint",
44+
"lint:check": "jlpm stylelint:check && jlpm prettier:check && jlpm eslint:check",
45+
"prettier": "jlpm prettier:base --write --list-different",
46+
"prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css}\"",
47+
"prettier:check": "jlpm prettier:base --check",
4348
"watch": "run-p watch:src watch:labextension",
4449
"watch:src": "tsc -w",
4550
"watch:labextension": "jupyter labextension watch .",
@@ -48,6 +53,8 @@
4853
"dependencies": {
4954
"@jupyterlab/application": "^3.4",
5055
"@jupyterlab/apputils": "^3.4",
56+
"@jupyterlab/cells": "^3.4",
57+
"@jupyterlab/codeeditor": "^3.4",
5158
"@jupyterlab/coreutils": "^5.4",
5259
"@jupyterlab/docregistry": "^3.4",
5360
"@jupyterlab/filebrowser": "^3.4",
@@ -72,6 +79,7 @@
7279
"eslint": "^8.9.0",
7380
"eslint-config-prettier": "^8.4.0",
7481
"eslint-plugin-prettier": "^4.0.0",
82+
"eslint-plugin-react": "^7.30.0",
7583
"npm-run-all": "^4.1.5",
7684
"prettier": "^2.5.1",
7785
"rimraf": "^3.0.2",
File renamed without changes.

src/factory.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
DocumentModel
55
} from '@jupyterlab/docregistry';
66
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
7+
import { IEditorMimeTypeService } from '@jupyterlab/codeeditor';
78

89
import { BlocklyEditor, BlocklyPanel } from './widget';
910
import { BlocklyRegistry } from './registry';
@@ -18,6 +19,7 @@ export class BlocklyEditorFactory extends ABCWidgetFactory<
1819
> {
1920
private _registry: BlocklyRegistry;
2021
private _rendermime: IRenderMimeRegistry;
22+
private _mimetypeService: IEditorMimeTypeService;
2123

2224
/**
2325
* Constructor of BlocklyEditorFactory.
@@ -28,6 +30,7 @@ export class BlocklyEditorFactory extends ABCWidgetFactory<
2830
super(options);
2931
this._registry = new BlocklyRegistry();
3032
this._rendermime = options.rendermime;
33+
this._mimetypeService = options.mimetypeService;
3134
}
3235

3336
get registry(): BlocklyRegistry {
@@ -43,7 +46,11 @@ export class BlocklyEditorFactory extends ABCWidgetFactory<
4346
protected createNewWidget(
4447
context: DocumentRegistry.IContext<DocumentModel>
4548
): BlocklyEditor {
46-
const manager = new BlocklyManager(this._registry, context.sessionContext);
49+
const manager = new BlocklyManager(
50+
this._registry,
51+
context.sessionContext,
52+
this._mimetypeService
53+
);
4754
const content = new BlocklyPanel(context, manager, this._rendermime);
4855
return new BlocklyEditor({ context, content, manager });
4956
}
@@ -55,5 +62,9 @@ export namespace BlocklyEditorFactory {
5562
* A rendermime instance.
5663
*/
5764
rendermime: IRenderMimeRegistry;
65+
/*
66+
* A mimeType service instance.
67+
*/
68+
mimetypeService: IEditorMimeTypeService;
5869
}
5970
}

0 commit comments

Comments
 (0)