Skip to content

Commit

Permalink
LaTeX: Restructure the index nodes inside title nodes only on LaTeX b…
Browse files Browse the repository at this point in the history
…uilds

refs: sphinx-doc#8865
  • Loading branch information
tk0miya committed Feb 10, 2021
1 parent 674831c commit 9411051
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -142,6 +142,8 @@ Bugs fixed
the :ref:`'sphinxsetup' <latexsphinxsetup>` key of ``latex_elements``)
* #8183: LaTeX: Remove substitution_reference nodes from doctree only on LaTeX
builds
* #8865: LaTeX: Restructure the index nodes inside title nodes only on LaTeX
builds

Testing
--------
Expand Down
5 changes: 3 additions & 2 deletions sphinx/builders/latex/transforms.py
Expand Up @@ -574,7 +574,7 @@ def run(self, **kwargs: Any) -> None:
section['ids'].append(':doc') # special label for :doc:


class IndexInSectionTitleTransform(SphinxTransform):
class IndexInSectionTitleTransform(SphinxPostTransform):
"""Move index nodes in section title to outside of the title.
LaTeX index macro is not compatible with some handling of section titles
Expand All @@ -601,8 +601,9 @@ class IndexInSectionTitleTransform(SphinxTransform):
...
"""
default_priority = 400
builders = ('latex',)

def apply(self, **kwargs: Any) -> None:
def run(self, **kwargs: Any) -> None:
for node in self.document.traverse(nodes.title):
if isinstance(node.parent, nodes.section):
for i, index in enumerate(node.traverse(addnodes.index)):
Expand Down

0 comments on commit 9411051

Please sign in to comment.