Skip to content

Commit

Permalink
Use the "sphinx-copybutton" extension in documentation (#1651)
Browse files Browse the repository at this point in the history
DOC: Use the sphinx-copybutton extension in documentation

	modified:   .github/workflows/test-documentation-build.yml
	modified:   docs/source/conf.py
	modified:   etstool.py
	modified:   setup.py

Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
  • Loading branch information
Poruri Sai Rahul and mdickinson committed Jun 14, 2022
1 parent e525c57 commit f17231e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/test-documentation-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Install dependencies and local packages
run: |
python -m pip install --upgrade pip
python -m pip install Sphinx enthought_sphinx_theme
python -m pip install Sphinx enthought_sphinx_theme sphinx-copybutton
python -m pip install .
- name: Build HTML documentation with Sphinx
run: |
Expand Down
7 changes: 7 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"sphinx_copybutton",
"traits.util.trait_documenter",
]

Expand Down Expand Up @@ -116,6 +117,12 @@

autodoc_member_order = "bysource"

# Options for Sphinx copybutton extension
# ---------------------------------------

# Matches prompts - "$ ", ">>>" and "..."
copybutton_prompt_text = r">>> |\.\.\. |\$ "
copybutton_prompt_is_regexp = True

# Options for HTML output
# -----------------------
Expand Down
9 changes: 9 additions & 0 deletions etstool.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@
"traitsui",
}

# Dependencies that need to be installed from PyPO
pypi_dependencies = {"sphinx-copybutton"}

# Dependencies we install from source for testing
source_dependencies = {"traitsui"}

Expand Down Expand Up @@ -189,6 +192,12 @@ def install(edm, runtime, environment, editable, source):
install_stubs,
]

if pypi_dependencies:
commands += [
"{edm} run -e {environment} -- python -m pip install " + dep
for dep in pypi_dependencies
]

click.echo("Creating environment '{environment}'".format(**parameters))
execute(commands, parameters)
if source:
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ def get_long_description():
"docs": [
"enthought-sphinx-theme",
"Sphinx>=2.1.0,!=3.2.0",
"sphinx-copybutton",
],
"test": [
"Cython",
Expand Down

0 comments on commit f17231e

Please sign in to comment.