File: interactive_examples.rst.inc

package info (click to toggle)
scipy 1.16.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 236,088 kB
  • sloc: cpp: 503,720; python: 345,302; ansic: 195,677; javascript: 89,566; fortran: 56,210; cs: 3,081; f90: 1,150; sh: 857; makefile: 771; pascal: 284; csh: 135; lisp: 134; xml: 56; perl: 51
file content (35 lines) | stat: -rw-r--r-- 1,515 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
.. _interactive-docs:

Interactive examples in docstrings
==================================

Examples within docstrings can be made interactive using the
`jupyterlite-sphinx extension <https://jupyterlite-sphinx.readthedocs.io/en/stable/>`__,
which implements the ``.. try_examples::`` directive. When used in the
"Examples" section of a docstring, this directive will create a button that
allows users to open the example in an interactive JupyterLite window, or in a
new tab as a Jupyter notebook. For SciPy, this directive is automatically added
to all docstrings with an "Examples" section through the
``global_enable_try_examples`` configuration option in ``doc/source/conf.py``.

To hide the buttons that turn docstring examples into embedded notebooks, after
building the html documentation, edit the ``try_examples.json`` runtime
configuration file after ``scipy/doc/build/html/`` and add the url paths of the
files to be ignored to the ``ignore_patterns`` list. This list expects elements
to be JavaScript Regex patterns. The initial version of this file in a clean
documentation build is

.. code-block:: json

   {
       "global_min_height": "400px",
       "ignore_patterns": [".*"]
   }

The buttons for converting examples sections into embedded interactive
notebooks are hidden by default on clean docs builds.

See the documentation for the ``jupyterlite-sphinx``
`TryExamples directive <https://jupyterlite-sphinx.readthedocs.io/en/stable/directives/try_examples.html#>`__
for more information.