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 29ce9e8a03446..6960230229c16 100644 --- a/environment.yml +++ b/environment.yml @@ -91,6 +91,7 @@ dependencies: - sphinx - sphinx-design - sphinx-copybutton + - sphinx-toggleprompt - types-python-dateutil - types-PyMySQL - types-pytz diff --git a/requirements-dev.txt b/requirements-dev.txt index ce0ff91b2c8b3..a60a0ba615d75 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -66,6 +66,7 @@ pytest-cython sphinx sphinx-design sphinx-copybutton +sphinx-toggleprompt types-python-dateutil types-PyMySQL types-pytz