13
13
from pygmt .helpers .utils import is_nonstr_iter
14
14
15
15
COMMON_OPTIONS = {
16
- "R" : """\
16
+ "R" : r """
17
17
region : str or list
18
18
*Required if this is the first plot command*.
19
- ``' xmin/xmax/ymin/ymax[+r][+uunit]'`` .
19
+ * xmin/xmax/ymin/ymax*\ [**+r**][**+u**\ *unit*] .
20
20
Specify the region of interest.""" ,
21
- "J" : """\
21
+ "J" : r """
22
22
projection : str
23
23
*Required if this is the first plot command*.
24
+ *projcode*\[*projparams*/]\ *width*.
24
25
Select map projection.""" ,
25
- "B" : """\
26
- frame : str or list
26
+ "B" : r """
27
+ frame : bool or str or list
27
28
Set map boundary frame and axes attributes.""" ,
28
29
"U" : """\
29
30
timestamp : bool or str
30
31
Draw GMT time stamp logo on plot.""" ,
31
- "CPT" : """\
32
+ "CPT" : r """
32
33
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.""" ,
35
37
"G" : """\
36
38
color : str
37
39
Select color or pattern for filling of symbols or polygons. Default
38
40
is no fill.""" ,
39
41
"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
42
44
written to stderr. Choose among 7 levels of verbosity:
43
45
44
46
- **q** - Quiet, not even fatal error messages are produced
45
47
- **e** - Error messages only
46
48
- **w** - Warnings [Default]
47
49
- **t** - Timings (report runtimes for time-intensive algorthms);
48
- - **i** - Informational messages (same as " verbose=True" )
50
+ - **i** - Informational messages (same as `` verbose=True`` )
49
51
- **c** - Compatibility warnings
50
52
- **d** - Debugging messages""" ,
51
53
"W" : """\
52
54
pen : str
53
55
Set pen attributes for lines or the outline of symbols.""" ,
54
- "XY" : """\
56
+ "XY" : r """
55
57
xshift : str
56
- ``[a|c|f|r][ xshift]`` .
58
+ [**a**\|\ **c**\|\ **f**\|\ **r**\][* xshift*] .
57
59
Shift plot origin in x-direction.
58
60
yshift : str
59
- ``[a|c|f|r][ yshift]`` .
61
+ [**a**\|\ **c**\|\ **f**\|\ **r**\][* yshift*] .
60
62
Shift plot origin in y-direction. Full documentation is at
61
63
:gmt-docs:`gmt.html#xy-full`.
62
64
""" ,
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*].
65
68
Selects a specific subplot panel. Only allowed when in subplot
66
69
mode. Use ``panel=True`` to advance to the next panel in the
67
70
selected order. Instead of *row,col* you may also give a scalar
68
71
value *index* which depends on the order you set via ``autolabel``
69
72
when the subplot was defined. **Note**: *row*, *col*, and *index*
70
73
all start at 0.
71
74
""" ,
72
- "j" : """\
75
+ "j" : r """
73
76
distcalc : str
74
- ``e|f|g`` .
77
+ **e**\|\ **f**\|\ **g** .
75
78
Determine how spherical distances are calculated.
76
79
77
80
- **e** - Ellipsoidal (or geodesic) mode
78
81
- **f** - Flat Earth mode
79
82
- **g** - Great circle distance [Default]
80
83
81
84
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 """
87
90
interpolation : str
88
- ``[b|c|l|n][+a][+bBC][+c][+tthreshold]``
91
+ [**b**\|\ **c**\|\ **l**\|\ **n**][**+a**][**+b**\ *BC*][**+c**][**+t**\ *threshold*].
89
92
Select interpolation mode for grids. You can select the type of
90
93
spline used:
91
94
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 """
97
100
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*].
99
103
Select perspective view and set the azimuth and elevation angle of
100
104
the viewpoint. Default is [180, 90]. Full documentation is at
101
105
:gmt-docs:`gmt.html#perspective-full`.
102
106
""" ,
103
- "registration" : """\
107
+ "registration" : r """
104
108
registration : str
105
- ``[g|p]``
109
+ **g**\|\ **p**.
106
110
Force output grid to be gridline (g) or pixel (p) node registered.
107
111
Default is gridline (g).""" ,
108
112
"t" : """\
109
- transparency : float
113
+ transparency : int or float
110
114
Set transparency level, in [0-100] percent range.
111
115
Default is 0, i.e., opaque.
112
116
Only visible when PDF or raster format output is selected.
113
117
Only the PNG format selection adds a transparency layer
114
118
in the image (for further processing). """ ,
115
- "x" : """\
116
- cores : int
117
- ``[[-]n]`` .
119
+ "x" : r """
120
+ cores : bool or int
121
+ [[**-**]\ *n*] .
118
122
Limit the number of cores to be used in any OpenMP-enabled
119
123
multi-threaded algorithms. By default we try to use all available
120
124
cores. Set a number *n* to only use n cores (if too large it will
121
125
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).
124
128
""" ,
125
129
}
126
130
127
131
128
132
def fmt_docstring (module_func ):
129
- """
133
+ r """
130
134
Decorator to insert common text into module docstrings.
131
135
132
136
Should be the last decorator (at the top).
@@ -182,10 +186,11 @@ def fmt_docstring(module_func):
182
186
----------
183
187
region : str or list
184
188
*Required if this is the first plot command*.
185
- ``' xmin/xmax/ymin/ymax[+r][+uunit]'`` .
189
+ * xmin/xmax/ymin/ymax*\ [**+r**][**+u**\ *unit*] .
186
190
Specify the region of interest.
187
191
projection : str
188
192
*Required if this is the first plot command*.
193
+ *projcode*\[*projparams*/]\ *width*.
189
194
Select map projection.
190
195
<BLANKLINE>
191
196
**Aliases:**
@@ -204,9 +209,9 @@ def fmt_docstring(module_func):
204
209
filler_text ["aliases" ] = "\n " .join (aliases )
205
210
206
211
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 " ) )
210
215
211
216
# Dedent the docstring to make it all match the option text.
212
217
docstring = textwrap .dedent (module_func .__doc__ )
0 commit comments