sphinx-doc / sphinx-doc/sphinx

C++ Domain: Error when parsing enum in template class scope

Open
#13,129 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

domains:cpp type:bug
Dominant language
Python
Stars
8k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

I am trying to document an enum, that is part of a partially specialized template class.
However, I am getting this issue:

index.rst:6: WARNING: Invalid C++ declaration: Expected identifier in nested name, got keyword: template [error at 8]
  template<> Some<int>::Enum
  --------^

This only occurs for enums.
It works when I declare a class the same way.

How to Reproduce
.. This works:

.. cpp:class:: template<> Some<int>::Class


.. This doesn't:

.. cpp:enum:: template<> Some<int>::Enum
Environment Information
Platform:              linux; (Linux-5.15.167.4-microsoft-standard-WSL2-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.4
Pygments version:      2.18.0
Sphinx extensions

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the C++ domain's handling of the cpp:enum declaration and compare it with the working cpp:class case. Reproduce the warning using the provided reStructuredText example, then verify that documenting an enum in a partially specialized template class scope parses without the warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.