Skip to content

Commit c4e18c1

Browse files
authored
docs: Various docstring fixes related to parameter markup (#5869)
I've batched here some queued commits that addresses various small warnings, or just to continue aligning the docstrings with other places. Some of the fixes here seemed to have originated from copy-paste errors, and a few are real typos too. Using admonitions (boxes) for "Attention: " rendered quite nice and colourful, so I kept it. Escaping a trailing underscore in the parameter list is necessary as it was interpreted as a label, so then the parameters weren't matching the signature, when using some stricter warnings. And the backslash needs to be escaped too, as one is for python to keep the backslash, the second one to pass to sphinx/docutils. So, `:param xxxx_: bla bla bla` into `:param xxxx\\_: bla bla bla` When finding issues, I was doing searches on the repo to find other cases. Usually I was skipping the gui folder, as I wasn't building the docs for it, but this time I let one slip. There was one parameter that I didn't know how to document, as the previous text was completely unrelated (copy-paste error). * docs: Fix indent of return of grass.grassdb.read() * docs: Fix docstring formatting of grass.jupyter.interactivemap * docs: Fix param syntax of grass.script.core * docs: Use attention admonitions in docstrings of grass.pygrass.gis.region * docs: Use double backticks for inline code style in grass.script.core * docs: Replace `<tt></tt>` markup with double backticks in docstrings * docs: Use double backticks for inline code style in docstrings of grass.script.core and grass.script.raster3d * docs: Fix some invalid parameter list generating warnings * docs: Fix note syntax in grass.jupyter.interactivemap.InteractiveMap.add_raster() * docs: Fix typos in described parameter not matching the signature * docs: Escape parameters ending with underscores in docstrings * docs: Add or remove parameters in docstrings that don't belong to the functions in grass.temporal Probably copy paste errors * docs: Remove contradicting type in param list of python/grass/script/utils.py * docs: Add LineDist return type in docstring of grass.pygrass.vector.geometry.Line.distance() * docs: Fill in docstring for grass.script.utils.text_to_string()
1 parent 7bc9ce0 commit c4e18c1

File tree

18 files changed

+88
-87
lines changed

18 files changed

+88
-87
lines changed

gui/wxpython/iscatt/dialogs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def __init__(
234234
"""Dialog for export of category raster.
235235
236236
:param parent: window
237-
:param str rasterName name of vector layer for export
237+
:param str rasterName: name of vector layer for export
238238
:param title: window title
239239
"""
240240
wx.Dialog.__init__(self, parent, id, title, style=style, **kwargs)

python/grass/grassdb/history.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ def read(history_path):
130130
"""Read the content of the history file.
131131
132132
:param str history_path: path to the history log file
133-
:return content_list: list of dictionaries
134-
with 'command' and 'command_info' keys
133+
:return content_list: list of dictionaries with 'command' and 'command_info' keys
135134
"""
136135
if get_history_file_extension(history_path) == ".json":
137136
return _read_from_JSON(history_path)

python/grass/jupyter/interactivemap.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ def __init__(
6363
):
6464
"""Reproject GRASS raster, export to PNG, and compute bounding box.
6565
66-
param str name: layer name
67-
param str title: title of layer to display in layer control legend
68-
param bool use_region: use computational region of current mapset
69-
param str saved_region: name of saved computation region
70-
param renderer: instance of ReprojectionRenderer
71-
**kwargs: keyword arguments passed to folium/ipyleaflet layer instance
66+
:param str name: layer name
67+
:param str title: title of layer to display in layer control legend
68+
:param bool use_region: use computational region of current mapset
69+
:param str saved_region: name of saved computation region
70+
:param renderer: instance of ReprojectionRenderer
71+
:param kwargs: keyword arguments passed to folium/ipyleaflet layer instance
7272
"""
7373
self._name = name
7474
self._layer_kwargs = kwargs
@@ -355,10 +355,11 @@ def add_raster(self, name, title=None, **kwargs):
355355
Color table for the raster can be modified with `r.colors` before calling
356356
this function.
357357
358-
.. note:: This will only work if the raster is located in the current mapset.
359-
To change the color table of a raster located outside the current mapset,
360-
switch to that mapset with `g.mapset`, modify the color table with `r.color`
361-
then switch back to the initial mapset and run this function.
358+
.. note::
359+
This will only work if the raster is located in the current mapset.
360+
To change the color table of a raster located outside the current mapset,
361+
switch to that mapset with ``g.mapset``, modify the color table with ``r.color``
362+
then switch back to the initial mapset and run this function.
362363
363364
:param str name: name of raster to add to display; positional-only parameter
364365
:param str title: raster name for layer control
@@ -372,7 +373,8 @@ def add_layer_control(self, **kwargs):
372373
373374
A Layer Control is added by default. Call this function to customize
374375
layer control object. Accepts keyword arguments to be passed to leaflet
375-
layer control object"""
376+
layer control object
377+
"""
376378

377379
if self._folium:
378380
self.layer_control_object = self._folium.LayerControl(**kwargs)

python/grass/pygrass/gis/region.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ def set_raster_region(self):
459459
"""Set the computational region (window) for all raster maps in the current
460460
process.
461461
462-
Attention: All raster objects must be closed or the
462+
.. Attention:: All raster objects must be closed or the
463463
process will be terminated.
464464
465465
The Raster library C function Rast_set_window() is called.
@@ -498,7 +498,7 @@ def set_current(self):
498498
This function adjusts the values before setting the region
499499
so you don't have to call G_adjust_Cell_head().
500500
501-
Attention: Only the current process is affected.
501+
.. Attention:: Only the current process is affected.
502502
The GRASS computational region is not affected.
503503
504504
:Example:

python/grass/pygrass/modules/grid/grid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,8 @@ class GridModule:
410410
:type mapset_prefix: str
411411
:param patch_backend: "r.patch", "RasterRow", or None for for default
412412
:type patch_backend: None or str
413-
:param run_: if False only instantiate the object
414-
:type run_: bool
413+
:param run\\_: if False only instantiate the object
414+
:type run\\_: bool
415415
:param args: give all the parameters to the command
416416
:param kargs: give all the parameters to the command
417417

python/grass/pygrass/raster/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ def numpy2raster(array, mtype, rastname, overwrite=False):
693693
694694
:param obj array: a numpy array
695695
:param obj mtype: the datatype of array
696-
:param str rastername: the name of output map
696+
:param str rastname: the name of output map
697697
:param bool overwrite: True to overwrite existing map
698698
"""
699699
reg = Region()

python/grass/pygrass/vector/basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ def append(self, box):
198198
"""Append a Bbox object to a Boxlist object, using the
199199
``Vect_boxlist_append`` C function.
200200
201-
:param bbox: the bounding box to add to the list
202-
:param bbox: a Bbox object
201+
:param box: the bounding box to add to the list
202+
:type box: a Bbox object
203203
204204
>>> box0 = Bbox()
205205
>>> box1 = Bbox(1, 2, 3, 4)

python/grass/pygrass/vector/find.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(
3030
:param c_mapinfo: Pointer to the vector layer mapinfo structure
3131
:type c_mapinfo: ctypes pointer to mapinfo structure
3232
:param table: Attribute table of the vector layer
33-
:param writable: True or False
33+
:param writeable: True or False
3434
"""
3535
self.c_mapinfo = c_mapinfo
3636
self.table: Table | None = table

python/grass/pygrass/vector/geometry.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,8 @@ def buffer(
594594
:type dist_y: num
595595
:param angle: the angle between 0x and major axis
596596
:type angle: num
597-
:param round_: to make corners round
598-
:type round_: bool
597+
:param round\\_: to make corners round
598+
:type round\\_: bool
599599
:param tol: fix the maximum distance between theoretical arc and output segments
600600
:type tol: float
601601
:returns: the buffer as Area object
@@ -892,6 +892,7 @@ def distance(self, pnt):
892892
893893
:param pnt: the point to calculate distance
894894
:type pnt: a Point object or a tuple with the coordinates
895+
:rtype: LineDist
895896
896897
Return a namedtuple with:
897898
@@ -1173,8 +1174,8 @@ def buffer(
11731174
:type dist_y: num
11741175
:param angle: the angle between 0x and major axis
11751176
:type angle: num
1176-
:param round_: to make corners round
1177-
:type round_: bool
1177+
:param round\\_: to make corners round
1178+
:type round\\_: bool
11781179
:param tol: fix the maximum distance between theoretical arc and output segments
11791180
:type tol: float
11801181
:returns: the buffer as Area object
@@ -1734,8 +1735,8 @@ def buffer(
17341735
:type dist_y: num
17351736
:param angle: the angle between 0x and major axis
17361737
:type angle: num
1737-
:param round_: to make corners round
1738-
:type round_: bool
1738+
:param round\\_: to make corners round
1739+
:type round\\_: bool
17391740
:param tol: fix the maximum distance between theoretical arc and output segments
17401741
:type tol: float
17411742
:returns: the buffer as line, centroid, isles object tuple

python/grass/script/core.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,10 @@ def make_command(
267267
268268
:param str prog: GRASS module
269269
:param str flags: flags to be used (given as a string)
270-
:param bool overwrite: True to enable overwriting the output (<tt>--o</tt>)
271-
:param bool quiet: True to run quietly (<tt>--q</tt>)
272-
:param bool superquiet: True to run extra quietly (<tt>--qq</tt>)
273-
:param bool verbose: True to run verbosely (<tt>--v</tt>)
270+
:param bool overwrite: True to enable overwriting the output (``--o``)
271+
:param bool quiet: True to run quietly (``--q``)
272+
:param bool superquiet: True to run extra quietly (``--qq``)
273+
:param bool verbose: True to run verbosely (``--v``)
274274
:param options: module's parameters
275275
276276
:return: list of arguments
@@ -444,10 +444,10 @@ def start_command(
444444
445445
:param str prog: GRASS module
446446
:param str flags: flags to be used (given as a string)
447-
:param bool overwrite: True to enable overwriting the output (<tt>--o</tt>)
448-
:param bool quiet: True to run quietly (<tt>--q</tt>)
449-
:param bool superquiet: True to run extra quietly (<tt>--qq</tt>)
450-
:param bool verbose: True to run verbosely (<tt>--v</tt>)
447+
:param bool overwrite: True to enable overwriting the output (``--o``)
448+
:param bool quiet: True to run quietly (``--q``)
449+
:param bool superquiet: True to run extra quietly (``--qq``)
450+
:param bool verbose: True to run verbosely (``--v``)
451451
:param kwargs: module's parameters
452452
453453
:return: Popen object
@@ -490,8 +490,8 @@ def run_command(*args, **kwargs):
490490
The behavior on error can be changed using *errors* parameter
491491
which is passed to the :func:`handle_errors()` function.
492492
493-
:param *args: unnamed arguments passed to :func:`start_command()`
494-
:param **kwargs: named arguments passed to :func:`start_command()`
493+
:param args: unnamed arguments passed to :func:`start_command()`
494+
:param kwargs: named arguments passed to :func:`start_command()`
495495
:param str errors: passed to :func:`handle_errors()`
496496
497497
.. versionchanged:: 8.0
@@ -717,10 +717,10 @@ def exec_command(
717717
718718
:param str prog: GRASS module
719719
:param str flags: flags to be used (given as a string)
720-
:param bool overwrite: True to enable overwriting the output (<tt>--o</tt>)
721-
:param bool quiet: True to run quietly (<tt>--q</tt>)
722-
:param bool superquiet: True to run quietly (<tt>--qq</tt>)
723-
:param bool verbose: True to run verbosely (<tt>--v</tt>)
720+
:param bool overwrite: True to enable overwriting the output (``--o``)
721+
:param bool quiet: True to run quietly (``--q``)
722+
:param bool superquiet: True to run quietly (``--qq``)
723+
:param bool verbose: True to run verbosely (``--v``)
724724
:param env: dictionary with system environment variables
725725
(:external:py:data:`os.environ` by default)
726726
:param list kwargs: module's parameters
@@ -748,11 +748,11 @@ def message(msg, flag=None, env=None):
748748

749749

750750
def debug(msg, debug=1, env=None):
751-
"""Display a debugging message using `g.message -d`.
751+
"""Display a debugging message using ``g.message -d``.
752752
753753
The visibility of a debug message at runtime is controlled by
754-
setting the corresponding DEBUG level with `g.gisenv set="DEBUG=X"`
755-
(with `X` set to the debug level specified in the function call).
754+
setting the corresponding DEBUG level with ``g.gisenv set="DEBUG=X"``
755+
(with ``X`` set to the debug level specified in the function call).
756756
757757
:param str msg: debugging message to be displayed
758758
:param str debug: debug level (0-5) with the following recommended
@@ -772,7 +772,7 @@ def debug(msg, debug=1, env=None):
772772

773773

774774
def verbose(msg, env=None):
775-
"""Display a verbose message using `g.message -v`
775+
"""Display a verbose message using ``g.message -v``
776776
777777
:param str msg: verbose message to be displayed
778778
:param env: dictionary with system environment variables
@@ -782,7 +782,7 @@ def verbose(msg, env=None):
782782

783783

784784
def info(msg, env=None):
785-
"""Display an informational message using `g.message -i`
785+
"""Display an informational message using ``g.message -i``
786786
787787
:param str msg: informational message to be displayed
788788
:param env: dictionary with system environment variables
@@ -792,7 +792,7 @@ def info(msg, env=None):
792792

793793

794794
def percent(i, n, s, env=None):
795-
"""Display a progress info message using `g.message -p`
795+
"""Display a progress info message using ``g.message -p``
796796
797797
.. code-block:: python
798798
@@ -812,7 +812,7 @@ def percent(i, n, s, env=None):
812812

813813

814814
def warning(msg, env=None):
815-
"""Display a warning message using `g.message -w`
815+
"""Display a warning message using ``g.message -w``
816816
817817
:param str msg: warning message to be displayed
818818
:param env: dictionary with system environment variables
@@ -822,7 +822,7 @@ def warning(msg, env=None):
822822

823823

824824
def error(msg, env=None):
825-
"""Display an error message using `g.message -e`
825+
"""Display an error message using ``g.message -e``
826826
827827
This function does not end the execution of the program.
828828
The right action after the error is up to the caller.
@@ -836,7 +836,7 @@ def error(msg, env=None):
836836

837837

838838
def fatal(msg, env=None):
839-
"""Display an error message using `g.message -e`, then abort or raise
839+
"""Display an error message using ``g.message -e``, then abort or raise
840840
841841
Raises exception when module global raise_on_error is 'True', abort
842842
(calls :external:py:func:`sys.exit`) otherwise.
@@ -1102,7 +1102,7 @@ def _text_to_key_value_dict(
11021102
checkunits: bool = False,
11031103
) -> KeyValue[list[int | float | str]]:
11041104
"""Convert a key-value text file, where entries are separated by newlines
1105-
and the key and value are separated by `sep', into a key-value dictionary
1105+
and the key and value are separated by ``sep``, into a key-value dictionary
11061106
and discover/use the correct data types (float, int or string) for values.
11071107
11081108
:param filename: The name or name and path of the text file to convert
@@ -1199,7 +1199,7 @@ def compare_key_value_text_files(
11991199
d : hello,8,0.1
12001200
12011201
:param str filename_a: name of the first key-value text file
1202-
:param str filenmae_b: name of the second key-value text file
1202+
:param str filename_b: name of the second key-value text file
12031203
:param str sep: character that separates the keys and values, default is ":"
12041204
:param str val_sep: character that separates the values of a single key,
12051205
default is ","
@@ -1677,7 +1677,7 @@ def parse_color(
16771677
val: str, dflt: tuple[float, float, float] | None = None
16781678
) -> tuple[float, float, float] | None:
16791679
"""Parses the string "val" as a GRASS colour, which can be either one of
1680-
the named colours or an R:G:B tuple e.g. 255:255:255. Returns an
1680+
the named colours or an ``R:G:B`` tuple e.g. ``255:255:255``. Returns an
16811681
(r,g,b) triple whose components are floating point values between 0
16821682
and 1.
16831683
@@ -1728,7 +1728,7 @@ def verbosity():
17281728
17291729
2 all messages will be printed
17301730
1731-
3 also verbose messages will be printed. Triggered by "--v" or "--verbose" flag.
1731+
3 also verbose messages will be printed. Triggered by "``--v``" or "``--verbose``" flag.
17321732
"""
17331733
vbstr = os.getenv("GRASS_VERBOSE")
17341734
if vbstr:
@@ -1744,8 +1744,8 @@ def find_program(pgm, *args):
17441744
17451745
You must call the program in a way that will return a successful
17461746
exit code. For GRASS modules this means you need to pass it some
1747-
valid CLI option, like "--help". For other programs a common
1748-
valid do-little option is usually "--version".
1747+
valid CLI option, like "``--help``". For other programs a common
1748+
valid do-little option is usually "``--version``".
17491749
17501750
:Example:
17511751
.. code-block:: pycon

0 commit comments

Comments
 (0)