Skip to content

Commit a93363e

Browse files
authored
Use napoleon instead of numpydoc with sphinx (#383)
The napoleon sphinx extension renders the numpy docstrings better than numpydoc and works with newer versions of sphinx. This way, we upgrade to a newer sphinx which works better with the readthedocs theme. Older sphinx is also a problem for Python 3.8 packages on conda-forge.
1 parent 343c7ad commit a93363e

File tree

7 files changed

+30
-22
lines changed

7 files changed

+30
-22
lines changed

doc/_templates/autosummary/class.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44

55
.. autoclass:: {{ objname }}
66

7+
.. rubric:: Methods Summary
8+
9+
.. autosummary::
10+
{% for item in methods %}
11+
{% if item != '__init__' %}
12+
{{ objname }}.{{ item }}
13+
{% endif %}
14+
{% endfor %}
15+
16+
.. include:: backreferences/{{ fullname }}.examples
17+
718
.. raw:: html
819

920
<div style='clear:both'></div>
21+

doc/conf.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@
2020
"sphinx.ext.viewcode",
2121
"sphinx.ext.extlinks",
2222
"sphinx.ext.intersphinx",
23-
"numpydoc",
23+
"sphinx.ext.napoleon",
2424
"nbsphinx",
2525
"sphinx_gallery.gen_gallery",
2626
]
2727

2828
# Autosummary pages will be generated by sphinx-autogen instead of sphinx-build
29-
autosummary_generate = False
29+
autosummary_generate = []
3030

31-
numpydoc_class_members_toctree = False
31+
# Make the list of returns arguments and attributes render the same as the
32+
# parameters list
33+
napoleon_use_rtype = False
34+
napoleon_use_ivar = True
3235

3336
# configure links to GMT docs
3437
extlinks = {

environment.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ channels:
55
dependencies:
66
- python=3.7
77
- pip
8+
- gmt=6.0.0
89
- numpy
910
- pandas
1011
- xarray
@@ -18,10 +19,9 @@ dependencies:
1819
- pytest-mpl
1920
- coverage
2021
- black
21-
- pylint
22+
- pylint=2.2.2
2223
- flake8
23-
- sphinx<=1.8.5
24-
- sphinx_rtd_theme
24+
- sphinx=2.2.1
25+
- sphinx_rtd_theme=0.4.3
2526
- sphinx-gallery
2627
- nbsphinx
27-
- numpydoc

pygmt/base_plotting.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ def colorbar(self, **kwargs):
157157
158158
Full option list at :gmt-docs:`colorbar.html`
159159
160+
{aliases}
161+
160162
Parameters
161163
----------
162164
position (D) : str
@@ -175,7 +177,6 @@ def colorbar(self, **kwargs):
175177
default, the anchor point on the scale is assumed to be the bottom
176178
left corner (BL), but this can be changed by appending +j followed
177179
by a 2-char justification code justify.
178-
179180
box (F) : bool or str
180181
``[+cclearances][+gfill][+i[[gap/]pen]][+p[pen]][+r[radius]]
181182
[+s[[dx/dy/][shade]]]``. If set to True, draws a rectangular
@@ -192,18 +193,15 @@ def colorbar(self, **kwargs):
192193
offset background shaded region. Here, dx/dy indicates the shift
193194
relative to the foreground frame [4p/-4p] and shade sets the fill
194195
style to use for shading [gray50].
195-
196196
truncate (G) : list or str
197197
``zlo/zhi`` Truncate the incoming CPT so that the lowest and
198198
highest z-levels are to zlo and zhi. If one of these equal NaN then
199199
we leave that end of the CPT alone. The truncation takes place
200200
before the plotting.
201-
202201
scale (W) : float
203202
Multiply all z-values in the CPT by the provided scale. By default
204203
the CPT is used as is.
205204
206-
{aliases}
207205
"""
208206
kwargs = self._preprocess(**kwargs)
209207
with Session() as lib:

pygmt/gridding.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def surface(x=None, y=None, z=None, data=None, **kwargs):
3737
3838
Full option list at :gmt-docs:`surface.html`
3939
40+
{aliases}
41+
4042
Parameters
4143
----------
4244
x, y, z : 1d arrays
@@ -56,8 +58,6 @@ def surface(x=None, y=None, z=None, data=None, **kwargs):
5658
Optional. The file name for the output netcdf file with extension .nc
5759
to store the grid in.
5860
59-
{aliases}
60-
6161
Returns
6262
-------
6363
ret: xarray.DataArray or None

pygmt/mathops.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,43 @@ def makecpt(**kwargs):
1515
1616
Full option list at :gmt-docs:`makecpt.html`
1717
18+
{aliases}
19+
1820
Parameters
1921
----------
2022
cmap (C) : str
2123
Selects the master color palette table (CPT) to use in the
2224
interpolation. Full list of built-in color palette tables can be found
2325
at :gmt-docs:`cookbook/cpts.html#built-in-color-palette-tables-cpt`.
24-
2526
series (T) : list or str
2627
``[min/max/inc[+b|l|n]|file|list]``. Defines the range of the new CPT
2728
by giving the lowest and highest z-value (and optionally an interval).
2829
If this is not given, the existing range in the master CPT will be used
2930
intact.
30-
3131
truncate (G) : list or str
3232
``zlo/zhi``. Truncate the incoming CPT so that the lowest and highest
3333
z-levels are to zlo and zhi. If one of these equal NaN then we leave
3434
that end of the CPT alone. The truncation takes place before any
3535
resampling. See also
3636
:gmt-docs:`cookbook/features.html#manipulating-cpts`.
37-
3837
output (H) : str
3938
Optional. The file name with extension .cpt to store the generated CPT
4039
file. If not given or False (default), saves the CPT as the session
4140
current CPT.
42-
4341
reverse (I) : str
4442
Set this to True or c [Default] to reverse the sense of color
4543
progression in the master CPT. Set this to z to reverse the sign of
4644
z-values in the color table. Note that this change of z-direction
4745
happens before -G and -T values are used so the latter must be
4846
compatible with the changed z-range. See also
4947
:gmt-docs:`cookbook/features.html#manipulating-cpts`.
50-
5148
continuous (Z) : bool
5249
Creates a continuous CPT [Default is discontinuous, i.e., constant
5350
colors for each interval]. This option has no effect when no -T is
5451
used, or when using -Tz_min/z_max; in the first case the input CPT
5552
remains untouched, in the second case it is only scaled to match the
5653
range z_min/z_max.
5754
58-
{aliases}
5955
"""
6056
with Session() as lib:
6157
if "H" not in kwargs.keys(): # if no output is set

requirements-dev.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ coverage
99
black
1010
pylint
1111
flake8
12-
sphinx<=1.8.5
13-
sphinx_rtd_theme
12+
sphinx=2.2.1
13+
sphinx_rtd_theme=0.4.3
1414
sphinx-gallery
1515
nbsphinx
16-
numpydoc

0 commit comments

Comments
 (0)