Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sphinx-copybutton extension to easily copy codes #838

Merged
merged 4 commits into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions doc/_static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,20 @@ h1 {
margin-top: 20px;
}
}

/* Style for the copy button */
/* Safe to remove for sphinx-copybutton>0.3.1
* https://github.com/executablebooks/sphinx-copybutton/pull/107
*/
a.copybtn {
position: absolute;
top: .2em;
right: .2em;
width: 1.3em;
height: 1.3em;
opacity: .3;
transition: opacity 0.5s;
border: none;
user-select: none;
}

8 changes: 8 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"sphinx.ext.napoleon",
"nbsphinx",
"sphinx_gallery.gen_gallery",
"sphinx_copybutton",
]

# Autosummary pages will be generated by sphinx-autogen instead of sphinx-build
Expand All @@ -52,6 +53,13 @@
"xarray": ("http://xarray.pydata.org/en/stable/", None),
}

# options for sphinx-copybutton
# https://sphinx-copybutton.readthedocs.io
copybutton_prompt_text = r">>> |\.\.\. "
copybutton_prompt_is_regexp = True
copybutton_only_copy_prompt_lines = True
copybutton_remove_prompts = True

sphinx_gallery_conf = {
# path to your examples scripts
"examples_dirs": [
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ dependencies:
- pytest-mpl
- pytest>=6.0
- sphinx
- sphinx-copybutton
- sphinx-gallery
- sphinx_rtd_theme=0.4.3
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ pytest-cov
pytest-mpl
pytest>=6.0
sphinx
sphinx-copybutton
sphinx-gallery
sphinx_rtd_theme==0.4.3