Skip to content
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

Sphinx 7.2: unknown node type: only #13022

Open
JasperCraeghs opened this issue Oct 14, 2024 · 0 comments
Open

Sphinx 7.2: unknown node type: only #13022

JasperCraeghs opened this issue Oct 14, 2024 · 0 comments
Labels

Comments

@JasperCraeghs
Copy link

JasperCraeghs commented Oct 14, 2024

Describe the bug

The use of an only-directive that is nested inside of a parent only-directive to conditionally include a directive of the Sphinx plugin breathe fails since Sphinx 7.2. Sphinx<=7.1.2 supports this use case.

/home/user/git/minimal-doc/<partial node>:: WARNING: unknown node type: <only: <list_item...><list_item...><list_item...>>

Traceback (most recent call last):
...
  File "/home/user/git/minimal-doc/venv/lib/python3.10/site-packages/sphinx/util/docutils.py", line 743, in dispatch_departure
    super().dispatch_departure(node)
  File "/home/user/git/minimal-doc/venv/lib/python3.10/site-packages/docutils/nodes.py", line 2005, in dispatch_departure
    return method(node)
  File "/home/user/git/minimal-doc/venv/lib/python3.10/site-packages/docutils/nodes.py", line 2027, in unknown_departure
    raise NotImplementedError(
NotImplementedError: <class 'sphinx.writers.html5.HTML5Translator'> departing unknown node type: only

Exception occurred:
  File "/home/user/git/minimal-doc/venv/lib/python3.10/site-packages/docutils/nodes.py", line 2027, in unknown_departure
    raise NotImplementedError(
NotImplementedError: <class 'sphinx.writers.html5.HTML5Translator'> departing unknown node type: only

How to Reproduce

My minimal git repository contains build output of doxygen, needed for the breathe directive (doxygenfile) to function, which is required to reproduce the bug.

git clone [email protected]:JasperCraeghs/minimal-doc.git
pip install virtualenv
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
make html

My index.rst:

minimal-doc documentation
=========================

.. only:: html

    hello world

    .. only:: not text

        .. doxygenfile:: component.c

Environment Information

Platform:              linux; (Linux-6.8.0-45-generic-x86_64-with-glibc2.35)
Python version:        3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0])
Python implementation: CPython
Sphinx version:        8.1.3
Docutils version:      0.21.2
Jinja2 version:        3.1.2
Pygments version:      2.18.0

Sphinx extensions

["breathe"]

Additional context

The following made me realize that this is likely a bug in sphinx and not in breathe: #10502

I can use directives of other Sphinx plugins in a nested only-directive. The crash is specific to the directives of the breathe plugin. The version of docutils doesn't seem to matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant