From 89882fac6d7e3bd0b1df9f00cb0a7494026bd68c Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Sat, 11 Jun 2022 07:57:22 +0100 Subject: [PATCH 1/2] DOC: Use the sphinx-copybutton extension in documentation modified: ci/edmtool.py modified: docs/source/conf.py modified: enable/__init__.py --- ci/edmtool.py | 3 +++ docs/source/conf.py | 7 +++++++ enable/__init__.py | 2 ++ 3 files changed, 12 insertions(+) diff --git a/ci/edmtool.py b/ci/edmtool.py index 30d328591..7e71d5915 100644 --- a/ci/edmtool.py +++ b/ci/edmtool.py @@ -294,6 +294,9 @@ def docs(runtime, toolkit, environment): commands = [ "edm install -y -e {environment} " + packages, ] + commands += [ + "edm run -e {environment} -- python -m pip install sphinx-copybutton" + ] click.echo( "Installing documentation tools in '{environment}'".format( **parameters diff --git a/docs/source/conf.py b/docs/source/conf.py index 6aa8ffc90..72c2ac29b 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -38,6 +38,7 @@ "sphinx.ext.napoleon", # Link to code in sphinx generated API docs "sphinx.ext.viewcode", + "sphinx_copybutton", # Include trait definition comments in autogenerated API docs "traits.util.trait_documenter", ] @@ -98,6 +99,12 @@ # 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 # ----------------------- diff --git a/enable/__init__.py b/enable/__init__.py index 9cc0aa19c..2a8ad63a5 100644 --- a/enable/__init__.py +++ b/enable/__init__.py @@ -20,6 +20,8 @@ ] __extras_require__ = { + # Dependencies for documentation + "docs": ["enthought-sphinx-theme", "sphinx", "sphinx-copybutton"], # Dependencies for running enable/kiva's examples "examples": ["chaco", "mayavi", "scipy", "kiwisolver", "pyglet"], # Dependencies for GL backend support From e841c6227a1f9ab5c542f833f9bd5ad14b070d64 Mon Sep 17 00:00:00 2001 From: Poruri Sai Rahul Date: Mon, 13 Jun 2022 08:26:50 +0100 Subject: [PATCH 2/2] Update ci/edmtool.py --- ci/edmtool.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ci/edmtool.py b/ci/edmtool.py index 7e71d5915..8f75f84f2 100644 --- a/ci/edmtool.py +++ b/ci/edmtool.py @@ -293,9 +293,7 @@ def docs(runtime, toolkit, environment): ]) commands = [ "edm install -y -e {environment} " + packages, - ] - commands += [ - "edm run -e {environment} -- python -m pip install sphinx-copybutton" + "edm run -e {environment} -- python -m pip install sphinx-copybutton", ] click.echo( "Installing documentation tools in '{environment}'".format(