Skip to content

Commit

Permalink
ENH: include jupyterlite in the supported extention (#1023)
Browse files Browse the repository at this point in the history
* display a jupyterlite output

* simplify the build

* add jupyterlite to the req

* add disclaimer

* split viz libs and execution libs

* Update docs/examples/pydata.md
  • Loading branch information
12rambau committed May 20, 2023
1 parent 874b2bd commit 9f04c2f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 18 deletions.
1 change: 1 addition & 0 deletions docs/conf.py
Expand Up @@ -42,6 +42,7 @@
# "nbsphinx", # Uncomment and comment-out MyST-NB for local testing purposes.
"numpydoc",
"sphinx_togglebutton",
"jupyterlite_sphinx",
"sphinx_favicon",
]

Expand Down
38 changes: 38 additions & 0 deletions docs/examples/execution.rst
@@ -0,0 +1,38 @@
Execution Libraries
===================

Many execution libraries can be used to display the output of IPyhton cells. We used ``MySTnb`` to parse and display the outputs presented in :doc:`./pydata`. In this section we'll show alternatives that runs code for you using a Jupyter like kernel.

Jupyterlite
-----------

.. warning::
The jupyterLite lib is not yet providing a handle to switch from light to dark theme. If you consider using it in your documentation you should also enforce the light theme to your users.
Follow https://github.com/jupyterlite/jupyterlite-sphinx/issues/69 for more information.

``jupyterlite-sphinx`` brings the power of `JupyterLite <https://jupyterlite.readthedocs.io/en/latest/>`__ to your Sphinx documentation. It makes a full JupyterLite deployment in your docs and provide some utilities for using that deployment easily.

This section demonstrate how it displays in a **pydata-sphinx-theme** context:

.. replite::
:kernel: python
:height: 600px
:prompt: Try Replite!

print("it's a test")

jupyter-sphinx
--------------

Another common library is ``jupyter-sphinx``.
This section demonstrates a subset of functionality to make sure it behaves as expected.

.. jupyter-execute::

import matplotlib.pyplot as plt
import numpy as np

rng = np.random.default_rng()
data = rng.standard_normal((3, 100))
fig, ax = plt.subplots()
ax.scatter(data[0], data[1], c=data[2], s=3)
1 change: 1 addition & 0 deletions docs/examples/index.rst
Expand Up @@ -19,6 +19,7 @@ See the sections in the primary sidebar and below to explore.

kitchen-sink/index
pydata
execution
api


Expand Down
19 changes: 1 addition & 18 deletions docs/examples/pydata.md
Expand Up @@ -3,8 +3,6 @@ file_format: mystnb
kernelspec:
name: python3
display_name: Python 3
mystnb:
execution_mode: cache
---

% To test this file with nbsphinx we need to convert to ipynb. To do this:
Expand Down Expand Up @@ -97,23 +95,8 @@ data

```{code-cell}
from ipyleaflet import Map, basemaps
from IPython.display import display
# display a map centered on France
m = Map(basemap=basemaps.Esri.WorldImagery, zoom=5, center=[46.21, 2.21])
display(m)
```

## jupyter-sphinx

This theme has styling for [`jupyter-sphinx`](https://jupyter-sphinx.readthedocs.io/), which is often used for executing and displaying widgets with a Jupyter kernel.

```{jupyter-execute}
import matplotlib.pyplot as plt
import numpy as np
rng = np.random.default_rng()
data = rng.standard_normal((3, 100))
fig, ax = plt.subplots()
ax.scatter(data[0], data[1], c=data[2], s=3)
m
```
1 change: 1 addition & 0 deletions pyproject.toml
Expand Up @@ -66,6 +66,7 @@ doc = [
"sphinx-copybutton",
"sphinx-design",
"sphinx-togglebutton",
"jupyterlite-sphinx",
"sphinxcontrib-youtube",
"sphinx-favicon>=1.0.1",
# Install nbsphinx in case we want to test it locally even though we can't load
Expand Down

0 comments on commit 9f04c2f

Please sign in to comment.