Skip to content

Commit 9936c9f

Browse files
authored
Use longname placeholders in the docstrings for common options (#1932)
1 parent 9a986ba commit 9936c9f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+523
-534
lines changed

pygmt/figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def psconvert(self, icc_gray=False, **kwargs):
223223
both an EPS and a PDF file. Using **F** creates a multi-page PDF
224224
file from the list of input PS or PDF files. It requires the
225225
``prefix`` parameter.
226-
{V}
226+
{verbose}
227227
"""
228228
kwargs = self._preprocess(**kwargs)
229229
# Default cropping the figure to True

pygmt/helpers/decorators.py

Lines changed: 34 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,40 @@
1414
from pygmt.exceptions import GMTInvalidInput
1515
from pygmt.helpers.utils import is_nonstr_iter
1616

17-
COMMON_OPTIONS = {
18-
"R": r"""
17+
COMMON_DOCSTRINGS = {
18+
"region": r"""
1919
region : str or list
2020
*xmin/xmax/ymin/ymax*\ [**+r**][**+u**\ *unit*].
2121
Specify the :doc:`region </tutorials/basics/regions>` of interest.""",
22-
"J": r"""
22+
"projection": r"""
2323
projection : str
2424
*projcode*\[*projparams*/]\ *width*.
2525
Select map :doc:`projection </projections/index>`.""",
26-
"A": r"""
26+
"area_thresh": r"""
2727
area_thresh : int or float or str
2828
*min_area*\ [/*min_level*/*max_level*][**+a**\[**g**\|\ **i**]\
2929
[**s**\|\ **S**]][**+l**\|\ **r**][**+p**\ *percent*].
3030
Features with an area smaller than *min_area* in km\ :sup:`2` or of
3131
hierarchical level that is lower than *min_level* or higher than
3232
*max_level* will not be plotted [Default is 0/0/4 (all
3333
features)].""",
34-
"B": r"""
34+
"frame": r"""
3535
frame : bool or str or list
3636
Set map boundary
3737
:doc:`frame and axes attributes </tutorials/basics/frames>`. """,
38-
"U": """\
38+
"timestamp": """\
3939
timestamp : bool or str
4040
Draw GMT time stamp logo on plot.""",
41-
"CPT": r"""
41+
"cmap": r"""
4242
cmap : str
4343
File name of a CPT file or a series of comma-separated colors
4444
(e.g., *color1*,\ *color2*,\ *color3*) to build a linear continuous
4545
CPT from those colors automatically.""",
46-
"G": """\
46+
"color": """\
4747
color : str or 1d array
4848
Select color or pattern for filling of symbols or polygons. Default
4949
is no fill.""",
50-
"I": r"""
50+
"spacing": r"""
5151
spacing : str
5252
*x_inc*\ [**+e**\|\ **n**][/\ *y_inc*\ [**+e**\|\ **n**]].
5353
*x_inc* [and optionally *y_inc*] is the grid spacing.
@@ -78,7 +78,7 @@
7878
**Note**: If ``region=grdfile`` is used then the grid spacing and
7979
the registration have already been initialized; use ``spacing`` and
8080
``registration`` to override these values.""",
81-
"V": """\
81+
"verbose": """\
8282
verbose : bool or str
8383
Select verbosity level [Default is **w**], which modulates the messages
8484
written to stderr. Choose among 7 levels of verbosity:
@@ -90,10 +90,10 @@
9090
- **i** - Informational messages (same as ``verbose=True``)
9191
- **c** - Compatibility warnings
9292
- **d** - Debugging messages""",
93-
"W": """\
93+
"pen": """\
9494
pen : str
9595
Set pen attributes for lines or the outline of symbols.""",
96-
"XY": r"""
96+
"xyshift": r"""
9797
xshift : str
9898
[**a**\|\ **c**\|\ **f**\|\ **r**\][*xshift*].
9999
Shift plot origin in x-direction.
@@ -102,13 +102,13 @@
102102
Shift plot origin in y-direction. Full documentation is at
103103
:gmt-docs:`gmt.html#xy-full`.
104104
""",
105-
"a": r"""
105+
"aspatial": r"""
106106
aspatial : bool or str
107107
[*col*\ =]\ *name*\ [,...].
108108
Control how aspatial data are handled during input and output.
109109
Full documentation is at :gmt-docs:`gmt.html#aspatial-full`.
110110
""",
111-
"b": r"""
111+
"binary": r"""
112112
binary : bool or str
113113
**i**\|\ **o**\ [*ncols*][*type*][**w**][**+l**\|\ **b**].
114114
Select native binary input (using ``binary="i"``) or output
@@ -136,15 +136,15 @@
136136
be read as little- or big-endian, respectively.
137137
138138
Full documentation is at :gmt-docs:`gmt.html#bi-full`.""",
139-
"d": r"""
139+
"nodata": r"""
140140
nodata : str
141141
**i**\|\ **o**\ *nodata*.
142142
Substitute specific values with NaN (for tabular data). For
143143
example, ``d="-9999"`` will replace all values equal to -9999 with
144144
NaN during input and all NaN values with -9999 during output.
145145
Prepend **i** to the *nodata* value for input columns only. Prepend
146146
**o** to the *nodata* value for output columns only.""",
147-
"c": r"""
147+
"panel": r"""
148148
panel : bool or int or list
149149
[*row,col*\|\ *index*].
150150
Select a specific subplot panel. Only allowed when in subplot
@@ -154,21 +154,21 @@
154154
when the subplot was defined. **Note**: *row*, *col*, and *index*
155155
all start at 0.
156156
""",
157-
"e": r"""
157+
"find": r"""
158158
find : str
159159
[**~**]\ *"pattern"* \| [**~**]/\ *regexp*/[**i**].
160160
Only pass records that match the given *pattern* or regular
161161
expressions [Default processes all records]. Prepend **~** to
162162
the *pattern* or *regexp* to instead only pass data expressions
163163
that do not match the pattern. Append **i** for case insensitive
164164
matching. This does not apply to headers or segment headers.""",
165-
"f": r"""
165+
"coltypes": r"""
166166
coltypes : str
167167
[**i**\|\ **o**]\ *colinfo*.
168168
Specify data types of input and/or output columns (time or
169169
geographical data). Full documentation is at
170170
:gmt-docs:`gmt.html#f-full`.""",
171-
"g": r"""
171+
"gap": r"""
172172
gap : str or list
173173
**x**\|\ **y**\|\ **z**\|\ **d**\|\ **X**\|\ **Y**\|\
174174
**D**\ *gap*\ [**u**][**+a**][**+c**\ *col*][**+n**\|\ **p**].
@@ -209,7 +209,7 @@
209209
column value must exceed *gap* for a break to be imposed.
210210
- **+p** - specify that the current value minus the previous
211211
value must exceed *gap* for a break to be imposed.""",
212-
"h": r"""
212+
"header": r"""
213213
header : str
214214
[**i**\|\ **o**][*n*][**+c**][**+d**][**+m**\ *segheader*][**+r**\
215215
*remark*][**+t**\ *title*].
@@ -231,7 +231,7 @@
231231
line-breaks.
232232
233233
Blank lines and lines starting with \# are always skipped.""",
234-
"i": r"""
234+
"incols": r"""
235235
incols : str or 1d array
236236
Specify data columns for primary input in arbitrary order. Columns
237237
can be repeated and columns not listed will be skipped [Default
@@ -261,7 +261,7 @@
261261
[Default is 1].
262262
- **+o** to add the given *offset* to the input values [Default
263263
is 0].""",
264-
"j": r"""
264+
"distcalc": r"""
265265
distcalc : str
266266
**e**\|\ **f**\|\ **g**.
267267
Determine how spherical distances are calculated.
@@ -275,11 +275,11 @@
275275
(:gmt-term:`PROJ_MEAN_RADIUS`), and the specification of latitude type
276276
(:gmt-term:`PROJ_AUX_LATITUDE`). Geodesic distance calculations is also
277277
controlled by method (:gmt-term:`PROJ_GEODESIC`).""",
278-
"l": r"""
278+
"label": r"""
279279
label : str
280280
Add a legend entry for the symbol or line being plotted. Full
281281
documentation is at :gmt-docs:`gmt.html#l-full`.""",
282-
"n": r"""
282+
"interpolation": r"""
283283
interpolation : str
284284
[**b**\|\ **c**\|\ **l**\|\ **n**][**+a**][**+b**\ *BC*][**+c**][**+t**\ *threshold*].
285285
Select interpolation mode for grids. You can select the type of
@@ -289,7 +289,7 @@
289289
- **c** for bicubic [Default]
290290
- **l** for bilinear
291291
- **n** for nearest-neighbor""",
292-
"o": r"""
292+
"outcols": r"""
293293
outcols : str or 1d array
294294
*cols*\ [,...][,\ **t**\ [*word*]].
295295
Specify data columns for primary output in arbitrary order. Columns
@@ -312,21 +312,21 @@
312312
input and skip trailing text. **Note**: If ``incols`` is also
313313
used then the columns given to ``outcols`` correspond to the
314314
order after the ``incols`` selection has taken place.""",
315-
"p": r"""
315+
"perspective": r"""
316316
perspective : list or str
317317
[**x**\|\ **y**\|\ **z**]\ *azim*\[/*elev*\[/*zlevel*]]\
318318
[**+w**\ *lon0*/*lat0*\[/*z0*]][**+v**\ *x0*/*y0*].
319319
Select perspective view and set the azimuth and elevation angle of
320320
the viewpoint. Default is [180, 90]. Full documentation is at
321321
:gmt-docs:`gmt.html#perspective-full`.
322322
""",
323-
"r": r"""
323+
"registration": r"""
324324
registration : str
325325
**g**\|\ **p**.
326326
Force gridline (**g**) or pixel (**p**) node registration.
327327
[Default is **g**\ (ridline)].
328328
""",
329-
"s": r"""
329+
"skiprows": r"""
330330
skiprows : bool or str
331331
[*cols*][**+a**][**+r**].
332332
Suppress output for records whose *z*-value equals NaN [Default
@@ -342,14 +342,14 @@
342342
- **+a** to suppress the output of the record if just one or
343343
more of the columns equal NaN [Default skips record only
344344
if values in all specified *cols* equal NaN].""",
345-
"t": """\
345+
"transparency": """\
346346
transparency : int or float
347347
Set transparency level, in [0-100] percent range.
348348
Default is 0, i.e., opaque.
349349
Only visible when PDF or raster format output is selected.
350350
Only the PNG format selection adds a transparency layer
351351
in the image (for further processing). """,
352-
"w": r"""
352+
"wrap": r"""
353353
wrap : str
354354
**y**\|\ **a**\|\ **w**\|\ **d**\|\ **h**\|\ **m**\|\ **s**\|\
355355
**c**\ *period*\ [/*phase*][**+c**\ *col*].
@@ -367,7 +367,7 @@
367367
- **c** - custom cycle (normalized)
368368
369369
Full documentation is at :gmt-docs:`gmt.html#w-full`.""",
370-
"x": r"""
370+
"cores": r"""
371371
cores : bool or int
372372
[[**-**]\ *n*].
373373
Limit the number of cores to be used in any OpenMP-enabled
@@ -391,17 +391,6 @@ def fmt_docstring(module_func):
391391
* ``{aliases}``: Insert a section listing the parameter aliases defined by
392392
decorator ``use_alias``.
393393
394-
The following are places for common parameter descriptions:
395-
396-
* ``{R}``: region (bounding box as west, east, south, north)
397-
* ``{J}``: projection (coordinate system to use)
398-
* ``{B}``: frame (map frame and axes parameters)
399-
* ``{U}``: timestamp (insert time stamp logo)
400-
* ``{CPT}``: cmap (the color palette table)
401-
* ``{G}``: color
402-
* ``{W}``: pen
403-
* ``{n}``: interpolation
404-
405394
Parameters
406395
----------
407396
module_func : function
@@ -426,8 +415,8 @@ def fmt_docstring(module_func):
426415
... data : str or {table-like}
427416
... Pass in either a file name to an ASCII data table, a 2D
428417
... {table-classes}.
429-
... {R}
430-
... {J}
418+
... {region}
419+
... {projection}
431420
...
432421
... {aliases}
433422
... '''
@@ -481,7 +470,7 @@ def fmt_docstring(module_func):
481470
" tabular data"
482471
)
483472

484-
for marker, text in COMMON_OPTIONS.items():
473+
for marker, text in COMMON_DOCSTRINGS.items():
485474
# Remove the indentation and the first line break from the multiline
486475
# strings so that it doesn't mess up the original docstring
487476
filler_text[marker] = textwrap.dedent(text.lstrip("\n"))

pygmt/src/basemap.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ def basemap(self, **kwargs):
4848
4949
Parameters
5050
----------
51-
{J}
51+
{projection}
5252
zscale/zsize : float or str
5353
Set z-axis scaling or z-axis size.
54-
{R}
54+
{region}
5555
*Required if this is the first plot command.*
56-
{B}
56+
{frame}
5757
map_scale : str
5858
[**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*\
5959
**+w**\ *length*.
@@ -82,13 +82,13 @@ def basemap(self, **kwargs):
8282
compass : str
8383
Draws a map magnetic rose on the map at the location defined by the
8484
reference and anchor points
85-
{U}
86-
{V}
87-
{XY}
88-
{c}
89-
{f}
90-
{p}
91-
{t}
85+
{timestamp}
86+
{verbose}
87+
{xyshift}
88+
{panel}
89+
{coltypes}
90+
{perspective}
91+
{transparency}
9292
"""
9393
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
9494
if not args_in_kwargs(args=["B", "L", "Td", "Tm", "c"], kwargs=kwargs):

pygmt/src/binstats.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ def binstats(data, **kwargs):
9393
computed while the count will be the sum of the weights instead of
9494
number of points. If the weights are actually uncertainties
9595
(one sigma) then append **+s** and weight = 1/sigma.
96-
{I}
97-
{R}
98-
{V}
99-
{a}
100-
{b}
101-
{h}
102-
{i}
103-
{r}
96+
{spacing}
97+
{region}
98+
{verbose}
99+
{aspatial}
100+
{binary}
101+
{header}
102+
{incols}
103+
{registration}
104104
105105
Returns
106106
-------

0 commit comments

Comments
 (0)