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 inline code examples to contributing guidelines #1924

Merged
merged 4 commits into from
Jun 1, 2022
Merged
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
24 changes: 24 additions & 0 deletions doc/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,30 @@ This will build the HTML files in `doc/_build/html`.
Open `doc/_build/html/index.html` in your browser to view the pages. Follow the
[pull request workflow](contributing.md#pull-request-workflow) to submit your changes for review.

### Adding example code

Many of the PyGMT functions have example code in their documentation. To contribute an
example, add an "Example" header and put the example code below it. Have all lines
begin with `>>>`. To keep this example code from being run during testing, add the code
`__doctest_skip__ = [function name]` to the top of the module.

**Inline code example**

Below the import statements at the top of the file

``
__doctest_skip__ = ["module_name"]
``

At the end of the function's docstring

Example
-------
>>> import pygmt
>>> # Comment describing what is happening
>>> Code example


### Contributing Gallery Plots

The gallery and tutorials are managed by
Expand Down