Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: include jupyterlite in the supported extention #1023

Merged
merged 10 commits into from May 20, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/conf.py
Expand Up @@ -33,6 +33,7 @@
# "nbsphinx", # Uncomment and comment-out MyST-NB for local testing purposes.
"numpydoc",
"sphinx_togglebutton",
"jupyterlite_sphinx",
]

# -- Internationalization ------------------------------------------------
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
21 changes: 2 additions & 19 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 @@ -95,25 +93,10 @@ data

`ipyleaflet` is a **Jupyter**/**Leaflet** bridge enabling interactive maps in the Jupyter notebook environment. this demonstrate how you can integrate maps in your documentation.

```{code-cell}
```{jupyter-execute}
12rambau marked this conversation as resolved.
Show resolved Hide resolved
12rambau marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -68,6 +68,7 @@ doc = [
"sphinx-copybutton",
"sphinx-design",
"sphinx-togglebutton",
"jupyterlite-sphinx",
"sphinxcontrib-youtube",
# Install nbsphinx in case we want to test it locally even though we can't load
# it at the same time as MyST-NB.
Expand Down