Skip to content

Commit

Permalink
Use myst-nb to demo ipywidgets double render bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gabalafou committed Apr 11, 2024
1 parent 662758e commit a7361f6
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 5 deletions.
5 changes: 3 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,16 @@
"_extension.gallery_directive",
"_extension.component_directive",
# For extension examples and demos
"myst_parser",
# "myst_parser",
"ablog",
"jupyter_sphinx",
"sphinxcontrib.youtube",
"nbsphinx",
# "nbsphinx",
"numpydoc",
"sphinx_togglebutton",
"jupyterlite_sphinx",
"sphinx_favicon",
"myst_nb",
]

jupyterlite_config = "jupyterlite_config.json"
Expand Down
51 changes: 48 additions & 3 deletions docs/examples/pydata.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
"\n",
"This theme has built-in support and special styling for several major visualization libraries in the PyData ecosystem.\n",
"This ensures that the images and output generated by these libraries looks good for both light and dark modes.\n",
"Below are examples of each that we use as a benchmark for reference.\n",
"\n",
"Below are examples of each that we use as a benchmark for reference."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Pandas"
]
},
Expand All @@ -30,6 +35,46 @@
"df"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## IPyWidget"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"import ipywidgets as widgets\n",
"from IPython.display import display\n",
"\n",
"tab = widgets.Tab()\n",
"\n",
"descr_str = \"Hello\"\n",
"\n",
"title = widgets.HTML(descr_str)\n",
"\n",
"# create output widgets\n",
"widget_images = widgets.Output()\n",
"widget_annotations = widgets.Output()\n",
"\n",
"# render in output widgets\n",
"with widget_images:\n",
" display(pd.DataFrame(np.random.randn(10,10)))\n",
"with widget_annotations:\n",
" display(pd.DataFrame(np.random.randn(10,10)))\n",
"\n",
"tab.children = [widget_images, widget_annotations]\n",
"tab.titles = [\"Images\", \"Annotations\"]\n",
"\n",
"display(widgets.VBox([title, tab]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -143,7 +188,7 @@
},
"language_info": {
"name": "python",
"version": "3.10.8"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ doc = [
"nbsphinx",
"ipyleaflet",
"colorama",
"ipywidgets",
"myst-nb"
]
test = ["pytest", "pytest-cov", "pytest-regressions"]
dev = ["pyyaml", "pre-commit", "nox", "pydata-sphinx-theme[doc,test]"]
Expand Down

0 comments on commit a7361f6

Please sign in to comment.