Skip to content

Commit e31ce00

Browse files
committed
add standalone docstrings_test mode + fix docstrings
1 parent d1ae6d2 commit e31ce00

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

control/robust.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ def mixsyn(g, w1=None, w2=None, w3=None):
400400
401401
info : tuple
402402
Two-tuple `(gamma, rcond)` containing additional information:
403-
403+
404404
* gamma (scalar): H-infinity norm of cl.
405405
* rcond (array): Estimates of reciprocal condition numbers computed
406406
during synthesis. See hinfsyn for details.

control/tests/docstrings_test.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import inspect
1818
import re
19+
1920
import sys
2021
import warnings
2122

@@ -74,6 +75,7 @@
7475
(control, ""), (control.flatsys, "flatsys."),
7576
(control.optimal, "optimal."), (control.phaseplot, "phaseplot."),
7677
(control.matlab, "matlab.")]
78+
7779
@pytest.mark.parametrize("module, prefix", module_list)
7880
def test_parameter_docs(module, prefix):
7981
checked = set() # Keep track of functions we have checked
@@ -93,13 +95,15 @@ def test_parameter_docs(module, prefix):
9395
doc = None if obj is None else npd.FunctionDoc(obj)
9496

9597
# Parse the docstring using numpydoc
96-
doc = None if obj is None else npd.FunctionDoc(obj)
98+
with warnings.catch_warnings():
99+
warnings.simplefilter('ignore') # debug via sphinx, not here
100+
doc = None if obj is None else npd.FunctionDoc(obj)
97101

98102
# Skip anything that is outside of this module
99103
if inspect.getmodule(obj) is not None and \
100104
not inspect.getmodule(obj).__name__.startswith('control'):
101105
# Skip anything that isn't part of the control package
102-
_info(f"member '{objname}' is outside `control` module", 5)
106+
_info(f"member '{name}' is outside `control` module", 5)
103107
continue
104108

105109
# Skip non-top-level functions without parameter lists
@@ -236,12 +240,14 @@ def test_parameter_docs(module, prefix):
236240
f"{obj} return value '{retname}' "
237241
"docstring missing space")
238242

239-
# Look at the return values
240-
for val in doc["Returns"]:
241-
if val.name == '' and \
242-
(match := re.search("([\w]+):", val.type)) is not None:
243-
retname = match.group(1)
244-
_warn(f"{obj.__name__} '{retname}' docstring missing space")
243+
# Look at the return values
244+
for val in doc["Returns"]:
245+
if val.name == '' and \
246+
(match := re.search(r"([\w]+):", val.type)) is not None:
247+
retname = match.group(1)
248+
_warn(
249+
f"{obj} return value '{retname}' "
250+
"docstring missing space")
245251

246252

247253
@pytest.mark.parametrize("module, prefix", [

0 commit comments

Comments
 (0)