Skip to content

Commit f911809

Browse files
committed
Doc: render the widgets in notebook
1 parent 2ac14de commit f911809

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

docs/source/conf.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
from aiidalab_widgets_base import __version__ # pylint: disable=wrong-import-position
1818

19+
# work around unpickleable functions
20+
sys.path.append(str(Path(__file__).parent))
21+
from ipywidgets_docs_utils import jupyterlab_markdown_heading
22+
1923
# Add any Sphinx extension module names here, as strings. They can be
2024
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
2125
# ones.
@@ -27,7 +31,21 @@
2731
"myst_nb",
2832
]
2933

30-
nb_execution_mode = "off"
34+
myst_heading_anchors = 4
35+
myst_heading_slug_func = jupyterlab_markdown_heading
36+
37+
nb_ipywidgets_js = {
38+
"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js": {
39+
"integrity": "sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=",
40+
"crossorigin": "anonymous",
41+
},
42+
"https://cdn.jsdelivr.net/npm/@jupyter-widgets/html-manager@*/dist/embed-amd.js": {
43+
"data-jupyter-widgets-cdn": "https://cdn.jsdelivr.net/npm/",
44+
"crossorigin": "anonymous",
45+
},
46+
}
47+
48+
nb_execution_mode = "cache"
3149

3250
# Add any paths that contain templates here, relative to this directory.
3351
templates_path = ["_templates"]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def jupyterlab_markdown_heading(heading_text):
2+
"""Use JupyterLab-style anchors for a consistent authoring/viewing experience.
3+
4+
This _must_ be defined in an external file as local functions can't be asssigned
5+
to config values, as they can't be pickled.
6+
"""
7+
return heading_text.replace(" ", "-")

notebooks/viewers.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
" 'parameter 4' : [1, 2, 3],\n",
4747
"})\n",
4848
"vwr = viewer(p.store(), downloadable=True)\n",
49+
"vwr.layout.width = '80%'\n",
4950
"display(vwr)"
5051
]
5152
},

0 commit comments

Comments
 (0)