sphinx-doc / sphinx-doc/sphinx

(C++) Qualified names in signatures fail to generate cross-references

Open
#12,845 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

If a C++ function parameter or return type contains a qualified name, then xref resolution fails by attempting to generate a link for the namespace name.

Given

.. cpp:namespace:: foo
.. cpp:class:: something 

.. cpp:function:: void bar(foo::something arg)

Expected: The foo::something parameter type generates a hyperlink to the something class defined within the foo namespace.

Actual: /.../repro/index.rst:8: WARNING: cpp:identifier reference target not found: foo [ref.identifier]

Using a qualified name in an inline reference (e.g. cpp:class or cpp:any) will resolve the object just fine. It appears that the generated signature nodes contain a reference to some foo (the namespace), which has no link target.

This usually will silently fail unless nitpicky mode is enabled.

How to Reproduce

An empty conf.py is sufficient. The following index.rst will fail to render when nitpicky-mode is enabled:

.. default-domain:: cpp
.. namespace:: foo
.. class:: something

.. function:: void bar(foo::something)
Environment Information
Platform:              linux; (Linux-6.10.3-arch1-2-x86_64-with-glibc2.40)
Python version:        3.12.4 (main, Jun  7 2024, 06:33:07) [GCC 14.1.1 20240522])
Python implementation: CPython
Sphinx version:        8.0.2
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 minimal index.rst reproduction and empty conf.py, then trace the C++ domain's generated signature nodes and cross-reference resolution. Run the example with nitpicky mode enabled and verify that foo::something links to the class without warning about foo.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.