mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Merge pull request #6395 from tk0miya/6350_autosummary_is_confused_by_default_value
Fix #6350: autosummary is confused by an argument having some kind of default value
This commit is contained in:
@@ -120,6 +120,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 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
|
||||
|
||||
@@ -444,10 +444,20 @@ def mangle_signature(sig, max_chars=30):
|
||||
# Remove parenthesis
|
||||
s = re.sub(r"^\((.*)\)$", r"\1", s).strip()
|
||||
|
||||
# Strip strings (which can contain things that confuse the code below)
|
||||
s = re.sub(r"\\\\", "", s)
|
||||
s = re.sub(r"\\'", "", s)
|
||||
s = re.sub(r"'[^']*'", "", s)
|
||||
# Strip literals (which can contain things that confuse the code below)
|
||||
s = re.sub(r"\\\\", "", s) # escaped backslash (maybe inside string)
|
||||
s = re.sub(r"\\'", "", s) # escaped single quote
|
||||
s = re.sub(r'\\"', "", s) # escaped double quote
|
||||
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]
|
||||
|
||||
@@ -47,11 +47,13 @@ def test_mangle_signature():
|
||||
(a, b[, c]) :: (a, b[, c])
|
||||
(a, b[, cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx]) :: (a, b[, ...)
|
||||
(a, b='c=d, e=f, g=h', c=3) :: (a[, b, c])
|
||||
(a, b="c=d, e=f, g=h", c=3) :: (a[, b, c])
|
||||
(a, b='c=d, \\'e=f,\\' g=h', c=3) :: (a[, b, c])
|
||||
(a, b='c=d, ', e='\\\\' g=h, c=3) :: (a[, b, e, c])
|
||||
(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)
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user