Skip to content

Commit b8385bf

Browse files
authored
Update docstrings of common aliases (#862)
Update the docstrings of the aliases in COMMON_OPTIONS in decorators.py
1 parent bd362bb commit b8385bf

File tree

1 file changed

+48
-43
lines changed

1 file changed

+48
-43
lines changed

pygmt/helpers/decorators.py

+48-43
Original file line numberDiff line numberDiff line change
@@ -13,120 +13,124 @@
1313
from pygmt.helpers.utils import is_nonstr_iter
1414

1515
COMMON_OPTIONS = {
16-
"R": """\
16+
"R": r"""
1717
region : str or list
1818
*Required if this is the first plot command*.
19-
``'xmin/xmax/ymin/ymax[+r][+uunit]'``.
19+
*xmin/xmax/ymin/ymax*\ [**+r**][**+u**\ *unit*].
2020
Specify the region of interest.""",
21-
"J": """\
21+
"J": r"""
2222
projection : str
2323
*Required if this is the first plot command*.
24+
*projcode*\[*projparams*/]\ *width*.
2425
Select map projection.""",
25-
"B": """\
26-
frame : str or list
26+
"B": r"""
27+
frame : bool or str or list
2728
Set map boundary frame and axes attributes.""",
2829
"U": """\
2930
timestamp : bool or str
3031
Draw GMT time stamp logo on plot.""",
31-
"CPT": """\
32+
"CPT": r"""
3233
cmap : str
33-
File name of a CPT file or ``C='color1,color2[,color3,...]'`` to
34-
build a linear continuous CPT from those colors automatically.""",
34+
File name of a CPT file or a series of comma-separated colors
35+
(e.g., *color1*,\ *color2*,\ *color3*) to build a linear continuous
36+
CPT from those colors automatically.""",
3537
"G": """\
3638
color : str
3739
Select color or pattern for filling of symbols or polygons. Default
3840
is no fill.""",
3941
"V": """\
40-
verbose : str
41-
Select verbosity level [Default is w], which modulates the messages
42+
verbose : bool or str
43+
Select verbosity level [Default is **w**], which modulates the messages
4244
written to stderr. Choose among 7 levels of verbosity:
4345
4446
- **q** - Quiet, not even fatal error messages are produced
4547
- **e** - Error messages only
4648
- **w** - Warnings [Default]
4749
- **t** - Timings (report runtimes for time-intensive algorthms);
48-
- **i** - Informational messages (same as "verbose=True")
50+
- **i** - Informational messages (same as ``verbose=True``)
4951
- **c** - Compatibility warnings
5052
- **d** - Debugging messages""",
5153
"W": """\
5254
pen : str
5355
Set pen attributes for lines or the outline of symbols.""",
54-
"XY": """\
56+
"XY": r"""
5557
xshift : str
56-
``[a|c|f|r][xshift]``.
58+
[**a**\|\ **c**\|\ **f**\|\ **r**\][*xshift*].
5759
Shift plot origin in x-direction.
5860
yshift : str
59-
``[a|c|f|r][yshift]``.
61+
[**a**\|\ **c**\|\ **f**\|\ **r**\][*yshift*].
6062
Shift plot origin in y-direction. Full documentation is at
6163
:gmt-docs:`gmt.html#xy-full`.
6264
""",
63-
"c": r"""panel : int or list or bool
64-
[*row*\ ,\ *col*\|\ *index*].
65+
"c": r"""
66+
panel : bool or int or list
67+
[*row,col*\|\ *index*].
6568
Selects a specific subplot panel. Only allowed when in subplot
6669
mode. Use ``panel=True`` to advance to the next panel in the
6770
selected order. Instead of *row,col* you may also give a scalar
6871
value *index* which depends on the order you set via ``autolabel``
6972
when the subplot was defined. **Note**: *row*, *col*, and *index*
7073
all start at 0.
7174
""",
72-
"j": """\
75+
"j": r"""
7376
distcalc : str
74-
``e|f|g``.
77+
**e**\|\ **f**\|\ **g**.
7578
Determine how spherical distances are calculated.
7679
7780
- **e** - Ellipsoidal (or geodesic) mode
7881
- **f** - Flat Earth mode
7982
- **g** - Great circle distance [Default]
8083
8184
All spherical distance calculations depend on the current ellipsoid
82-
(PROJ_ELLIPSOID), the definition of the mean radius
83-
(PROJ_MEAN_RADIUS), and the specification of latitude type
84-
(PROJ_AUX_LATITUDE). Geodesic distance calculations is also
85-
controlled by method (PROJ_GEODESIC).""",
86-
"n": """\
85+
(:gmt-term:`PROJ_ELLIPSOID`), the definition of the mean radius
86+
(:gmt-term:`PROJ_MEAN_RADIUS`), and the specification of latitude type
87+
(:gmt-term:`PROJ_AUX_LATITUDE`). Geodesic distance calculations is also
88+
controlled by method (:gmt-term:`PROJ_GEODESIC`).""",
89+
"n": r"""
8790
interpolation : str
88-
``[b|c|l|n][+a][+bBC][+c][+tthreshold]``
91+
[**b**\|\ **c**\|\ **l**\|\ **n**][**+a**][**+b**\ *BC*][**+c**][**+t**\ *threshold*].
8992
Select interpolation mode for grids. You can select the type of
9093
spline used:
9194
92-
- 'b' for B-spline
93-
- 'c' for bicubic [Default]
94-
- 'l' for bilinear
95-
- 'n' for nearest-neighbor""",
96-
"p": """\
95+
- **b** for B-spline
96+
- **c** for bicubic [Default]
97+
- **l** for bilinear
98+
- **n** for nearest-neighbor""",
99+
"p": r"""
97100
perspective : list or str
98-
``'[x|y|z]azim[/elev[/zlevel]][+wlon0/lat0[/z0]][+vx0/y0]'``.
101+
[**x**\|\ **y**\|\ **z**]\ *azim*\[/*elev*\[/*zlevel*]]
102+
[**+w**\ *lon0*/*lat0*\[/*z0*]][**+v**\ *x0*/*y0*].
99103
Select perspective view and set the azimuth and elevation angle of
100104
the viewpoint. Default is [180, 90]. Full documentation is at
101105
:gmt-docs:`gmt.html#perspective-full`.
102106
""",
103-
"registration": """\
107+
"registration": r"""
104108
registration : str
105-
``[g|p]``
109+
**g**\|\ **p**.
106110
Force output grid to be gridline (g) or pixel (p) node registered.
107111
Default is gridline (g).""",
108112
"t": """\
109-
transparency : float
113+
transparency : int or float
110114
Set transparency level, in [0-100] percent range.
111115
Default is 0, i.e., opaque.
112116
Only visible when PDF or raster format output is selected.
113117
Only the PNG format selection adds a transparency layer
114118
in the image (for further processing). """,
115-
"x": """\
116-
cores : int
117-
``[[-]n]``.
119+
"x": r"""
120+
cores : bool or int
121+
[[**-**]\ *n*].
118122
Limit the number of cores to be used in any OpenMP-enabled
119123
multi-threaded algorithms. By default we try to use all available
120124
cores. Set a number *n* to only use n cores (if too large it will
121125
be truncated to the maximum cores available). Finally, give a
122-
negative number *-n* to select (all - n) cores (or at least 1 if
123-
n equals or exceeds all).
126+
negative number *-n* to select (all - *n*) cores (or at least 1 if
127+
*n* equals or exceeds all).
124128
""",
125129
}
126130

127131

128132
def fmt_docstring(module_func):
129-
"""
133+
r"""
130134
Decorator to insert common text into module docstrings.
131135
132136
Should be the last decorator (at the top).
@@ -182,10 +186,11 @@ def fmt_docstring(module_func):
182186
----------
183187
region : str or list
184188
*Required if this is the first plot command*.
185-
``'xmin/xmax/ymin/ymax[+r][+uunit]'``.
189+
*xmin/xmax/ymin/ymax*\ [**+r**][**+u**\ *unit*].
186190
Specify the region of interest.
187191
projection : str
188192
*Required if this is the first plot command*.
193+
*projcode*\[*projparams*/]\ *width*.
189194
Select map projection.
190195
<BLANKLINE>
191196
**Aliases:**
@@ -204,9 +209,9 @@ def fmt_docstring(module_func):
204209
filler_text["aliases"] = "\n".join(aliases)
205210

206211
for marker, text in COMMON_OPTIONS.items():
207-
# Remove the indentation from the multiline strings so that it doesn't
208-
# mess up the original docstring
209-
filler_text[marker] = textwrap.dedent(text)
212+
# Remove the indentation and the first line break from the multiline
213+
# strings so that it doesn't mess up the original docstring
214+
filler_text[marker] = textwrap.dedent(text.lstrip("\n"))
210215

211216
# Dedent the docstring to make it all match the option text.
212217
docstring = textwrap.dedent(module_func.__doc__)

0 commit comments

Comments
 (0)