Created
December 6, 2019 04:19
-
-
Save tk0miya/9d56031b09e0f7d864b0c3e0f5f9f91f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# extension testbed | |
# Description: ``:index:`` ロールのタイトルを強調表示する | |
from docutils import nodes | |
from sphinx import addnodes | |
from sphinx.transforms import SphinxTransform | |
class IndexStyleTransform(SphinxTransform): | |
default_priority = 200 | |
def apply(self): | |
for node in self.document.traverse(addnodes.index): | |
# Note: index ロールは index, target, text の順でノードを生成する | |
# refs: sphinx/roles:Index | |
siblings = node.traverse(siblings=True, include_self=False) | |
text = siblings[1] | |
node.parent.replace(text, nodes.strong(text, text)) | |
def setup(app): | |
app.add_transform(IndexStyleTransform) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment