Skip to content

Commit d2331ae

Browse files
authored
Add copybutton extension to template docs. (#429)
* Add copybutton extension to template docs. * Formatting.
1 parent d395883 commit d2331ae

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

python-project-template/{% if include_docs %}docs{% endif %}/conf.py.jinja

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ extensions.append("autoapi.extension")
3131
extensions.append("nbsphinx")
3232
{%- endif %}
3333

34+
# -- sphinx-copybutton configuration ----------------------------------------
35+
extensions.append("sphinx_copybutton")
36+
## sets up the expected prompt text from console blocks, and excludes it from
37+
## the text that goes into the clipboard.
38+
copybutton_exclude = ".linenos, .gp"
39+
copybutton_prompt_text = ">> "
40+
41+
## lets us suppress the copy button on select code blocks.
42+
copybutton_selector = "div:not(.no-copybutton) > div.highlight > pre"
43+
3444
templates_path = []
3545
exclude_patterns = ["_build", "**.ipynb_checkpoints"]
3646

python-project-template/{% if include_docs %}docs{% endif %}/index.rst.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ virtual environment. LINCC-Frameworks engineers primarily use `conda` to manage
1313
environments. If you have conda installed locally, you can run the following to
1414
create and activate a new environment.
1515

16-
.. code-block:: bash
16+
.. code-block:: console
1717

1818
>> conda create env -n <env_name> python=3.10
1919
>> conda activate <env_name>
@@ -22,7 +22,7 @@ create and activate a new environment.
2222
Once you have created a new environment, you can install this project for local
2323
development using the following commands:
2424

25-
.. code-block:: bash
25+
.. code-block:: console
2626

2727
>> pip install -e .'[dev]'
2828
>> pre-commit install

python-project-template/{% if include_docs %}docs{% endif %}/requirements.txt.jinja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
sphinx
22
sphinx-rtd-theme
33
sphinx-autoapi
4+
sphinx-copybutton
45
{%- if include_notebooks %}
56
nbsphinx
67
ipython

0 commit comments

Comments
 (0)