From d0e50f85b6e8435f13d46332b58e3b9efc4b6c9c Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Sat, 11 Jun 2022 07:42:30 +0100 Subject: [PATCH] DOC: Use the sphinx-copybutton extension in documentation modified: chaco/__init__.py modified: ci/edmtool.py modified: docs/source/conf.py --- chaco/__init__.py | 2 +- ci/edmtool.py | 8 ++++++++ docs/source/conf.py | 7 +++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/chaco/__init__.py b/chaco/__init__.py index 4e09e98a9..ecbe18c4d 100644 --- a/chaco/__init__.py +++ b/chaco/__init__.py @@ -15,6 +15,6 @@ __extras_require__ = { - "docs": ["enthought-sphinx-theme", "sphinx"], + "docs": ["enthought-sphinx-theme", "sphinx", "sphinx-copybutton"], 'examples': ['encore', 'scipy', 'pandas'] } diff --git a/ci/edmtool.py b/ci/edmtool.py index 8efc1e187..118ec605a 100644 --- a/ci/edmtool.py +++ b/ci/edmtool.py @@ -95,6 +95,8 @@ "swig", } +pypi_dependencies = {"sphinx-copybutton"} + # Dependencies we install from source for cron tests # Order from packages with the most dependencies to one with the least # dependencies. Packages are forced re-installed in this order. @@ -215,6 +217,12 @@ def install(runtime, toolkit, environment, editable, source): " --no-dependencies"), ] + if pypi_dependencies: + commands.extend([ + "edm run -e {environment} -- python -m pip install " + dep + for dep in pypi_dependencies + ]) + click.echo("Creating environment '{environment}'".format(**parameters)) execute(commands, parameters) diff --git a/docs/source/conf.py b/docs/source/conf.py index 51d4099fa..3fd0769ba 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -34,6 +34,7 @@ def get_build_docset(): 'sphinx.ext.graphviz', 'sphinx.ext.intersphinx', 'sphinx.ext.todo', + 'sphinx_copybutton', 'traits.util.trait_documenter', ] @@ -94,6 +95,12 @@ def get_build_docset(): # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' +# Options for Sphinx copybutton extension +# --------------------------------------- + +# Matches prompts - "$ ", ">>>" and "..." +copybutton_prompt_text = r">>> |\.\.\. |\$ " +copybutton_prompt_is_regexp = True # Options for HTML output # -----------------------