1616
1717import inspect
1818import re
19+
1920import sys
2021import warnings
2122
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 )
7880def 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