Skip to content

Commit d3ec8f3

Browse files
Merge pull request #2291 from VWS-Python/copybutton
Use sphinx-copybutton to add a copy button to documentation code blocks
2 parents 1f26908 + f6eec6e commit d3ec8f3

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

docs/source/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
author = "Adam Dangoor"
1313

1414
extensions = [
15+
"sphinx_copybutton",
1516
"sphinx.ext.autodoc",
1617
"sphinx.ext.intersphinx",
1718
"sphinx.ext.napoleon",
@@ -26,6 +27,10 @@
2627
year = datetime.datetime.now(tz=datetime.UTC).year
2728
project_copyright = f"{year}, {author}"
2829

30+
# Exclude the prompt from copied code with sphinx_copybutton.
31+
# https://sphinx-copybutton.readthedocs.io/en/latest/use.html#automatic-exclusion-of-prompts-from-the-copies.
32+
copybutton_exclude = ".linenos, .gp"
33+
2934
# The version info for the project you're documenting, acts as replacement for
3035
# |version| and |release|, also used in various other places throughout the
3136
# built documents.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ optional-dependencies.dev = [
5959
"pyyaml==6.0.1",
6060
"ruff==0.5.5",
6161
"sphinx==7.4.7",
62+
"sphinx-copybutton==0.5.2",
6263
"sphinx-substitution-extensions==2024.2.25",
6364
"sphinxcontrib-spelling==8",
6465
"sybil==6.1.1",

0 commit comments

Comments
 (0)