Skip to content

Commit d04d74a

Browse files
Add inline code examples to contributing guidelines (#1924)
Co-authored-by: Dongdong Tian <[email protected]>
1 parent 908cc2f commit d04d74a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

doc/contributing.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,30 @@ This will build the HTML files in `doc/_build/html`.
315315
Open `doc/_build/html/index.html` in your browser to view the pages. Follow the
316316
[pull request workflow](contributing.md#pull-request-workflow) to submit your changes for review.
317317

318+
### Adding example code
319+
320+
Many of the PyGMT functions have example code in their documentation. To contribute an
321+
example, add an "Example" header and put the example code below it. Have all lines
322+
begin with `>>>`. To keep this example code from being run during testing, add the code
323+
`__doctest_skip__ = [function name]` to the top of the module.
324+
325+
**Inline code example**
326+
327+
Below the import statements at the top of the file
328+
329+
``
330+
__doctest_skip__ = ["module_name"]
331+
``
332+
333+
At the end of the function's docstring
334+
335+
Example
336+
-------
337+
>>> import pygmt
338+
>>> # Comment describing what is happening
339+
>>> Code example
340+
341+
318342
### Contributing Gallery Plots
319343

320344
The gallery and tutorials are managed by

0 commit comments

Comments
 (0)