### Multifile Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting a multifile project.
```APIDOC
## Multifile
### Description
Documentation for a template function in a multifile project.
### Namespace
@ex_specific_multifile
### Function
TestTemplateFunction (project: multifile)
```
--------------------------------
### Typedef Examples
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Examples showcasing the documentation of typedefs.
```APIDOC
## Typedef Examples
### Description
Documentation for typedefs.
### Namespace
@ex_specific_typedef
### Index
(from ../../examples/specific/typedef/xml)
```
--------------------------------
### Working doxygenconcept Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/concept.rst
Use this directive to document an existing C++20 concept. Ensure Doxygen v1.9.2 or newer is installed.
```rst
.. doxygenconcept:: Hashable
:project: cpp_concept
```
--------------------------------
### Image Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting an image.
```APIDOC
## Image
### Description
Documentation for an image class.
### Namespace
@ex_specific_image
### Class
ImageClass (project: image)
```
--------------------------------
### C Macro Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting a C macro.
```APIDOC
## C Macro
### Description
Documentation for a C macro.
### File
c_macro.h (project: c_macro)
```
--------------------------------
### Extern Examples
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Examples for documenting external C functions and structs.
```APIDOC
## Extern Examples
### Description
Documentation for external C functions and structs.
### Namespace
@ex_specific_extern_examples
### Functions
- cache_tree_free (project: c_file)
### Structs
- cache_tree (project: c_file, outline: true)
```
--------------------------------
### C++ Union Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting a C++ union.
```APIDOC
## C++ Union
### Description
Documentation for a C++ union.
### Namespace
@ex_specific_cpp_union
### File
cpp_union.h (project: cpp_union)
```
--------------------------------
### C++ Macro Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting a C++ macro.
```APIDOC
## C++ Macro
### Description
Documentation for a C++ macro.
### File
define.h (project: define)
```
--------------------------------
### Array Parameter Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example demonstrating functions with array parameters.
```APIDOC
## Array Parameter
### Description
Documentation for functions accepting array parameters.
### Functions
- foo (project: array)
- bar (project: array)
```
--------------------------------
### Program Listing Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting a program listing.
```APIDOC
## Program Listing
### Description
Documentation for a class and function within a program listing context.
### Namespace
@ex_specific_program_listing
### Class
Vector (project: programlisting)
### Function
center (project: programlisting)
```
--------------------------------
### C Union Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting a C union.
```APIDOC
## C Union
### Description
Documentation for a C union.
### File
c_union.h (project: c_union)
```
--------------------------------
### All Members Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/members.rst
This example shows how to document all members of a namespaced class.
```APIDOC
## All Members
### Description
Documents all members of the `NamespacedClassTest` class within the `testnamespace` namespace.
### Doxygen Directives
```cpp
.. cpp:namespace:: @ex_members_all
.. doxygenclass:: testnamespace::NamespacedClassTest
:path: ../../examples/specific/members/xml
:members:
```
```
--------------------------------
### Interface Class Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting an interface class.
```APIDOC
## Interface Class
### Description
Documentation for an interface class.
### Namespace
@ex_specific_interface
### Interface
InterfaceClass (project: interface)
```
--------------------------------
### C++ Functions Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting C++ functions.
```APIDOC
## C++ Functions
### Description
Documentation for C++ functions.
### Namespace
@ex_specific_cpp_function
### File
cpp_function.h (project: cpp_function)
```
--------------------------------
### C Typedef Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting a C typedef.
```APIDOC
## C Typedef
### Description
Documentation for a C typedef.
### File
c_typedef.h (project: c_typedef)
```
--------------------------------
### C Struct Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting a C struct.
```APIDOC
## C Struct
### Description
Documentation for a C struct.
### File
c_struct.h (project: c_struct)
```
--------------------------------
### C++ Enums Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting C++ enums.
```APIDOC
## C++ Enums
### Description
Documentation for C++ enums.
### Namespace
@ex_specific_cpp_enum
### File
cpp_enum.h (project: cpp_enum)
```
--------------------------------
### Struct Members Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/members.rst
This example demonstrates documenting members of a struct, including its constructor and a member variable.
```APIDOC
## Struct Members
### Description
Documents the default constructor, copy constructor, and a member variable (`myMemberVar`) of the `MyClass` struct.
### Doxygen Directives
```cpp
.. cpp:namespace:: @ex_members_struct
.. doxygenfunction:: testnamespace::MyClass::MyClass()
:path: ../../examples/specific/struct_function/xml
.. doxygenfunction:: testnamespace::MyClass::MyClass(const MyClass&)
:path: ../../examples/specific/struct_function/xml
.. doxygenvariable:: testnamespace::MyClass::myMemberVar
:path: ../../examples/specific/struct_function/xml
```
```
--------------------------------
### Install Breathe with pip
Source: https://github.com/breathe-doc/breathe/blob/main/README.rst
Install Breathe using pip, the Python Package Index. This is the standard method for installing Python packages.
```bash
pip install breathe
```
--------------------------------
### Function Overloads Examples
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Examples illustrating the documentation of function overloads.
```APIDOC
## Function Overloads
### Description
Documentation for various function overloads.
### Namespace
@ex_specific_function_overloads
### Functions
- f(int, int) (project: functionOverload)
- f(double, double) (project: functionOverload)
- test::g(int,int) (project: functionOverload)
- test::g(double, double) (project: functionOverload)
- h(std::string, MyType) (project: functionOverload)
- h(std::string, MyOtherType) (project: functionOverload)
- h(std::string, const int) (project: functionOverload)
- h(std::string, const T, const U) (project: functionOverload)
```
--------------------------------
### C++ Template Specialization with Namespace Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting C++ template specialization with namespaces.
```APIDOC
## C++ Template Specialization with Namespace
### Description
Documentation for C++ template specialization within a namespace.
### Namespace
@ex_specific_cpp_ns_template_specialization
### File
cpp_ns_template_specialization.h (project: cpp_ns_template_specialization)
```
--------------------------------
### Namespace Outline Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/namespace.rst
This example demonstrates how to display only the names of namespace members without their documentation using the 'outline' option.
```rst
.. doxygennamespace:: foo
:project: namespace
:members:
:outline:
```
--------------------------------
### C Enum Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting a C enum.
```APIDOC
## C Enum
### Description
Documentation for a C enum.
### Enum
GSM_BackupFormat (project: c_enum)
```
--------------------------------
### Template Type Alias Examples
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Examples demonstrating the documentation of template type aliases.
```APIDOC
## Template Type Alias
### Description
Documentation for template type aliases.
### Namespace
@ex_specific_alias_template
### Aliases
- IsFurry (from ../../examples/specific/template_type_alias/xml)
- IsFuzzy (from ../../examples/specific/template_type_alias/xml)
```
--------------------------------
### Breathe Python Extension Setup
Source: https://context7.com/breathe-doc/breathe/llms.txt
The `breathe.setup` function in `breathe/__init__.py` is the entry point for the Sphinx extension. It registers directives, the file-state cache, and the renderer, and is called automatically when 'breathe' is in the `extensions` list.
```python
# breathe/__init__.py (simplified)
from sphinx.application import Sphinx
def setup(app: Sphinx):
from breathe.directives.setup import setup as directive_setup
from breathe.file_state_cache import setup as file_state_cache_setup
from breathe.renderer.sphinxrenderer import setup as renderer_setup
directive_setup(app)
file_state_cache_setup(app)
renderer_setup(app)
return {
"version": __version__,
"parallel_read_safe": True,
"parallel_write_safe": True,
}
```
--------------------------------
### Namespaced Function Examples
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Examples of documenting functions within namespaces.
```APIDOC
## Namespaced Function Examples
### Description
Documentation for functions within various namespaces and classes.
### Namespace
@ex_specific_namespaced_function
### Functions
- TestNamespaceClasses::NamespacedClassTest::function (from ../../examples/specific/class/xml)
- TestNamespaceClasses::ClassTest::function (from ../../examples/specific/class/xml)
- TestNamespaceClasses::ClassTest::anotherFunction (from ../../examples/specific/class/xml)
- ClassTest::function (from ../../examples/specific/class/xml)
- ClassTest::anotherFunction (from ../../examples/specific/class/xml)
- f0 (from ../../examples/specific/class/xml)
- f0< std::string > (from ../../examples/specific/class/xml)
- NS1::f1 (from ../../examples/specific/class/xml)
- NS1::f1< std::string > (from ../../examples/specific/class/xml)
- NS1::NS2::f2 (from ../../examples/specific/class/xml)
- NS1::NS2::f2< std::string > (from ../../examples/specific/class/xml)
```
--------------------------------
### C++ Friend Classes Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting C++ friend classes.
```APIDOC
## C++ Friend Classes
### Description
Documentation for C++ friend classes.
### Namespace
@ex_specific_cpp_friendclass
### File
cpp_friendclass.h (project: cpp_friendclass)
```
--------------------------------
### C++ Inherited Members Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting C++ inherited members.
```APIDOC
## C++ Inherited Members
### Description
Documentation for C++ inherited members.
### Namespace
@ex_specific_cpp_inherited_members
### Classes
- Base (project: cpp_inherited_members)
- A (project: cpp_inherited_members)
- B (project: cpp_inherited_members)
```
--------------------------------
### No Members Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/members.rst
This example shows how to document a class without explicitly listing any members.
```APIDOC
## No Members
### Description
Documents the `NamespacedClassTest` class without listing any specific members, implying default member visibility or exclusion.
### Doxygen Directives
```cpp
.. cpp:namespace:: @ex_members_no
.. doxygenclass:: testnamespace::NamespacedClassTest
:path: ../../examples/specific/members/xml
:no-link:
```
```
--------------------------------
### Specific Members Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/members.rst
This example demonstrates documenting only specific functions of a namespaced class.
```APIDIDOC
## Specific Members
### Description
Documents only `functionS` and `anotherFunction` of the `NamespacedClassTest` class, with no links.
### Doxygen Directives
```cpp
.. cpp:namespace:: @ex_members_specific
.. doxygenclass:: testnamespace::NamespacedClassTest
:path: ../../examples/specific/members/xml
:members: functionS, anotherFunction
:no-link:
```
```
--------------------------------
### Sphinx Configuration for Breathe Example
Source: https://github.com/breathe-doc/breathe/blob/main/tests/data/examples/README.rst
This configuration is used when running Sphinx for Breathe examples. It sets up the project name, default project, and required extensions. Ensure 'breathe' and 'sphinx.ext.graphviz' are in your extensions list.
```python
project = "test"
breathe_default_project = "example"
breathe_show_include = False
extensions = ["breathe", "sphinx.ext.graphviz"]
breathe_projects = {"example": SOME_TEMPORARY_FOLDER}
```
--------------------------------
### Run Unit Tests with make dev-test
Source: https://github.com/breathe-doc/breathe/blob/main/README.rst
Execute the test suite using the provided make command. This is useful for verifying the installation and functionality.
```bash
make dev-test
```
--------------------------------
### C++ Anonymous Entities Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting C++ anonymous entities.
```APIDOC
## C++ Anonymous Entities
### Description
Documentation for C++ anonymous entities.
### Namespace
@ex_specific_cpp_anon
### File
cpp_anon.h (project: cpp_anon)
```
--------------------------------
### Doxygen Index XML Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/codeguide.rst
An example of the index.xml file generated by Doxygen, which serves as a central reference and lists other generated files.
```xml
Test
member
func.h
```
--------------------------------
### Fixed Width Font Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example demonstrating the use of fixed-width font for documentation.
```APIDOC
## Fixed Width Font
### Description
Documentation for a class using fixed-width font.
### Namespace
@ex_specific_fixed_width
### Class
Out (from ../../examples/specific/fixedwidthfont/xml, members: true)
```
--------------------------------
### Failing Namespace Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/namespace.rst
This example intentionally uses a non-existent namespace 'madeupnamespace' to demonstrate the expected warning message.
```rst
.. doxygennamespace:: madeupnamespace
:project: namespace
```
--------------------------------
### C++ Code Example for Breathe
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/index.rst
This is an example of C++ code that can be documented using Breathe. Ensure Doxygen is configured to generate XML output.
```cpp
#include
class Nutshell {
public:
void say_hello() {
std::cout << "Hello World!\n";
}
};
```
--------------------------------
### C++ Trailing Return Type Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Example for documenting C++ trailing return types.
```APIDOC
## C++ Trailing Return Type
### Description
Documentation for C++ functions using trailing return types.
```
--------------------------------
### Failing doxygenunion Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/union.rst
This example demonstrates a failing case where the specified union does not exist. It will result in a warning message.
```rst
.. doxygenunion:: made_up_union
:project: union
```
--------------------------------
### Nested List Example 1 (C++)
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/lists.rst
This C++ code demonstrates the documentation structure for a nested list.
```cpp
/// @brief A simple class with a nested list.
///
/// This class demonstrates nested lists in Doxygen markup.
///
/// Unordered list:
/// + Item 1
/// + Subitem 1.1
/// + Subitem 1.2
/// + Item 2
///
/// Ordered list:
/// 1. Step 1
/// 1. Substep 1.1
/// 2. Substep 1.2
/// 2. Step 2
class NestedLists_1 {
public:
int data;
};
```
--------------------------------
### Failing doxygenconcept Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/concept.rst
This example shows how the directive behaves when a concept is not found. A warning will be generated.
```rst
.. doxygenconcept:: MadeUpConcept
:project: cpp_concept
```
--------------------------------
### Nested List Example 2 (C++)
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/lists.rst
This C++ code shows documentation for another nested list structure.
```cpp
/// @brief Another example of nested lists.
///
/// Demonstrates mixing different list types.
///
/// List 1:
/// - Element A
/// * Sub-element A.1
/// * Sub-element A.2
/// - Element B
///
/// List 2:
/// # First item
/// # First sub-item
/// # Second sub-item
/// # Second item
class NestedLists_2 {
public:
double value;
};
```
--------------------------------
### Nested List Example 3 (C++)
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/lists.rst
This C++ code illustrates a nested list with mixed item prefixes.
```cpp
/// @brief Nested lists with mixed prefixes.
///
/// Shows how different list markers can be used within nested structures.
///
/// * Main item 1
/// + Sub item 1.1
/// - Sub item 1.2
/// * Main item 2
/// 1. Sub item 2.1
/// 2. Sub item 2.2
class NestedLists_3 {
public:
char flag;
};
```
--------------------------------
### Nested List Example 4 (C++)
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/lists.rst
This C++ code provides an example of deeply nested lists.
```cpp
/// @brief Deeply nested lists.
///
/// Demonstrates multiple levels of nesting.
///
/// Level 1:
/// + Item A
/// + Level 2 Item A.1
/// - Level 3 Item A.1.1
/// - Level 3 Item A.1.2
/// + Level 2 Item A.2
/// + Item B
class NestedLists_4 {
public:
bool status;
};
```
--------------------------------
### Failing doxygenfile Directive Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/file.rst
This example demonstrates an intentional failure case where the specified file does not exist in the Doxygen XML output. It is expected to produce a warning.
```rst
.. doxygenfile:: made_up_file.h
:project: nutshell
```
--------------------------------
### C++ Function Lookup Examples
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/specific.rst
Demonstrates various C++ function declarations and their Doxygen representation, including noexcept, final, override, attributes, initializers, trailing return types, and parameter packs.
```APIDOC
## C++ Function Declarations
This section details various C++ function declarations and their Doxygen representation.
### `fNoexcept()`
- **Description**: A function declared with noexcept.
- **Signature**: `void fNoexcept()`
### `fFinal()`
- **Description**: A function declared as final.
- **Signature**: `void fFinal()`
### `fOverride()`
- **Description**: A function declared with override.
- **Signature**: `void fOverride()`
### `fAttr()`
- **Description**: A function with attributes (note: Doxygen may not capture attributes in XML).
- **Signature**: `void fAttr()`
### `fFInit()`
- **Description**: A function with a trailing return type.
- **Signature**: `auto fFInit() -> void`
### `fTrailing()`
- **Description**: A function with a trailing return type.
- **Signature**: `auto fTrailing() -> void`
### `fInit(int)`
- **Description**: A function taking an integer parameter.
- **Signature**: `void fInit(int)`
### `fPlain(int)`
- **Description**: A plain function taking an integer parameter.
- **Signature**: `void fPlain(int)`
### `fPtr(int*)`
- **Description**: A function taking a pointer to an integer.
- **Signature**: `void fPtr(int*)`
### `fLRef(int&)`
- **Description**: A function taking a reference to an integer.
- **Signature**: `void fLRef(int&)`
### `fRRef(int&&)`
- **Description**: A function taking a rvalue reference to an integer.
- **Signature**: `void fRRef(int&&)`
### `fParamPack(T...)`
- **Description**: A function template taking a parameter pack.
- **Signature**: `template void fParamPack(T...)`
### `fMemPtr(int A::*)`
- **Description**: A function taking a pointer to a member of class A.
- **Signature**: `void fMemPtr(int A::*)`
### `fParen(void (*)())`
- **Description**: A function taking a pointer to a function with no arguments.
- **Signature**: `void fParen(void (*)())`
### `fParenPlain(void (*)(int))`
- **Description**: A function taking a pointer to a function with an integer argument.
- **Signature**: `void fParenPlain(void (*)(int))`
```
--------------------------------
### Failing Group Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/group.rst
This example demonstrates an intentional failure when the specified group does not exist in the Doxygen XML output, resulting in a warning.
```rst
.. doxygengroup:: madeupgroup
:project: group
```
--------------------------------
### Build Documentation with make
Source: https://github.com/breathe-doc/breathe/blob/main/README.rst
Build the project's documentation locally. This process involves running Doxygen and then Sphinx.
```bash
make
```
--------------------------------
### Failing doxygentypedef Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/typedef.rst
This example demonstrates an intentional failure when the specified typedef does not exist in the Doxygen XML output. A warning will be generated.
```rst
.. doxygentypedef:: made_up_typedef
:project: restypedef
```
--------------------------------
### Example C++ Struct for Doxygen
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/codeguide.rst
This C++ code defines a simple struct with a comment, intended to be processed by Doxygen. It serves as an example for generating XML documentation.
```cpp
/**
A fluffy feline
*/
struct cat {
/**
Make this cat look super cute
*/
void make_cute();
};
```
--------------------------------
### Breathe Project Configuration
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/autoindex.rst
Configure the breathe_projects_source dictionary in your conf.py to map project names to their source directories and header files. This setup is required for the autodoxygenindex directive to locate and process your C++ documentation.
```python
breathe_projects_source = {
"auto" : ( "../examples/specific", ["auto_function.h", "auto_class.h"] )
}
```
--------------------------------
### Nested List Example 5 (C++)
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/lists.rst
This C++ code shows a nested list using HTML tags within Doxygen.
```cpp
/// @brief Nested lists using HTML.
///
/// Demonstrates using HTML and - tags for nested lists.
///
///
/// - Outer Item 1
///
/// - Inner Item 1.1
/// - Inner Item 1.2
///
///
/// - Outer Item 2
///
class NestedLists_5 {
public:
float ratio;
};
```
--------------------------------
### doxygenfile Directive with Selected and Ordered Sections
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/file.rst
Limit the sections to render for a source file and control their order. This example shows only the brief description and public type sections.
```rst
.. doxygenfile:: nutshell.h
:project: nutshell
:sections: briefdescription innerclass public-type
:no-link:
```
--------------------------------
### Display Struct Members with No Link
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/struct.rst
This example shows how to display struct members in an outline format and disable linking to the struct definition using the ``:no-link:`` option.
```rst
.. doxygenstruct:: StructTest
:project: struct
:members:
:outline:
:no-link:
```
--------------------------------
### Failing doxygenpage Directive Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/page.rst
This example demonstrates an intentionally failing directive, likely due to an incorrect or non-existent page name. It is expected to produce a warning message.
```rst
.. doxygengroup:: madeuppage
:project: xrefsect
```
--------------------------------
### C++ Grouping Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/groups.rst
This C++ code defines a class with groups, demonstrating how Breathe can parse and represent them. Ensure your Doxygen configuration supports grouping.
```cpp
#include
namespace {
/**
* @defgroup UserDefinedGroupTest User Defined Group Test
* This is a test group.
*/
/**
* @ingroup UserDefinedGroupTest
*/
class UserDefinedGroupTest {
public:
/**
* @brief This is a test method.
*/
void testMethod();
};
}
```
--------------------------------
### Failing Doxygen Class Directive
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/class.rst
This example demonstrates an intentionally failing ``.. doxygenclass::`` directive for a non-existent class, which results in a Doxygen warning.
```rst
.. doxygenclass:: made_up_class
:project: class
:members:
```
--------------------------------
### Handle Non-existent Struct
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/struct.rst
This intentionally failing example demonstrates the warning message produced when ``doxygenstruct`` cannot find the specified struct in the Doxygen XML output. Ensure the struct name and project are correct.
```rst
.. doxygenstruct:: made_up_struct
:project: struct
:members:
```
--------------------------------
### Doxygen Comment with LaTeX Math
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/latexmath.rst
Example of a C++ class comment demonstrating inline \f$ ... \f$ and display-style \f[ ... \f] LaTeX formulas.
```cpp
/**
* @brief A class
*
* A inline formula: \f$ f(x) = a + b \f$
*
* A display style formula:
* @f[
* \int_a^b f(x) dx = F(b) - F(a)
* @f]
*/
class MathHelper
{
public:
MathHelper() {}
~MathHelper() {}
}
```
--------------------------------
### Advanced Doxygen XML Generation with Sphinx Hooks
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/readthedocs.rst
This setup uses Sphinx's builder-inited event hook to run doxygen. It includes helper functions to manage the doxygen command execution and is suitable for more complex project structures.
```python
import subprocess, sys
def run_doxygen(folder):
"""Run the doxygen make command in the designated folder"""
try:
retcode = subprocess.call("cd %s; make" % folder, shell=True)
if retcode < 0:
sys.stderr.write("doxygen terminated by signal %s" % (-retcode))
except OSError as e:
sys.stderr.write("doxygen execution failed: %s" % e)
def generate_doxygen_xml(app):
"""Run the doxygen make commands if we're on the ReadTheDocs server"""
read_the_docs_build = os.environ.get('READTHEDOCS', None) == 'True'
if read_the_docs_build:
run_doxygen("../../examples/doxygen")
run_doxygen("../../examples/specific")
run_doxygen("../../examples/tinyxml")
def setup(app):
# Add hook for building doxygen xml when needed
app.connect("builder-inited", generate_doxygen_xml)
```
--------------------------------
### Display Class Documentation With All Public Members
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/class.rst
To display the class documentation along with all its public members, use the `:members:` option without arguments.
```rst
.. doxygenclass:: Nutshell
:project: nutshell
:members:
```
--------------------------------
### Configure Projects Source Directories
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/directives.rst
A dictionary mapping project names to a tuple of a directory and a list of source files to be automatically processed by Doxygen.
```python
breathe_projects_source = {
"myprojectsource" : (
"/some/long/path/to/myproject", ["file.c", "subfolder/otherfile.c"]
)
}
```
--------------------------------
### Compare Documentation Output
Source: https://github.com/breathe-doc/breathe/blob/main/README.rst
Compare the current documentation output against a previous state to check for regressions. This script requires all changes to be committed first and takes two commit references as arguments.
```bash
# Make sure all your changes are committed first
cd documentation
./compare master my-branch
```
--------------------------------
### Display Struct Documentation With All Public Members
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/struct.rst
Include the :members: option to display the struct documentation along with all its public members.
```rst
.. doxygenstruct:: StructTest
:project: struct
:members:
```
--------------------------------
### Failing doxygenenumvalue Directive Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/enumvalue.rst
This example demonstrates how the directive behaves when the specified enum value does not exist in the Doxygen XML output, resulting in a warning.
```rst
.. doxygenenumvalue:: made_up_enumvalue
:project: restypedef
```
--------------------------------
### Documenting Class Templates with Multiple Parameters
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/template.rst
Document a class with multiple template parameters using `doxygenclass`. Ensure the project is correctly specified.
```rst
.. doxygenclass:: anothertemplateclass
:project: template_class_non_type
:members:
```
--------------------------------
### Order Parameters First
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/directives.rst
A boolean setting to control the placement of the parameters section. Set to `True` to place it immediately after descriptions, otherwise it appears at the end.
```python
breathe_order_parameters_first = True
```
--------------------------------
### Basic doxygennamespace Usage
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/namespace.rst
Generates the namespace name, description, and any top-level public members. Use this for a standard namespace documentation.
```rst
.. doxygennamespace:: foo
:project: namespace
```
--------------------------------
### Example Doxygen XML Output
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/codeguide.rst
This XML represents the output generated by Doxygen for the C++ struct example. It details the compound definition, includes, and member definitions, which Breathe processes.
```xml
cat
test_cpp.hpp
void
void cat::make_cute
```
--------------------------------
### Configure Default Members to Display
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/directives.rst
Set the default members to be displayed by Breathe. Use this to always show public and undocumented members.
```python
breathe_default_members = ('members', 'undoc-members')
```
--------------------------------
### Autodoxygenfile Directive Usage
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/directives.rst
Example usage of the autodoxygenfile directive when source projects are configured.
```rst
.. autodoxygenfile:: file.c
:project: myprojectsource
```
--------------------------------
### Configure Doxygen Domain by File Pattern
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/directives.rst
Allows specifying domains for particular files using wildcard syntax, overriding the extension setting when necessary.
```python
breathe_domain_by_file_pattern = {
"*/alias.h" : "c",
}
```
--------------------------------
### Document All Symbols in a Source File
Source: https://context7.com/breathe-doc/breathe/llms.txt
Renders documentation for every documented entity within a specified source file. Use `:sections:` to control which description sections are included, or `:outline:` for an outline view.
```rst
.. doxygenfile:: api.h
:project: myproject
```
```rst
.. doxygenfile:: c_struct.h
:project: myproject
:sections: briefdescription detaileddescription
```
```rst
.. doxygenfile:: core.cpp
:project: myproject
:outline:
:allow-dot-graphs:
```
--------------------------------
### Documenting Functions with Multiple Template Parameters
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/template.rst
Document a function with multiple template parameters using `doxygenfunction`. The project must be specified.
```rst
.. doxygenfunction:: function2
:project: template_function
```
--------------------------------
### Minimum Breathe Configuration
Source: https://context7.com/breathe-doc/breathe/llms.txt
Configure Breathe in conf.py by adding 'breathe' to extensions, mapping project names to Doxygen XML output directories, and setting a default project.
```python
# conf.py — minimum viable configuration
import sys, os
extensions = ['breathe']
# Map project names to their Doxygen XML output directories
breathe_projects = {
"myproject": "/path/to/doxygen/xml/",
}
# Default project used when a directive omits :project:
breathe_default_project = "myproject"
```
--------------------------------
### Using autodoxygenfile Directive
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/autofile.rst
This is an example of how to use the autodoxygenfile directive in reStructuredText. It specifies the Doxygen XML file to process and the project name.
```rst
.. autodoxygenfile:: auto_class.h
:project: auto
```
--------------------------------
### Documenting Class Templates with Single Parameter
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/template.rst
Use `doxygenclass` to document a class with a single template parameter. Specify the project to link to the Doxygen output.
```rst
.. doxygenclass:: templateclass
:project: template_class
:members:
```
--------------------------------
### doxygenfile Directive for Namespaced Files
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/file.rst
Use the doxygenfile directive to process header files that are part of a namespace. This example assumes a namespace structure.
```rst
.. doxygenfile:: namespacefile.h
:project: namespace
```
--------------------------------
### Run Doxygen
Source: https://context7.com/breathe-doc/breathe/llms.txt
Execute Doxygen with your Doxyfile to generate the necessary XML files for Breathe.
```bash
# Run Doxygen to produce the XML tree
doxygen Doxyfile
# Output: doxygen/xml/index.xml + one XML file per compound
```
--------------------------------
### Handling a non-existent enum with doxygenenum
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/enum.rst
This example shows how the directive behaves when the specified enum does not exist in the Doxygen XML output. It will result in a warning.
```rst
.. doxygenenum:: made_up_enum
:project: restypedef
```
--------------------------------
### Render Node and Get Signature
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/codeguide.rst
Use the render function to process a node and extract its signature. This is typically used for testing and asserting the rendered output.
```python
# Render the node and grab its description
signature = find_node(render(app, member_def), "desc_signature")
# You can now examine the contents of signature.astext() and assert that
# they are as expected
```
--------------------------------
### doxygen file
Source: https://context7.com/breathe-doc/breathe/llms.txt
Renders documentation for every documented entity defined in a specific source file.
```APIDOC
## doxygenfile — Document All Symbols in a Source File
Renders documentation for every documented entity defined in a specific source file.
```rst
.. doxygenfile:: api.h
:project: myproject
.. doxygenfile:: c_struct.h
:project: myproject
:sections: briefdescription detaileddescription
.. doxygenfile:: core.cpp
:project: myproject
:outline:
:allow-dot-graphs:
```
```
--------------------------------
### Define Doxygen Aliases
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/directives.rst
Configure aliases to be placed in the Doxygen config file. This example shows how to enable inline reStructuredText linking within Doxygen comments.
```python
breathe_doxygen_aliases = {
'rstref{1}': r'\verbatim embed:rst:inline :ref:`\1` \endverbatim'
}
```
--------------------------------
### Documenting Functions with Single Template Parameter
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/template.rst
Use `doxygenfunction` to document a function with a single template parameter. Link to the correct project.
```rst
.. doxygenfunction:: function1
:project: template_function
```
--------------------------------
### doxygenenumvalue Directive Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/enumvalue.rst
Use this directive to reference a specific enum value from Doxygen XML output. Ensure the project name matches the Doxygen configuration.
```rst
.. doxygenenumvalue:: TIXML_NO_ERROR
:project: tinyxml
```
--------------------------------
### Set Doxygen Configuration Options
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/directives.rst
Provide a dictionary of Doxygen configuration options to be written to the generated Doxygen config file by `autodoxygenindex`.
```python
breathe_doxygen_config_options = {'EXCLUDE_SYMBOLS': 'abc123'}
```
--------------------------------
### Handle non-existent C++ variable with doxygenvariable
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/variable.rst
This example shows how the doxygenvariable directive handles cases where the specified variable does not exist in the Doxygen XML output. It will generate a warning.
```rst
.. doxygenvariable:: made_up_variable
:project: define
```
--------------------------------
### Unannotated Non-C/C++ Code Block
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/codeblocks.rst
When Pygments does not recognize the syntax within an unannotated code block, no highlighting is applied. This example demonstrates a CMake script within a C++ context.
```cpp
/** A function with an unannotated code block with non-C/C++ code.
*
* @code
* set(user_list A B C)
* foreach(element ${user_list})
* message(STATUS "Element is ${element}")
* endforeach()
* @endcode
*
* Another code-block that explicitly remains not highlighted.
* @code{.unparsed}
* Show this as is.
* @endcode
*/
void with_unannotated_cmake_code_block();
```
--------------------------------
### Configure Multiple Projects in Breathe
Source: https://context7.com/breathe-doc/breathe/llms.txt
Map multiple project names to their respective Doxygen XML output directories in conf.py. Set a default project for directives that omit the :project: option.
```python
# conf.py
breathe_projects = {
"core": "../../doxygen/core/xml/",
"plugins": "../../doxygen/plugins/xml/",
"utils": "../../doxygen/utils/xml/",
}
breathe_default_project = "core"
# Per-directive override: :project: plugins
# Direct path override: :path: ../../doxygen/legacy/xml/
```
--------------------------------
### Doxygen Verbatim Block with Leading Asterisks (Problematic)
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/markups.rst
This example demonstrates how a Doxygen verbatim block with leading asterisks can cause reStructuredText to be misinterpreted, leading to incorrect rendering as a bullet list.
```cpp
/*!
* Inserting additional reStructuredText information.
*
* \verbatim embed:rst
* Some example code
*
* .. code-block:: cpp
*
* int example(int x) {
* return x * 2;
* }
* \endverbatim
*/
```
--------------------------------
### Documenting Qt Signals and Slots
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/class.rst
This directive documents a class, including its members, and is aware of Qt's Signals and Slots, displaying them in appropriate sections.
```rst
.. doxygenclass:: QtSignalSlotExample
:project: qtsignalsandslots
:members:
```
--------------------------------
### Breathe Project Configuration
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/autofile.rst
This Python code snippet shows the necessary configuration for Breathe in Sphinx's conf.py file. It maps a project name to its source directory and a list of Doxygen XML files.
```python
breathe_projects_source = {
"auto" : ( "../examples/specific", ["auto_class.h"] )
}
```
--------------------------------
### Display Struct Documentation With Undocumented Members
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/struct.rst
Combine :members:, :private-members:, and :undoc-members: options to display all members, including undocumented ones. Undocumented public members require :members:, and undocumented private members require :private-members:.
```rst
.. doxygenstruct:: StructTest
:project: struct
:members:
:private-members:
:undoc-members:
```
--------------------------------
### Integrate Doxygen with Read the Docs
Source: https://context7.com/breathe-doc/breathe/llms.txt
Configure your Sphinx `conf.py` to automatically run Doxygen and generate XML files at Read the Docs build time. This uses Python's `subprocess` module to execute Doxygen commands.
```python
# conf.py — generate Doxygen XML at RTD build time
import subprocess, os, sys
def run_doxygen(folder):
try:
retcode = subprocess.call("cd %s; make" % folder, shell=True)
if retcode < 0:
sys.stderr.write("doxygen terminated by signal %s" % (-retcode))
except OSError as e:
sys.stderr.write("doxygen execution failed: %s" % e)
def generate_doxygen_xml(app):
if os.environ.get('READTHEDOCS') == 'True':
run_doxygen("../doxygen/core")
run_doxygen("../doxygen/plugins")
def setup(app):
app.connect("builder-inited", generate_doxygen_xml)
```
--------------------------------
### Map File Extensions to Sphinx Domains
Source: https://context7.com/breathe-doc/breathe/llms.txt
Configure `breathe_domain_by_extension` in conf.py to map file extensions (e.g., '.h', '.c') to the appropriate Sphinx domain (e.g., 'cpp', 'c'). This ensures Breathe uses the correct language domain when rendering symbols.
```python
# conf.py
breathe_domain_by_extension = {
"h": "cpp",
"hpp": "cpp",
"c": "c",
"py": "py",
"php": "php",
}
```
--------------------------------
### Handle Leading Slashes with embed:rst:leading-slashes
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/markups.rst
For comment blocks starting with triple forward slashes (`///`), use `embed:rst:leading-slashes` to correctly process embedded reStructuredText, avoiding issues with the slashes.
```cpp
/// Some kind of method
///
/// @param something a parameter
/// @returns the same value provided in something param
///
/// @verbatim embed:rst:leading-slashes
/// .. code-block:: c
/// :linenos:
///
/// bool foo(bool something) {
/// return something;
/// };
///
/// @endverbatim
/// @note Documentation using `///` should begin and end in a blank line.
```
--------------------------------
### Document a Preprocessor Macro
Source: https://context7.com/breathe-doc/breathe/llms.txt
Renders a `#define` macro. Set `breathe_show_define_initializer = True` in `conf.py` to display the macro's value.
```rst
.. doxygendefine:: MAX_BUFFER_SIZE
:project: myproject
```
```rst
.. doxygendefine:: PLATFORM_WINDOWS
:project: myproject
:outline:
```
--------------------------------
### Failing doxygenfunction Example
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/function.rst
This snippet demonstrates an intentionally failing case where the 'doxygenfunction' directive is used with a non-existent function name ('made_up_function'). This will result in a warning message indicating that the function could not be found in the doxygen XML output.
```rst
.. doxygenfunction:: made_up_function
:project: structcmd
```
--------------------------------
### Generate API Stub Files with breathe-apidoc
Source: https://context7.com/breathe-doc/breathe/llms.txt
Use the `breathe-apidoc` command-line tool to crawl Doxygen XML output and generate RST stub files for API entries. Options include specifying output directory, forcing overwrites, including members, filtering by type, and dry runs.
```bash
# Basic: generate stubs for all compound types
breathe-apidoc -o docs/api /path/to/doxygen/xml
# Force overwrite, include :members:, limit to classes and structs
breathe-apidoc -o docs/api \
-f \
-m \
-g class,struct \
--project myproject \
/path/to/doxygen/xml
# Dry run with custom suffix
breathe-apidoc -o docs/api \
-n \
-s txt \
/path/to/doxygen/xml
# Quiet mode, no table-of-contents file
breathe-apidoc -o docs/api -q -T /path/to/doxygen/xml
```
--------------------------------
### Configure Doxygen Domain by File Extension
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/directives.rst
Allows specifying domains for particular files based on their extension. This setting enables support for Doxygen XML generated from PHP code.
```python
breathe_domain_by_extension = {
"h" : "cpp",
}
breathe_domain_by_extension = {
"php" : "php",
}
```
--------------------------------
### Sphinx Configuration for MathJax
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/latexmath.rst
Configuration snippet for Sphinx's conf.py to enable math rendering using the mathjax extension.
```python
extensions = ["breathe", "sphinx.ext.mathjax"]
```
--------------------------------
### Sphinx Configuration for Breathe Projects
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/index.rst
Configure the 'breathe_projects' dictionary in your Sphinx 'conf.py' file to map project names to their Doxygen XML output paths.
```python
breathe_projects = {
"nutshell": "../../examples/specific/nutshell/xml/",
}
```
--------------------------------
### Handle Missing Define with doxygendefine
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/define.rst
Demonstrates how the doxygendefine directive handles a non-existent define, resulting in a warning. This is useful for testing or showing error conditions.
```rst
.. doxygendefine:: MADEUPDEFINE
:project: define
```
--------------------------------
### Display Struct Documentation With Specific Public Members
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/struct.rst
Specify member names as comma-separated arguments to the :members: option to document only those particular members.
```rst
.. doxygenstruct:: StructTest
:project: struct
:members: publicFunction, protectedFunction
```
--------------------------------
### Configure Sphinx Extensions
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/dot_graphs.rst
Ensure 'breathe' and 'sphinx.ext.graphviz' are added to your Sphinx project's extensions list in conf.py to enable graph rendering.
```python
extensions = ["breathe", "sphinx.ext.graphviz"]
```
--------------------------------
### Doxygen Configuration for XML Output
Source: https://context7.com/breathe-doc/breathe/llms.txt
Configure Doxyfile to generate XML output for Breathe. Ensure GENERATE_XML is YES and specify the XML output directory.
```ini
# Doxyfile — key settings for Breathe compatibility
PROJECT_NAME = "My Project"
OUTPUT_DIRECTORY = doxygen/
GENERATE_XML = YES
XML_OUTPUT = xml
GENERATE_HTML = NO
RECURSIVE = YES
INPUT = src/
```
--------------------------------
### Show Define Initializer
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/directives.rst
A boolean flag to control whether the initializer of a define is displayed in the output. Set to `True` to include values like '100' for `MAX_LENGTH 100`.
```python
breathe_show_define_initializer = True
```
--------------------------------
### Sphinx Configuration to Enable Breathe Extension
Source: https://github.com/breathe-doc/breathe/blob/main/documentation/source/index.rst
Add 'breathe' to the 'extensions' list in your Sphinx 'conf.py' file to enable Breathe's functionality.
```rst
extensions = ["breathe"]
```