mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #6350: autosummary is confused by an argument having namedtuple as a default value
This commit is contained in:
parent
5d640f3c10
commit
dd1b5beb74
3
CHANGES
3
CHANGES
@ -118,8 +118,7 @@ Bugs fixed
|
||||
referenced
|
||||
* #6165: autodoc: ``tab_width`` setting of docutils has been ignored
|
||||
* #6311: autosummary: autosummary table gets confused by complex type hints
|
||||
* #6350: autosummary: confused by an argument having default string value
|
||||
containing a single quote
|
||||
* #6350: autosummary: confused by an argument having some kind of default value
|
||||
* Generated Makefiles lack a final EOL (refs: #6232)
|
||||
* #6375: extlinks: Cannot escape angle brackets in link caption
|
||||
* #6378: linkcheck: Send commonly used User-Agent
|
||||
|
@ -451,6 +451,14 @@ def mangle_signature(sig, max_chars=30):
|
||||
s = re.sub(r"'[^']*'", "", s) # string literal (w/ single quote)
|
||||
s = re.sub(r'"[^"]*"', "", s) # string literal (w/ double quote)
|
||||
|
||||
# Strip complex objects (maybe default value of arguments)
|
||||
while re.search(r'\([^)]*\)', s): # contents of parenthesis (ex. NamedTuple(attr=...))
|
||||
s = re.sub(r'\([^)]*\)', '', s)
|
||||
while re.search(r'<[^>]*>', s): # contents of angle brackets (ex. <object>)
|
||||
s = re.sub(r'<[^>]*>', '', s)
|
||||
while re.search(r'{[^}]*}', s): # contents of curly brackets (ex. dict)
|
||||
s = re.sub(r'{[^}]*}', '', s)
|
||||
|
||||
# Parse the signature to arguments + options
|
||||
args = [] # type: List[str]
|
||||
opts = [] # type: List[str]
|
||||
|
@ -53,6 +53,7 @@ def test_mangle_signature():
|
||||
(a, b={'c=d, ': 3, '\\\\': 3}) :: (a[, b])
|
||||
(a=1, b=2, c=3) :: ([a, b, c])
|
||||
(a=1, b=<SomeClass: a, b, c>, c=3) :: ([a, b, c])
|
||||
(a=1, b=T(a=1, b=2), c=3) :: ([a, b, c])
|
||||
(a: int, b: int) -> str :: (a, b)
|
||||
"""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user