Skip to content

Commit cf96c93

Browse files
authored
Merge pull request sphinx-doc#9724 from tk0miya/support_PreBibliographic_nodes
Support docutils-0.18: allow PreBibliographic nodes before docinfo
2 parents cc85aef + 8118f97 commit cf96c93

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

sphinx/environment/collectors/metadata.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ def process_doc(self, app: Sphinx, doctree: nodes.document) -> None:
3333
3434
Keep processing minimal -- just return what docutils says.
3535
"""
36-
if len(doctree) > 0 and isinstance(doctree[0], nodes.docinfo):
36+
index = doctree.first_child_not_matching_class(nodes.PreBibliographic)
37+
if index is None:
38+
return
39+
elif isinstance(doctree[index], nodes.docinfo):
3740
md = app.env.metadata[app.env.docname]
38-
for node in doctree[0]:
41+
for node in doctree[index]: # type: ignore
3942
# nodes are multiply inherited...
4043
if isinstance(node, nodes.authors):
4144
authors = cast(List[nodes.author], node)
@@ -58,7 +61,7 @@ def process_doc(self, app: Sphinx, doctree: nodes.document) -> None:
5861
value = 0
5962
md[name] = value
6063

61-
doctree.pop(0)
64+
doctree.pop(index)
6265

6366

6467
def setup(app: Sphinx) -> Dict[str, Any]:

0 commit comments

Comments
 (0)