mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch '3.x' into 7865_extract_abbr
This commit is contained in:
commit
c4f0d70d17
3
CHANGES
3
CHANGES
@ -20,7 +20,8 @@ Bugs fixed
|
|||||||
|
|
||||||
* #7839: autosummary: cannot handle umlauts in function names
|
* #7839: autosummary: cannot handle umlauts in function names
|
||||||
* #7865: autosummary: Failed to extract summary line when abbreviations found
|
* #7865: autosummary: Failed to extract summary line when abbreviations found
|
||||||
|
* #7866: autosummary: Failed to extract correct summary line when docstring
|
||||||
|
contains a hyperlink target
|
||||||
* #7715: LaTeX: ``numfig_secnum_depth > 1`` leads to wrong figure links
|
* #7715: LaTeX: ``numfig_secnum_depth > 1`` leads to wrong figure links
|
||||||
* #7846: html theme: XML-invalid files were generated
|
* #7846: html theme: XML-invalid files were generated
|
||||||
|
|
||||||
|
@ -499,6 +499,13 @@ def mangle_signature(sig: str, max_chars: int = 30) -> str:
|
|||||||
|
|
||||||
def extract_summary(doc: List[str], document: Any) -> str:
|
def extract_summary(doc: List[str], document: Any) -> str:
|
||||||
"""Extract summary from docstring."""
|
"""Extract summary from docstring."""
|
||||||
|
def parse(doc: List[str], settings: Any) -> nodes.document:
|
||||||
|
state_machine = RSTStateMachine(state_classes, 'Body')
|
||||||
|
node = new_document('', settings)
|
||||||
|
node.reporter = NullReporter()
|
||||||
|
state_machine.run(doc, node)
|
||||||
|
|
||||||
|
return node
|
||||||
|
|
||||||
# Skip a blank lines at the top
|
# Skip a blank lines at the top
|
||||||
while doc and not doc[0].strip():
|
while doc and not doc[0].strip():
|
||||||
@ -516,11 +523,7 @@ def extract_summary(doc: List[str], document: Any) -> str:
|
|||||||
return ''
|
return ''
|
||||||
|
|
||||||
# parse the docstring
|
# parse the docstring
|
||||||
state_machine = RSTStateMachine(state_classes, 'Body')
|
node = parse(doc, document.settings)
|
||||||
node = new_document('', document.settings)
|
|
||||||
node.reporter = NullReporter()
|
|
||||||
state_machine.run(doc, node)
|
|
||||||
|
|
||||||
if not isinstance(node[0], nodes.paragraph):
|
if not isinstance(node[0], nodes.paragraph):
|
||||||
# document starts with non-paragraph: pick up the first line
|
# document starts with non-paragraph: pick up the first line
|
||||||
summary = doc[0].strip()
|
summary = doc[0].strip()
|
||||||
@ -534,7 +537,7 @@ def extract_summary(doc: List[str], document: Any) -> str:
|
|||||||
for i in range(len(sentences)):
|
for i in range(len(sentences)):
|
||||||
summary = ". ".join(sentences[:i + 1]).rstrip(".") + "."
|
summary = ". ".join(sentences[:i + 1]).rstrip(".") + "."
|
||||||
node[:] = []
|
node[:] = []
|
||||||
state_machine.run([summary], node)
|
node = parse(doc, document.settings)
|
||||||
if summary.endswith(WELL_KNOWN_ABBREVIATIONS):
|
if summary.endswith(WELL_KNOWN_ABBREVIATIONS):
|
||||||
pass
|
pass
|
||||||
elif not node.traverse(nodes.system_message):
|
elif not node.traverse(nodes.system_message):
|
||||||
|
@ -108,6 +108,12 @@ def test_extract_summary(capsys):
|
|||||||
'=========']
|
'=========']
|
||||||
assert extract_summary(doc, document) == 'blah blah'
|
assert extract_summary(doc, document) == 'blah blah'
|
||||||
|
|
||||||
|
# hyperlink target
|
||||||
|
doc = ['Do `this <https://www.sphinx-doc.org/>`_ and that. '
|
||||||
|
'blah blah blah.']
|
||||||
|
assert (extract_summary(doc, document) ==
|
||||||
|
'Do `this <https://www.sphinx-doc.org/>`_ and that.')
|
||||||
|
|
||||||
_, err = capsys.readouterr()
|
_, err = capsys.readouterr()
|
||||||
assert err == ''
|
assert err == ''
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user