@@ -247,7 +247,7 @@ class SphinxDocstring(Docstring):
247247
248248 re_multiple_simple_type = r"""
249249 (?:{container_type}|{type})
250- (?:(?:\s+(?:of|or)\s+|\s*,\s*)(?:{container_type}|{type}))*
250+ (?:(?:\s+(?:of|or)\s+|\s*,\s*|\s+\|\s+ )(?:{container_type}|{type}))*
251251 """ .format (
252252 type = re_type , container_type = re_simple_container_type
253253 )
@@ -449,7 +449,7 @@ class GoogleDocstring(Docstring):
449449
450450 re_multiple_type = r"""
451451 (?:{container_type}|{type}|{xref})
452- (?:(?:\s+(?:of|or)\s+|\s*,\s*)(?:{container_type}|{type}|{xref}))*
452+ (?:(?:\s+(?:of|or)\s+|\s*,\s*|\s+\|\s+ )(?:{container_type}|{type}|{xref}))*
453453 """ .format (
454454 type = re_type , xref = re_xref , container_type = re_container_type
455455 )
@@ -728,22 +728,25 @@ class NumpyDocstring(GoogleDocstring):
728728 re .X | re .S | re .M ,
729729 )
730730
731- re_default_value = r"""((['"]\w+\s*['"])|(True)|(False)|(None))"""
731+ re_default_value = r"""((['"]\w+\s*['"])|(\d+)|( True)|(False)|(None))"""
732732
733733 re_param_line = re .compile (
734734 rf"""
735- \s* (\*{{0,2}}\w+)(\s?(:|\n)) # identifier with potential asterisks
735+ \s* (?P<param_name> \*{{0,2}}\w+)(\s?(:|\n)) # identifier with potential asterisks
736736 \s*
737- (
737+ (?P<param_type>
738738 (
739739 ({ GoogleDocstring .re_multiple_type } ) # default type declaration
740740 (,\s+optional)? # optional 'optional' indication
741741 )?
742742 (
743743 {{({ re_default_value } ,?\s*)+}} # set of default values
744744 )?
745- \n)?
746- \s* (.*) # optional description
745+ (?:$|\n)
746+ )?
747+ (
748+ \s* (?P<param_desc>.*) # optional description
749+ )?
747750 """ ,
748751 re .X | re .S ,
749752 )
@@ -794,15 +797,26 @@ def match_param_docs(self) -> tuple[set[str], set[str]]:
794797 continue
795798
796799 # check if parameter has description only
797- re_only_desc = re .match (r"\s* (\*{0,2}\w+)\s*:?\n" , entry )
800+ re_only_desc = re .match (r"\s*(\*{0,2}\w+)\s*:?\n\s*\w*$ " , entry )
798801 if re_only_desc :
799- param_name = match .group (1 )
800- param_desc = match .group (2 )
802+ param_name = match .group ("param_name" )
803+ param_desc = match .group ("param_type" )
801804 param_type = None
802805 else :
803- param_name = match .group (1 )
804- param_type = match .group (3 )
805- param_desc = match .group (4 )
806+ param_name = match .group ("param_name" )
807+ param_type = match .group ("param_type" )
808+ param_desc = match .group ("param_desc" )
809+ # The re_param_line pattern needs to match multi-line which removes the ability
810+ # to match a single line description like 'arg : a number type.'
811+ # We are not trying to determine whether 'a number type' is correct typing
812+ # but we do accept it as typing as it is in the place where typing
813+ # should be
814+ if param_type is None and re .match (r"\s*(\*{0,2}\w+)\s*:.+$" , entry ):
815+ param_type = param_desc
816+ # If the description is "" but we have a type description
817+ # we consider the description to be the type
818+ if not param_desc and param_type :
819+ param_desc = param_type
806820
807821 if param_type :
808822 params_with_type .add (param_name )
0 commit comments