breathe-doc / breathe

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

Add option to support cpp:namespace directives #980

Open Rouslan opened 2 months ago

Rouslan commented 2 months ago

This pull request adds a single config option: breathe_use_cpp_namespace. I added the following to the documentation, which describes the new option as well as I can:

breathe_use_cpp_namespace

If set to True, the cpp:namespace, cpp:namespace-push and cpp:namespace-pop directives are observed.

The namespace specified by the aforementioned directives shall be referred to as the "current" namespace in this text.

With the exception of doxygendefine, all doxygen- directives will search for a symbol under the current C++ namespace. Parent namespaces will not be searched. In other words: if the symbol isn't found in the current namespace, it is not found at all.

Similarly to the directives of the cpp domain, the current namespace is not included in the definition of the symbol in the output generated by Sphinx, but is still taken into account for cross-referencing.

Additionally, this changes the default behavior of how doxygenclass, doxygenstruct, doxygennamespace and doxygenunion are presented. By default, the namespace is always omitted for these directives. When breathe_use_cpp_namespace is True, they are treated like the other directives and include the namespace (as given by the doxygen- directive, not the "current" namespace).

By default, this is False.

I had to change the behavior of the class/struct/namespace/union directives, as described above, so that the namespace directives could be used to control how much of the namespace to show. I decided to play it safe and only have the behavior change when breathe_use_cpp_namespace is enabled.

This pull request includes the changes in #967 and #934.