Skip to content

LaTeX build fails: KeyError: 'objtype' in custom desc_signature node #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
PierreEtienneJ opened this issue May 21, 2025 · 0 comments · May be fixed by #25
Open

LaTeX build fails: KeyError: 'objtype' in custom desc_signature node #24

PierreEtienneJ opened this issue May 21, 2025 · 0 comments · May be fixed by #25

Comments

@PierreEtienneJ
Copy link

PierreEtienneJ commented May 21, 2025

Description

When building the documentation using the LaTeX builder, the following error occurs:

....
  File "<...>/python3.12/site-packages/docutils/nodes.py", line 186, in walkabout
    if child.walkabout(visitor):
       ^^^^^^^^^^^^^^^^^^^^^^^^
  [Previous line repeated 7 more times]
  File "<...>/python3.12/site-packages/docutils/nodes.py", line 178, in walkabout
    visitor.dispatch_visit(self)
  File "<...>/python3.12/site-packages/sphinx/util/docutils.py", line 616, in dispatch_visit
    method(node)
  File "<...>/python3.12/site-packages/sphinx/writers/latex.py", line 772, in visit_desc_signature
    if node.parent['objtype'] != 'describe' and node['ids']:
       ~~~~~~~~~~~^^^^^^^^^^^
  File "<...>/python3.12/site-packages/docutils/nodes.py", line 596, in __getitem__
    return self.attributes[key]
           ~~~~~~~~~~~~~~~^^^^^
KeyError: 'objtype'

This comes from a desc_signature node whose parent desc node does not define the 'objtype' attribute. This field is required by the LaTeX writer to determine how to render the object.

How to reproduce

Use the Rust extension in a Sphinx project.

Build with sphinx -b latex ....

Observe the crash during the desc_signature processing.

Cause

The extension creates a desc node but does not assign the required 'objtype' attribute, which is expected by the LaTeX writer.

Suggested fix

Add a proper 'objtype' to the desc node when building custom Rust directives:

@PierreEtienneJ PierreEtienneJ linked a pull request May 21, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant