Skip to content

Commit

Permalink
Fix sphinx-doc#9322: KeyError is raised on PropagateDescDomain transform
Browse files Browse the repository at this point in the history
PropageteDescDomain applies the domain name from the "domain" attribute
of parent node (desc node) to the desc_signature node.  The structure
has longly generated by ObjectDescription.  But it must not be a new
rule.

This allows to build document that contains non standard doctree.
  • Loading branch information
tk0miya committed Jun 13, 2021
1 parent e05cef5 commit 2150923
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -76,6 +76,7 @@ Bugs fixed
whitespace (ex. ``Dict[str, str]``)
* #8945: when transforming typed fields, call the specified role instead of
making an single xref. For C and C++, use the ``expr`` role for typed fields.
* #9322: KeyError is raised on PropagateDescDomain transform

Testing
--------
Expand Down
3 changes: 2 additions & 1 deletion sphinx/transforms/post_transforms/__init__.py
Expand Up @@ -263,7 +263,8 @@ class PropagateDescDomain(SphinxPostTransform):

def run(self, **kwargs: Any) -> None:
for node in self.document.traverse(addnodes.desc_signature):
node['classes'].append(node.parent['domain'])
if node.parent.get('domain'):
node['classes'].append(node.parent['domain'])


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

0 comments on commit 2150923

Please sign in to comment.