mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix Google Docstring argument regex in Napoleon. Argument type matching is now more permissive
This commit is contained in:
parent
5b0bb8c1e1
commit
e968a6c1a1
@ -23,9 +23,8 @@ from sphinx.util.pycompat import UnicodeMixin
|
|||||||
|
|
||||||
|
|
||||||
_directive_regex = re.compile(r'\.\. \S+::')
|
_directive_regex = re.compile(r'\.\. \S+::')
|
||||||
_google_untyped_arg_regex = re.compile(r'\s*(\*?\*?\w+)\s*:\s*(.*)')
|
_google_untyped_arg_regex = re.compile(r'\s*(.+?)\s*:\s*(.*)')
|
||||||
_google_typed_arg_regex = re.compile(r'\s*(\*?\*?\w+)\s*\(\s*(.+?)\s*\)\s*:'
|
_google_typed_arg_regex = re.compile(r'\s*(.+?)\s*\(\s*(.+?)\s*\)\s*:\s*(.*)')
|
||||||
r'\s*(.*)')
|
|
||||||
|
|
||||||
|
|
||||||
class GoogleDocstring(UnicodeMixin):
|
class GoogleDocstring(UnicodeMixin):
|
||||||
@ -178,17 +177,17 @@ class GoogleDocstring(UnicodeMixin):
|
|||||||
def _consume_indented_block(self, indent=1):
|
def _consume_indented_block(self, indent=1):
|
||||||
lines = []
|
lines = []
|
||||||
line = self._line_iter.peek()
|
line = self._line_iter.peek()
|
||||||
while(not self._is_section_break()
|
while(not self._is_section_break() and
|
||||||
and (not line or self._is_indented(line, indent))):
|
(not line or self._is_indented(line, indent))):
|
||||||
lines.append(next(self._line_iter))
|
lines.append(next(self._line_iter))
|
||||||
line = self._line_iter.peek()
|
line = self._line_iter.peek()
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
def _consume_contiguous(self):
|
def _consume_contiguous(self):
|
||||||
lines = []
|
lines = []
|
||||||
while (self._line_iter.has_next()
|
while (self._line_iter.has_next() and
|
||||||
and self._line_iter.peek()
|
self._line_iter.peek() and
|
||||||
and not self._is_section_header()):
|
not self._is_section_header()):
|
||||||
lines.append(next(self._line_iter))
|
lines.append(next(self._line_iter))
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
@ -400,11 +399,11 @@ class GoogleDocstring(UnicodeMixin):
|
|||||||
|
|
||||||
def _is_section_break(self):
|
def _is_section_break(self):
|
||||||
line = self._line_iter.peek()
|
line = self._line_iter.peek()
|
||||||
return (not self._line_iter.has_next()
|
return (not self._line_iter.has_next() or
|
||||||
or self._is_section_header()
|
self._is_section_header() or
|
||||||
or (self._is_in_section
|
(self._is_in_section and
|
||||||
and line
|
line and
|
||||||
and not self._is_indented(line, self._section_indent)))
|
not self._is_indented(line, self._section_indent)))
|
||||||
|
|
||||||
def _parse(self):
|
def _parse(self):
|
||||||
self._parsed_lines = self._consume_empty()
|
self._parsed_lines = self._consume_empty()
|
||||||
@ -743,12 +742,12 @@ class NumpyDocstring(GoogleDocstring):
|
|||||||
|
|
||||||
def _is_section_break(self):
|
def _is_section_break(self):
|
||||||
line1, line2 = self._line_iter.peek(2)
|
line1, line2 = self._line_iter.peek(2)
|
||||||
return (not self._line_iter.has_next()
|
return (not self._line_iter.has_next() or
|
||||||
or self._is_section_header()
|
self._is_section_header() or
|
||||||
or ['', ''] == [line1, line2]
|
['', ''] == [line1, line2] or
|
||||||
or (self._is_in_section
|
(self._is_in_section and
|
||||||
and line1
|
line1 and
|
||||||
and not self._is_indented(line1, self._section_indent)))
|
not self._is_indented(line1, self._section_indent)))
|
||||||
|
|
||||||
def _is_section_header(self):
|
def _is_section_header(self):
|
||||||
section, underline = self._line_iter.peek(2)
|
section, underline = self._line_iter.peek(2)
|
||||||
|
Loading…
Reference in New Issue
Block a user