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 the sphinx-copybutton extension for easier copying codes #833

Closed
seisman opened this issue Feb 4, 2021 · 0 comments · Fixed by #838
Closed

Add the sphinx-copybutton extension for easier copying codes #833

seisman opened this issue Feb 4, 2021 · 0 comments · Fixed by #838
Labels
documentation Improvements or additions to documentation feature request New feature wanted

Comments

@seisman
Copy link
Member

seisman commented Feb 4, 2021

Description of the desired feature

The examples in the docstring have Python prompt likes >>> and ..., which makes it difficult to copy. For example, https://www.pygmt.org/dev/api/generated/pygmt.datasets.load_earth_relief.html#pygmt.datasets.load_earth_relief.

Directly copy the codes gives me the following codes:

>>> # load the default grid (pixel-registered 01d grid)
>>> grid = load_earth_relief()
>>> # load the 30m grid with "gridline" registration
>>> grid = load_earth_relief("30m", registration="gridline")
>>> # load high-resolution grid for a specific region
>>> grid = load_earth_relief(
...     "05m", region=[120, 160, 30, 60], registration="gridline"
... )

which is not ready for use.

The sphinx-copybutton extension can add a copy button to code blocks so readers can copy the codes by clicking the button. It can also strip the prompts.

I think the extension would make the documentation easier to use. What do you think @GenericMappingTools/python.

Are you willing to help implement and maintain this feature? Yes

@seisman seisman added feature request New feature wanted documentation Improvements or additions to documentation labels Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature request New feature wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant