Skip to content

Commit

Permalink
C++, add support for anon entities.
Browse files Browse the repository at this point in the history
Anonymous entities are specified with names starting with "@",
but are rendered as "[anonymous]".

Fixes sphinx-doc#3593 and sphinx-doc#2683.
  • Loading branch information
jakobandersen committed Jun 9, 2018
1 parent fc7817b commit cc02694
Show file tree
Hide file tree
Showing 4 changed files with 355 additions and 266 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ Features added
option of highlight directive
* C++, add a ``cpp:texpr`` role as a sibling to ``cpp:expr``.
* C++, add support for unions.
* C++, add support for anonymous entities using names staring with ``@``.
Fixes #3593 and #2683.
* #3606: MathJax should be loaded with async attribute
* html: Output ``canonical_url`` metadata if :confval:`html_baseurl` set (refs:
#4193)
Expand Down
35 changes: 35 additions & 0 deletions doc/usage/restructuredtext/domains.rst
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,41 @@ Some directives support options:
- ``:tparam-line-spec:``, for templated declarations.
If specified, each template parameter will be rendered on a separate line.

Anonymous Entities
~~~~~~~~~~~~~~~~~~

C++ supposrts anonymous namespaces, classes, enums, and unions.
For the sake of documentation they must be given some name that starts with ``@``,
e.g., ``@42`` or ``@data``.
These names can also be used in cross-references and (type) expressions,
though nested symbols will be found even when omitted.
The ``@...`` name will always be rendered as **[anonymous]** (possibly as a link).

Example::

.. cpp:class:: Data

.. cpp:union:: @data

.. cpp:var:: int a

.. cpp:var:: double b

Explicit ref: :cpp:var:`Data::@data::a`. Short-hand ref: :cpp:var:`Data::a`.

This will be rendered as:

.. cpp:class:: Data

.. cpp:union:: @data

.. cpp:var:: int a

.. cpp:var:: double b

Explicit ref: :cpp:var:`Data::@data::a`. Short-hand ref: :cpp:var:`Data::a`.


Constrained Templates
~~~~~~~~~~~~~~~~~~~~~

Expand Down
Loading

0 comments on commit cc02694

Please sign in to comment.