Skip to content

Commit bfcc2da

Browse files
committed
embedme
1 parent 169decf commit bfcc2da

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

advanced/server-extension/README.md

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ if (launcher) {
296296
}
297297
```
298298
299-
Invoking the command (via the command palette or the launcher) will open a new tab with
299+
Invoking the command (via the command palette or the launcher) will open a new tab with
300300
an `IFrame` that will display static content fetched from the server extension.
301301
302302
**Note**
@@ -312,14 +312,14 @@ an `IFrame` that will display static content fetched from the server extension.
312312
313313
The server part of the extension is going to be presented in this section.
314314
315-
You first need to install the python source code. The following will install
315+
You first need to install the python source code. The following will install
316316
the `jlab_ext_example` package in dev mode:
317317
318318
```bash
319319
pip install -e .
320320
```
321321
322-
Then you need to enable the package at the Jupyter level
322+
Then you need to enable the package at the Jupyter level
323323
so that it becomes a server extension.
324324
325325
```bash
@@ -450,7 +450,7 @@ input_data = self.get_json_body()
450450
data = {"greetings": "Hello {}, enjoy JupyterLab!".format(input_data["name"])}
451451
```
452452
453-
The part responsible to serve static content with a `StaticFileHandler` handler
453+
The part responsible to serve static content with a `StaticFileHandler` handler
454454
is the following:
455455
456456
```py
@@ -486,7 +486,7 @@ through package managers like `pip`.
486486
487487
> Note: In particular, [`jupyter-packaging`](https://github.com/jupyter/jupyter-packaging) provides helpers to package and install JS files
488488
> with a Python package for Jupyter frontends (classical notebook,
489-
> JupyterLab,...).
489+
> JupyterLab,...).
490490
> As this package is a setup requirement, it needs to be specified in the `pyproject.toml` to be installed by `pip`.
491491
492492
The `setup.py` file is the entry point to describe package metadata:
@@ -497,6 +497,7 @@ The `setup.py` file is the entry point to describe package metadata:
497497
"""
498498
jlab_ext_example setup
499499
"""
500+
import json
500501
import os
501502

502503
from jupyter_packaging import (
@@ -511,14 +512,15 @@ HERE = os.path.abspath(os.path.dirname(__file__))
511512
name="jlab_ext_example"
512513

513514
# Get our version
514-
version = get_version(os.path.join(name, "_version.py"))
515+
with open(os.path.join(HERE, 'package.json')) as f:
516+
version = json.load(f)['version']
515517

516-
lab_path = os.path.join(HERE, name, "static")
518+
lab_path = os.path.join(HERE, name, "labextension")
517519

518520
# Representative files that should exist after a successful build
519521
jstargets = [
520522
os.path.join(HERE, "lib", "index.js"),
521-
os.path.join(HERE, name, "static", "package.json"),
523+
os.path.join(lab_path, "package.json"),
522524
]
523525

524526
package_data_spec = {
@@ -530,7 +532,8 @@ package_data_spec = {
530532
labext_name = "@jupyterlab-examples/server-extension"
531533

532534
data_files_spec = [
533-
("share/jupyter/labextensions/%s" % labext_name, lab_path, "*.*"),("etc/jupyter/jupyter_server_config.d",
535+
("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"),
536+
("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"),("etc/jupyter/jupyter_server_config.d",
534537
"jupyter-config", "jlab_ext_example.json"),
535538

536539
]
@@ -541,7 +544,7 @@ cmdclass = create_cmdclass("jsdeps",
541544
)
542545

543546
cmdclass["jsdeps"] = combine_commands(
544-
install_npm(HERE, build_cmd="build", npm=["jlpm"]),
547+
install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]),
545548
ensure_targets(jstargets),
546549
)
547550

@@ -590,35 +593,35 @@ the frontend NPM package needs to be built and inserted in the Python package. T
590593
done using a special `cmdclass`:
591594
592595
```py
593-
# setup.py#L42-L50
596+
# setup.py#L45-L53
594597

595598
cmdclass = create_cmdclass("jsdeps",
596599
package_data_spec=package_data_spec,
597600
data_files_spec=data_files_spec
598601
)
599602

600603
cmdclass["jsdeps"] = combine_commands(
601-
install_npm(HERE, build_cmd="build", npm=["jlpm"]),
604+
install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]),
602605
ensure_targets(jstargets),
603606
)
604607
```
605608
606609
Basically it will build the frontend NPM package:
607610
608611
```py
609-
# setup.py#L48-L48
612+
# setup.py#L51-L51
610613

611-
install_npm(HERE, build_cmd="build", npm=["jlpm"]),
614+
install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]),
612615
```
613616
614617
It will ensure one of the generated JS files is `lib/jlabextexample.js`:
615618
616619
```py
617-
# setup.py#L23-L26
620+
# setup.py#L25-L28
618621

619622
jstargets = [
620623
os.path.join(HERE, "lib", "index.js"),
621-
os.path.join(HERE, name, "static", "package.json"),
624+
os.path.join(lab_path, "package.json"),
622625
]
623626
```
624627
@@ -663,9 +666,8 @@ user about that dependency by adding the `discovery` metadata to your `package.j
663666
file:
664667
665668
```json5
666-
// package.json#L68-L78
669+
// package.json#L70-L80
667670

668-
],
669671
"jupyterlab": {
670672
"discovery": {
671673
"server": {
@@ -676,20 +678,21 @@ file:
676678
"name": "jlab_ext_example"
677679
}
678680
}
681+
},
679682
```
680683
681684
In this example, the extension requires a `server` extension:
682685
683686
```json5
684-
// package.json#L70-L70
687+
// package.json#L71-L71
685688

686689
"discovery": {
687690
```
688691

689692
And that server extension is available through `pip`:
690693

691694
```json5
692-
// package.json#L71-L73
695+
// package.json#L72-L74
693696

694697
"server": {
695698
"managers": [

basics/hello-world/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ package is declared in the file `package.json`:
9393
```json5
9494
// package.json#L44-L46
9595

96+
"watch:src": "tsc -w"
9697
},
9798
"dependencies": {
98-
"@jupyterlab/application": "^3.0.0-rc.7"
9999
```
100100
101101
With this basic import setup, you can move on to construct a new instance

main-menu/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ After the execution of that command, `package.json` should list them in the
8787
```json5
8888
// package.json#L44-L48
8989

90+
"watch:src": "tsc -w"
9091
},
9192
"dependencies": {
9293
"@jupyterlab/application": "^3.0.0-rc.7",
9394
"@jupyterlab/mainmenu": "^3.0.0-rc.7",
94-
"@lumino/widgets": "^1.14.0"
9595
```
9696
9797
With this extension installed, a new menu _Main Menu Example_ should be present. And when

settings/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ the `package.json` file in the `jupyterlab` section (here `schema`):
111111
```json5
112112
// package.json#L68-L70
113113

114+
"style/*.css"
114115
],
115116
"jupyterlab": {
116-
"extension": true,
117117
```
118118
<!-- prettier-ignore-end -->
119119

0 commit comments

Comments
 (0)