diff --git a/doc/source/conf.py b/doc/source/conf.py index f222a228531ff..1ff9c57f10988 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -57,6 +57,7 @@ "matplotlib.sphinxext.plot_directive", "numpydoc", "sphinx_copybutton", + "sphinx_toggleprompt", "sphinx_design", "sphinx.ext.autodoc", "sphinx.ext.autosummary", @@ -461,6 +462,10 @@ # If false, no module index is generated. # latex_use_modindex = True +# Configure copybutton to strip Python REPL prompts and output when copying code cells +copybutton_prompt_text = r">>> |\.\.\.:|In \[\d+\]:\n?|Out\[\d+\]:\n?" +copybutton_prompt_is_regexp = True + if include_api: intersphinx_mapping = { diff --git a/environment.yml b/environment.yml index 3e5b73d2cca0b..6f9a7b651933a 100644 --- a/environment.yml +++ b/environment.yml @@ -91,6 +91,7 @@ dependencies: - sphinx - sphinx-design - sphinx-copybutton + - sphinx-toggleprompt # static typing - scipy-stubs diff --git a/requirements-dev.txt b/requirements-dev.txt index c799fe3d2f076..07b22c74a8c0b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -66,6 +66,7 @@ pytest-cython sphinx sphinx-design sphinx-copybutton +sphinx-toggleprompt scipy-stubs types-python-dateutil types-PyMySQL