Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #9568: autosummary: summarise overlined sectioned headings correctly #9569

Merged
merged 2 commits into from Aug 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -31,6 +31,7 @@ Bugs fixed
* #9522: autodoc: PEP 585 style typehints having arguments (ex. ``list[int]``)
are not displayed well
* #9481: autosummary: some warnings contain non-existing filenames
* #9568: autosummary: summarise overlined sectioned headings correctly
* #9481: c domain: some warnings contain non-existing filenames
* #9481: cpp domain: some warnings contain non-existing filenames
* #9456: html search: abbreation marks are inserted to the search result if
Expand Down
5 changes: 4 additions & 1 deletion sphinx/ext/autosummary/__init__.py
Expand Up @@ -540,7 +540,10 @@ def parse(doc: List[str], settings: Any) -> nodes.document:

# parse the docstring
node = parse(doc, document.settings)
if not isinstance(node[0], nodes.paragraph):
if isinstance(node[0], nodes.section):
# document starts with a section heading, so use that.
summary = node[0].astext().strip()
elif not isinstance(node[0], nodes.paragraph):
# document starts with non-paragraph: pick up the first line
summary = doc[0].strip()
else:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_ext_autosummary.py
Expand Up @@ -109,6 +109,11 @@ def test_extract_summary(capsys):
'=========']
assert extract_summary(doc, document) == 'blah blah'

doc = ['=========',
'blah blah',
'=========']
assert extract_summary(doc, document) == 'blah blah'

# hyperlink target
doc = ['Do `this <https://www.sphinx-doc.org/>`_ and that. '
'blah blah blah.']
Expand Down