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

documentation improvements for copying functionality #62

Merged
merged 1 commit into from
Feb 6, 2020
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
3 changes: 2 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@
# html_sidebars = {}

# CopyButton configuration
# copybutton_prompt_text = ">>> "
copybutton_prompt_text = ">>> "
# Switches for testing but shouldn't be activated in the live docs
# copybutton_only_copy_prompt_lines = False
# copybutton_remove_prompts = False
# copybutton_image_path = "test/TEST_COPYBUTTON.png"
Expand Down
29 changes: 14 additions & 15 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,20 @@ And here's a code block, note the copy button to the right!

copy me!

By default, ``sphinx-copybutton`` will remove Python prompts from
each line that begins with them. If it finds lines that start with the
prompt text, all *other* lines will not be copied.
For example, try copying the text
below:

If the code block overlaps to the right of the text area, you can just click
the button to get the whole thing.

.. code-block:: bash

123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789

You can configure ``sphinx-copybutton`` to detect *input prompts* in code
cells, and then both remove these prompts before copying, as well as skip
lines that *don't* start with prompts (in case they are output lines).

For example, this site has been configured to strip Python prompts (">>> ").
Try copy-pasting the code block below.

.. code-block:: python

Expand All @@ -42,16 +51,6 @@ below:
>>> print(b)
wow

The text that ``sphinx-copybutton`` uses can be configured as well. See
:ref:`configure_copy_text` for more information.

If the code block overlaps to the right of the text area, you can just click
the button to get the whole thing.

.. code-block:: bash

123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789123456789

Installation
============

Expand Down