Skip to content

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

Closed

Description

@seisman

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

Activity

  1. added
    feature request
    documentation
    on Feb 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationfeature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions