Skip to content

Commit 75e56e5

Browse files
authored
Fix the example codes in the contributors guides (#2929)
1 parent 21a8722 commit 75e56e5

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

doc/contributing.md

+23-19
Original file line numberDiff line numberDiff line change
@@ -320,24 +320,24 @@ Open `doc/_build/html/index.html` in your browser to view the pages. Follow the
320320
Many of the PyGMT functions have example code in their documentation. To contribute an
321321
example, add an "Example" header and put the example code below it. Have all lines
322322
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.
323+
`__doctest_skip__ = ["function_name"]` to the top of the module.
324324

325325
**Inline code example**
326326

327327
Below the import statements at the top of the file
328328

329-
``
330-
__doctest_skip__ = ["module_name"]
331-
``
332-
333-
At the end of the function's docstring
329+
```python
330+
__doctest_skip__ = ["function_name"]
334331

335-
Example
336-
-------
337-
>>> import pygmt
338-
>>> # Comment describing what is happening
339-
>>> Code example
332+
At the end of the function's docstring:
340333

334+
```python
335+
Example
336+
-------
337+
>>> import pygmt
338+
>>> # Comment describing what is happening
339+
>>> Code example
340+
```
341341

342342
### Contributing Gallery Plots
343343

@@ -580,7 +580,9 @@ returning the `pygmt.Figure` object:
580580
```python
581581
@pytest.mark.mpl_image_compare
582582
def test_my_plotting_case():
583-
"Test that my plotting method works"
583+
"""
584+
Test that my plotting method works.
585+
"""
584586
fig = Figure()
585587
fig.basemap(region=[0, 360, -90, 90], projection="W15c", frame=True)
586588
return fig
@@ -675,20 +677,22 @@ summarized as follows:
675677
dvc push # Run before git push to enable automated testing with the new images
676678
git push
677679

678-
#### Using check_figures_equal
680+
#### Using `check_figures_equal`
679681

680682
This approach draws the same figure using two different methods (the reference
681683
method and the tested method), and checks that both of them are the same.
682-
It takes two `pygmt.Figure` objects ('fig_ref' and 'fig_test'), generates a png
684+
It takes two `pygmt.Figure` objects (`fig_ref` and `fig_test`), generates a png
683685
image, and checks for the Root Mean Square (RMS) error between the two.
684686
Here's an example:
685687

686688
```python
687689
@check_figures_equal()
688690
def test_my_plotting_case():
689-
"Test that my plotting method works"
690-
fig_ref, fig_test = Figure(), Figure()
691-
fig_ref.grdimage("@earth_relief_01d_g", projection="W120/15c", cmap="geo")
692-
fig_test.grdimage(grid, projection="W120/15c", cmap="geo")
693-
return fig_ref, fig_test
691+
"""
692+
Test that my plotting method works.
693+
"""
694+
fig_ref, fig_test = Figure(), Figure()
695+
fig_ref.grdimage("@earth_relief_01d_g", projection="W120/15c", cmap="geo")
696+
fig_test.grdimage(grid, projection="W120/15c", cmap="geo")
697+
return fig_ref, fig_test
694698
```

0 commit comments

Comments
 (0)