Skip to content

Commit 43a08ce

Browse files
committed
Infer versions in docs/Installation.ipynb
1 parent a5653a5 commit 43a08ce

File tree

2 files changed

+108
-24
lines changed

2 files changed

+108
-24
lines changed

docs/Installation.ipynb

Lines changed: 103 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,71 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"metadata": {
7+
"hide_input": true
8+
},
9+
"outputs": [],
10+
"source": [
11+
"from sys import path\n",
12+
"path.insert(0, '../py_src/jupyter_lsp')"
13+
]
14+
},
15+
{
16+
"cell_type": "code",
17+
"execution_count": null,
18+
"metadata": {
19+
"hide_input": true
20+
},
21+
"outputs": [],
22+
"source": [
23+
"import _version\n",
24+
"JUPYTER_LSP_VERSION = _version.__version__"
25+
]
26+
},
27+
{
28+
"cell_type": "code",
29+
"execution_count": null,
30+
"metadata": {
31+
"hide_input": true
32+
},
33+
"outputs": [],
34+
"source": [
35+
"import json\n",
36+
"\n",
37+
"with open('../packages/jupyterlab-lsp/package.json') as f:\n",
38+
" jupyterlab_lsp_package = json.load(f)\n",
39+
"\n",
40+
"JUPYTERLAB_LSP_VERSION = jupyterlab_lsp_package['version']\n",
41+
"JUPYTERLAB_VERSION = jupyterlab_lsp_package['devDependencies']['@jupyterlab/application'].lstrip('~^')\n",
42+
"JUPYTERLAB_NEXT_MAJOR_VERSION = int(JUPYTERLAB_VERSION.split('.')[0]) + 1\n",
43+
"\n",
44+
"REQUIRED_JUPYTERLAB = f'>={JUPYTERLAB_VERSION},<{JUPYTERLAB_NEXT_MAJOR_VERSION}'"
45+
]
46+
},
47+
{
48+
"cell_type": "code",
49+
"execution_count": null,
50+
"metadata": {
51+
"hide_input": true
52+
},
53+
"outputs": [],
54+
"source": [
55+
"from IPython.display import Markdown\n",
56+
"from IPython.core.magic import register_cell_magic\n",
57+
"\n",
58+
"\n",
59+
"@register_cell_magic\n",
60+
"def markdown(line, cell):\n",
61+
" \"\"\"Cell itnerpreted as Markdown but with variable substitution support.\n",
62+
"\n",
63+
" Variables from global environment will be substituted using the standard\n",
64+
" Python format mechanism which uses single curly braces (e.g. {variable})\n",
65+
" \"\"\"\n",
66+
" return Markdown(cell.format(**globals()))"
67+
]
68+
},
369
{
470
"cell_type": "markdown",
571
"metadata": {},
@@ -8,9 +74,14 @@
874
]
975
},
1076
{
11-
"cell_type": "markdown",
12-
"metadata": {},
77+
"cell_type": "code",
78+
"execution_count": null,
79+
"metadata": {
80+
"hide_input": true
81+
},
82+
"outputs": [],
1383
"source": [
84+
"%%markdown\n",
1485
"### Please Read This First\n",
1586
"\n",
1687
"Delivering LSP features to your JupyterLab **requires** three pieces:\n",
@@ -28,7 +99,7 @@
2899
"- runs in your browser, as an extension to JupyterLab\n",
29100
"- to install it, you need:\n",
30101
" - `nodejs >8`\n",
31-
" - `jupyterlab >=2.1,<3`\n",
102+
" - `jupyterlab {REQUIRED_JUPYTERLAB}`\n",
32103
"\n",
33104
"#### Language Servers\n",
34105
"\n",
@@ -49,17 +120,22 @@
49120
]
50121
},
51122
{
52-
"cell_type": "markdown",
53-
"metadata": {},
123+
"cell_type": "code",
124+
"execution_count": null,
125+
"metadata": {
126+
"hide_input": true
127+
},
128+
"outputs": [],
54129
"source": [
130+
"%%markdown\n",
55131
"#### conda (minimal python)\n",
56132
"\n",
57133
"```bash\n",
58-
"conda create -c conda-forge -n lsp 'python >=3.7,<3.8' 'jupyterlab=2.1' 'nodejs>8' python-language-server\n",
134+
"conda create -c conda-forge -n lsp 'python >=3.7,<3.8' 'jupyterlab={JUPYTERLAB_VERSION}' 'nodejs>8' python-language-server\n",
59135
"# Also consider: r-languageserver [*]\n",
60136
"source activate lsp\n",
61-
"python -m pip install 'jupyter-lsp=0.8.0' --no-deps\n",
62-
"jupyter labextension install '@krassowski/jupyterlab-lsp@1.0.0'\n",
137+
"python -m pip install 'jupyter-lsp={JUPYTER_LSP_VERSION}' --no-deps\n",
138+
"jupyter labextension install '@krassowski/jupyterlab-lsp@{JUPYTERLAB_LSP_VERSION}'\n",
63139
"```\n",
64140
"\n",
65141
"Then run\n",
@@ -84,9 +160,14 @@
84160
]
85161
},
86162
{
87-
"cell_type": "markdown",
88-
"metadata": {},
163+
"cell_type": "code",
164+
"execution_count": null,
165+
"metadata": {
166+
"hide_input": true
167+
},
168+
"outputs": [],
89169
"source": [
170+
"%%markdown\n",
90171
"##### `Dockerfile`\n",
91172
"\n",
92173
"```dockerfile\n",
@@ -98,9 +179,9 @@
98179
" 'jupyterlab=2.1' \\\n",
99180
" 'r-languageserver' \\\n",
100181
" && python3 -m pip install --no-cache-dir --no-deps \\\n",
101-
" 'jupyter-lsp=0.8.0' \\\n",
182+
" 'jupyter-lsp={JUPYTER_LSP_VERSION}' \\\n",
102183
" && jupyter labextension install --no-build \\\n",
103-
" '@krassowski/jupyterlab-lsp@1.0.0' \\\n",
184+
" '@krassowski/jupyterlab-lsp@{JUPYTERLAB_LSP_VERSION}' \\\n",
104185
" && jupyter lab build --dev-build=False --minimize=True \\\n",
105186
" && conda clean --all -f -y \\\n",
106187
" && rm -rf \\\n",
@@ -202,14 +283,19 @@
202283
]
203284
},
204285
{
205-
"cell_type": "markdown",
206-
"metadata": {},
286+
"cell_type": "code",
287+
"execution_count": null,
288+
"metadata": {
289+
"hide_input": true
290+
},
291+
"outputs": [],
207292
"source": [
293+
"%%markdown\n",
208294
"#### Install Jupyter[Lab] LSP\n",
209295
"\n",
210296
"```bash\n",
211-
"pip install jupyter-lsp=0.8.0\n",
212-
"jupyter labextension install @krassowski/jupyterlab-lsp@1.0.0\n",
297+
"pip install jupyter-lsp={JUPYTER_LSP_VERSION}\n",
298+
"jupyter labextension install @krassowski/jupyterlab-lsp@{JUPYTERLAB_LSP_VERSION}\n",
213299
"```"
214300
]
215301
},
@@ -245,7 +331,7 @@
245331
"name": "python",
246332
"nbconvert_exporter": "python",
247333
"pygments_lexer": "ipython3",
248-
"version": "3.7.6"
334+
"version": "3.7.5"
249335
}
250336
},
251337
"nbformat": 4,

docs/Releasing.ipynb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,24 @@
3030
"- `py_src/jupyter_lsp/_version.py` (canonical)\n",
3131
"- `azure-pipelines.yml`\n",
3232
"- `CHANGELOG.md`\n",
33-
"- `docs/Installation.ipynb`\n",
3433
"\n",
3534
"The npm version of `jupyterlab-lsp` must be updated in the following places:\n",
3635
"\n",
37-
"- `packages/jupyterlab-lsp/package.json` (canonical)\n",
36+
"- `packages/jupyterlab-lsp/package.json` > `version` (canonical)\n",
3837
"- `azure-pipelines.yml`\n",
3938
"- `packages/metapackage/package.json`\n",
4039
"- `CHANGELOG.md`\n",
41-
"- `docs/Installation.ipynb`\n",
4240
"\n",
4341
"The npm version of `lsp-ws-connection` must be updated in the following places:\n",
4442
"\n",
45-
"- `packages/lsp-ws-connection/package.json` (canonical)\n",
43+
"- `packages/lsp-ws-connection/package.json` > `version` (canonical)\n",
4644
"- `packages/jupyterlab-lsp/package.json`\n",
4745
"- `CHANGELOG.md`\n",
4846
"\n",
4947
"The JupyterLab version (if a newer is supported or required) needs to be updated in:\n",
5048
"\n",
51-
"- `README.md` (canonical)\n",
52-
"- `docs/Installation.ipynb`\n",
49+
"- `packages/jupyterlab-lsp/package.json` > `devDependencies` > `@jupyterlab/application` (canonical)\n",
50+
"- `README.md`\n",
5351
"\n",
5452
"### Releasing:\n",
5553
"\n",
@@ -81,7 +79,7 @@
8179
"name": "python",
8280
"nbconvert_exporter": "python",
8381
"pygments_lexer": "ipython3",
84-
"version": "3.8.0"
82+
"version": "3.7.5"
8583
}
8684
},
8785
"nbformat": 4,

0 commit comments

Comments
 (0)