Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files for JupyterLite #45

Merged
merged 41 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
9746f9b
Add files for ReadTheDocs
jtpio Aug 5, 2022
50ef4f0
Add config
jtpio Aug 5, 2022
fa84108
Add build to dependencies
jtpio Aug 5, 2022
30acded
Fix manifest and index
jtpio Aug 5, 2022
8aa0b0f
Add dedicated index for the docs
jtpio Aug 5, 2022
15529ad
Fix check-manifest
jtpio Aug 5, 2022
69b59e8
Update to the latest jupyterlite
jtpio Nov 17, 2022
6ac0067
Add `nodejs` to the docs environment
jtpio Nov 17, 2022
2793fe8
Remove `ignore_sys_prefix`
jtpio Nov 17, 2022
4dfc4cf
Cleanup config and remove xeus kernel
jtpio Nov 18, 2022
705fb47
Add example file
jtpio Nov 18, 2022
54c06b7
Ignore docs/content for prettier
jtpio Nov 18, 2022
bda05cb
Add `docs/content` to eslintignore
jtpio Nov 18, 2022
f970d15
Run black on conf.py
jtpio Nov 18, 2022
8716b15
Populate docs/index.md
jtpio Nov 18, 2022
811ad2e
Simplify example.js
jtpio Nov 18, 2022
af44b45
Remove extra title
jtpio Nov 18, 2022
6e5c3e9
Add `extra_file_types`
jtpio Nov 23, 2022
1a36704
Rename to example.ts
jtpio Nov 23, 2022
d6f2146
Update example content
jtpio Nov 23, 2022
1272212
Update link in docs index
jtpio Nov 23, 2022
a4bd702
Update `check-release` action
jtpio Nov 23, 2022
025fe66
Skip `check-links` for now
jtpio Nov 23, 2022
0a3d877
Add `check_links` job
jtpio Nov 23, 2022
9351b63
Try fixing ignore_glob
jtpio Nov 23, 2022
91a8af0
Try fixing ignore_glob
jtpio Nov 23, 2022
33a8e83
fix
jtpio Nov 23, 2022
87061b3
Try ignore_links
jtpio Nov 23, 2022
616151a
fix
jtpio Nov 23, 2022
4ee7b9d
fix
jtpio Nov 23, 2022
47b0c47
Fix eof
jtpio Nov 23, 2022
cce4489
fix ignore_links
jtpio Nov 23, 2022
cbd17f0
Add hint
jtpio Nov 24, 2022
d79acff
try without the badge
jtpio Nov 24, 2022
60c5193
try
jtpio Nov 24, 2022
ae65e5f
undo
jtpio Nov 24, 2022
29755f9
try
jtpio Nov 24, 2022
a66a5d1
one last try
jtpio Nov 24, 2022
ea6f13f
Add JupyterLite badge to the README
jtpio Dec 6, 2022
6d53846
Add `sphinxext.rediraffe`
jtpio Dec 6, 2022
aa39dd6
Remove `sphinxext.rediraffe`
jtpio Dec 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ coverage
**/*.d.ts
tests
src/modules.ts
docs/content
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
**/package.json
jupyterlab_plugin_playground
src/modules.ts
docs/content
12 changes: 12 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

build:
os: "ubuntu-20.04"
tools:
python: "mambaforge-4.10"

conda:
environment: docs/environment.yml

sphinx:
configuration: docs/conf.py
38 changes: 38 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
extensions = ["myst_parser", "jupyterlite_sphinx"]

jupyterlite_config = "jupyter_lite_config.json"
jupyterlite_dir = "."
jupyterlite_contents = "content"
jtpio marked this conversation as resolved.
Show resolved Hide resolved

master_doc = "index"
source_suffix = ".md"

# General information about the project.
project = "JupyterLab Plugin Playground"
author = "Project Jupyter"

exclude_patterns = []
highlight_language = "python"
pygments_style = "sphinx"

html_theme = "pydata_sphinx_theme"
html_static_path = ["_static"]

html_css_files = ["custom.css"]


def on_config_inited(*args):
import sys
import subprocess
from pathlib import Path

HERE = Path(__file__)
ROOT = HERE.parent.parent
subprocess.check_call(["jlpm"], cwd=str(ROOT))
subprocess.check_call(["jlpm", "build"], cwd=str(ROOT))

subprocess.check_call([sys.executable, "-m", "build"], cwd=str(ROOT))


def setup(app):
app.connect("config-inited", on_config_inited)
15 changes: 15 additions & 0 deletions docs/content/example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer example.ts (since we do run typescript, just without strict checking of types)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, there might 2 reasons for this for now:

  • there seems to be an issue with JupyterLite showing the .ts file as base64 encoded (probably a lite issue, to be investigated)
  • arguably a JavaScript example is the simplest form of extension we can expose to folks new to web dev. Similar to the idea of using the JS cookiecutter as a simple version of the extension cookiecutter: https://github.com/jupyterlab/extension-cookiecutter-js

Happy to revisit this and make TS the default, but could also be done as a follow-up.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there seems to be an issue with JupyterLite showing the .ts file as base64 encoded (probably a lite issue, to be investigated)

can't know'em all: need to add to extra_file_types.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right I thought we had this one by default already.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched back to example.ts, although still thinking that a JS example could be relevant to folks new to the JS / TS ecosystem. We can get feedback about this and iterate as needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point. Well, maybe we could have both? I guess it does not matter as much for lite until we have LSP support. But once we have LSP in lite (which should be doable here), the TS/JS server gives better hints in TS mode (obviouly).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LSP in lite (which should be doable here),

Oh, indeed. That's been low-prof on my backburner for a while. As, I've mentioned, I think an in-browser json-language-server would have huge bang for the buck as being shipped in-core Lab, not just lite.

Getting to full-on pygls-based servers like jedi-language-server would be the next target... but the general case, often requiring subprocess.Popen or equivalent, is going to be real hard. Indeed, I reckon my whole "LSP-over-comms" rant would actually be even more relevant in lite, as at present, you'd need a second emcsripten computer with a big PROXYFS to run a blocking language server.

a JS example could be relevant to folks new to the JS / TS ecosystem

Yerp: I can't usually in good conscience suggest someone write non-TS labextensions, even to start with. The hill is already quite steep from "i got nothing" or "jquery-and-pray" to full-on you can't do anything without Generics, Promises, Signals, Interfaces, Tokens and doing so by "save-reload-refresh-ooops-hard-refresh" is maddening.

For now, I feel we should "push the veal" with a default .ts (and not .tsx).

It's worth exploring a baseline .js entirely annotated and typecheckable (and checked) with JSDoc-style annotations the never actually gets transpiled... which, alas, will never be the case, due to webpack and babel. Being able to learn about tsconfig.json interactively is indeed one of the things the plugin playground probably should do.

To that earlier notational point, it's frustrating that the requires and optional positional types for an activate, which one can't really avoid interacting with, are as poor as they are, but I can't imagine how confusing they would be without types. My kingdom for something that required zero types (much less generics), but still gave one the full benefits:

const fooPlugin = JupyterFrontEndPlugin({
  provides: IFoo,
  depends: {
    required: {notebooks: INotebookTracker},
    optional: {mainMenu: IMainMenu},
  },
  activate: (app, deps) => {
    deps.notebook.doThing  // always works
    deps.mainMenu.doThing // red squiggly yo-this-might-be-null
    deps.crazyPants.doThing // o no, wat?
  } 
});

To the earlier point: all would be right in the world if .mjs worked perfectly, and deduplicating module federation somehow worked fully off validateable package.json data (again with LSP support), and you could author code directly into your labextension/dist without jupyter lab build... but we can't really solve that problem here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which, alas, will never be the case, due to webpack and babel.

Did you see https://github.com/tc39/proposal-type-annotations? Agree on other bits.

* This is an example hello world plugin.
* Open Command Palette with Ctrl+Shift+C
* (Command+Shift+C on Mac) and select
* "Load Current File as Extension"
*/
const plugin = {
id: 'hello-world:plugin',
autoStart: true,
activate: (app) => {
alert('Hello World!');
},
};

export default plugin;
19 changes: 19 additions & 0 deletions docs/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: jupyterlab-plugin-playground-lite

channels:
- conda-forge

dependencies:
- build
- python=3.10
- mamba
- pydata-sphinx-theme
- myst-parser
- ipywidgets>=8.0,<9
- jupyterlab>=3.5.0,<4
- jupyterlab-language-pack-fr-FR
- jupyterlab-language-pack-zh-CN
- nodejs=18
- pip:
- jupyterlite-sphinx
- jupyterlite==0.1.0b14
8 changes: 8 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Try `jupyterlab-plugin-playground` in your browser right now ![try-badge]][try]

[try]: ./lite/lab/index.html?path=example.js
[try-badge]: https://jupyterlite.rtfd.io/en/latest/_static/badge.svg


```{include} ../README.md
```
6 changes: 6 additions & 0 deletions docs/jupyter-lite.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"jupyter-lite-schema-version": 0,
"jupyter-config-data": {
"appName": "JupyterLab Plugin Playground"
}
}
8 changes: 8 additions & 0 deletions docs/jupyter_lite_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

{
"LiteBuildConfig": {
"federated_extensions": [
"../jupyterlab_plugin_playground/labextension"
]
}
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ build_cmd = "build:prod"
npm = ["jlpm"]

[tool.check-manifest]
ignore = ["jupyterlab_plugin_playground/labextension/**", "yarn.lock", ".*", "package-lock.json", "scripts/**"]
ignore = ["docs/**", "jupyterlab_plugin_playground/labextension/**", "yarn.lock", ".*", "package-lock.json", "scripts/**"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe break up into lines and sort

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also add link to docs in the setup.py

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hoping to do more cleanups in #51