Skip to content

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

Open
@PierreEtienneJ

Description

@PierreEtienneJ

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions