Skip to content

Commit

Permalink
Merge pull request #9569 from jakelishman/fix-autosummary-sections
Browse files Browse the repository at this point in the history
Fix #9568: autosummary: summarise overlined sectioned headings correctly
  • Loading branch information
tk0miya committed Aug 29, 2021
2 parents baacc26 + 760820f commit a4a0b97
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
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

0 comments on commit a4a0b97

Please sign in to comment.