breathe-doc / breathe

ReStructuredText and Sphinx bridge to Doxygen
https://breathe-doc.org
Other
752 stars 200 forks source link

Directive for Doxygen examples (xml compounds with kind="example") #842

Open chbauman opened 2 years ago

chbauman commented 2 years ago

I would like to be able to include single examples annotated with \example in the doxygen comment in the documentation.

When using the doxygenindex directive, example sections are generated for files referenced using the \example doxygen keyword. See also example.

There are two problems with this approach.

The first point can be avoided by using rst's literalinclude keyword, but I could not find a way to avoid the second one.

Ideally, there would be a new directive, e.g. doxygenexample that would achieve this and would be used similarly to the doxygenfile directive.

trivialfis commented 2 years ago

Hi, not sure if this is related. doxygengroup (and friends) doesn't include examples referenced by @example in the rendered document. Using the example in https://github.com/michaeljones/breathe/tree/master/examples/doxygen/example.cfg:

An easy way to reproduce is to add "docexample": "../../examples/doxygen/example/xml", to the breathe_projects in breathe/documentation/source/conf.py, then add the following to any .rst:

.. doxygenfile:: example.cpp
   :project: docexample

The class is correctly shown but no link to the example file.