Skip to content

Commit 8e4e228

Browse files
committed
Move code out of Installation.ipynb
1 parent 43a08ce commit 8e4e228

File tree

3 files changed

+43
-56
lines changed

3 files changed

+43
-56
lines changed

docs/Installation.ipynb

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,62 +8,14 @@
88
},
99
"outputs": [],
1010
"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()))"
11+
"from markdown import markdown\n",
12+
"from versions import (\n",
13+
" JUPYTER_LSP_VERSION,\n",
14+
" JUPYTERLAB_LSP_VERSION,\n",
15+
" JUPYTERLAB_NEXT_MAJOR_VERSION,\n",
16+
" JUPYTERLAB_VERSION,\n",
17+
" REQUIRED_JUPYTERLAB\n",
18+
")"
6719
]
6820
},
6921
{

docs/markdown.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from IPython.display import Markdown
2+
from IPython.core.magic import register_cell_magic, needs_local_scope
3+
4+
5+
@register_cell_magic
6+
@needs_local_scope
7+
def markdown(line, cell, local_ns):
8+
"""Cell interpreted as Markdown but with variable substitution support.
9+
10+
Variables from global environment will be substituted using the standard
11+
Python format mechanism which uses single curly braces (e.g. {variable})
12+
"""
13+
return Markdown(cell.format(**local_ns))

docs/versions.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import json
2+
from sys import path
3+
4+
path.insert(0, '../py_src/jupyter_lsp')
5+
6+
import _version # noqa
7+
8+
9+
JUPYTER_LSP_VERSION = _version.__version__
10+
11+
with open('../packages/jupyterlab-lsp/package.json') as f:
12+
jupyterlab_lsp_package = json.load(f)
13+
14+
JUPYTERLAB_LSP_VERSION = jupyterlab_lsp_package['version']
15+
JUPYTERLAB_VERSION = (
16+
jupyterlab_lsp_package
17+
['devDependencies']
18+
['@jupyterlab/application']
19+
.lstrip('~^')
20+
)
21+
JUPYTERLAB_NEXT_MAJOR_VERSION = int(JUPYTERLAB_VERSION.split('.')[0]) + 1
22+
REQUIRED_JUPYTERLAB = f'>={JUPYTERLAB_VERSION},<{JUPYTERLAB_NEXT_MAJOR_VERSION}'

0 commit comments

Comments
 (0)