1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
|
.. _class-example:
doxygenclass Directive
======================
This directive generates the appropriate output for a single class. It takes the
standard ``project``, ``path``, ``outline`` and ``no-link`` options and
additionally the ``members``, ``protected-members``, ``private-members``,
``undoc-members``, ``membergroups`` and ``members-only`` options.
``members``
Designed to behavior in a similar manner to the ``members`` option for the
``autoclass`` directive that comes with the Sphinx ``autodoc`` extension.
If you do not specify this option you will not get any information about the
class members, just the general class documentation. If you provide it
without arguments, then Breathe adds all the public members and their
documentation. If you specify it with **comma separated** arguments, then
Breathe will treat the arguments as names of members and provide
documentation for only those members that have been named.
``protected-members``
If specified, the protected members of the class will be displayed.
``private-members``
If specified, the private members of the class will be displayed.
``undoc-members``
If specified, the undocumented members of the class will be displayed.
``membergroups``
If specified, only the groups in a space-delimited list following this
directive will be displayed.
``members-only``
This will allow to show only the members, not the class information. Child
classes and structs are also not shown.
If you would like to always specify some combination of ``members``,
``protected-members``, ``private-members`` and ``undoc-members`` then you can
use the :ref:`breathe_default_members <breathe-default-members>` configuration
variable to set it in the ``conf.py``.
The output includes references to any base classes and derived classes of the
specified class.
Basic Example
-------------
.. cpp:namespace:: @ex_class_basic
This displays the class documentation without any members:
.. code-block:: rst
.. doxygenclass:: Nutshell
:project: nutshell
It produces this output:
.. doxygenclass:: Nutshell
:project: nutshell
Template Specialisation Example
-------------------------------
.. cpp:namespace:: @ex_class_template_spec
You can reference class template specialisations by include the specialisation
in the name:
.. code-block:: rst
.. doxygenclass:: TemplateClass< T * >
:project: template_specialisation
Produces this output:
.. doxygenclass:: TemplateClass< T * >
:project: template_specialisation
Where as without the specialisation, the directive references the generic
declaration:
.. code-block:: rst
.. doxygenclass:: TemplateClass
:project: template_specialisation
Produces this output:
.. doxygenclass:: TemplateClass
:project: template_specialisation
Note the spacing inside the ``<>``, it's important: there must be a
space after the ``<`` and before the ``>``.
Members Example
---------------
.. cpp:namespace:: @ex_class_members
This directive call will display the class documentation with all the public
members:
.. code-block:: rst
.. doxygenclass:: Nutshell
:project: nutshell
:members:
It produces this output:
.. doxygenclass:: Nutshell
:project: nutshell
:members:
:no-link:
Specific Members Example
------------------------
.. cpp:namespace:: @ex_class_members_specific
This displays the class documentation with only the members listed in the
``:members:`` option:
.. code-block:: rst
.. doxygenclass:: Nutshell
:project: nutshell
:members: Tool, crack, isCracked
It produces this output:
.. doxygenclass:: Nutshell
:project: nutshell
:members: Tool, crack, isCracked
:no-link:
Protected Members
-----------------
.. cpp:namespace:: @ex_class_members_protected
This displays only the protected members of the class. Normally this is combined
with the ``:members:`` option to show the public members as well.
.. code-block:: rst
.. doxygenclass:: GroupedClassTest
:project: group
:protected-members:
It produces this output:
.. doxygenclass:: GroupedClassTest
:project: group
:protected-members:
Private Members
---------------
.. cpp:namespace:: @ex_class_members_private
This displays only the private members of the class. Normally this is combined
with the ``:members:`` option to show the public members as well.
.. code-block:: rst
.. doxygenclass:: Nutshell
:project: nutshell
:private-members:
It produces this output:
.. doxygenclass:: Nutshell
:project: nutshell
:private-members:
:no-link:
Undocumented Members
--------------------
.. cpp:namespace:: @ex_class_members_undocumented
This displays the undocumented members of the class which are suppressed by
default. Undocumented public members are only shown if the ``:members:`` option
is also used. The same goes for the undocumented private members and the
``private-members`` option.
.. code-block:: rst
.. doxygenclass:: ClassTest
:project: class
:members:
:private-members:
:undoc-members:
It produces this output:
.. doxygenclass:: ClassTest
:project: classtest
:members:
:private-members:
:undoc-members:
:no-link:
.. note::
Undocumented classes are still not shown in the output due to an implementation
issue. Please post an issue on github if you would like this resolved.
.. _class-example-membergroups:
Membergroups
------------
.. cpp:namespace:: @ex_class_membergroups
This will show only members in the specified member group(s).
.. code-block:: rst
.. doxygenclass:: GroupedMembers
:project: membergroups
:members:
:membergroups: myGroup
It produces this output:
.. doxygenclass:: GroupedMembers
:project: membergroups
:members:
:membergroups: myGroup
:no-link:
Without ``:membergroups: myGroup`` it would produce:
.. cpp:namespace:: @ex_class_membergroups_all
.. doxygenclass:: GroupedMembers
:project: membergroups
:members:
.. _class-example-membersonly:
Members-only
------------
.. cpp:namespace:: @ex_class_members_only
This will only show the members of a class, and not the class name, child
classes or structs, or any information about the class.
.. code-block:: rst
.. doxygenclass:: ClassTest
:project: class
:members:
:members-only:
It produces this output:
.. doxygenclass:: ClassTest
:project: classtest
:members:
:members-only:
:no-link:
Without ``:members-only:`` it would produce:
.. cpp:namespace:: @ex_class_members_all
.. doxygenclass:: ClassTest
:project: classtest
:members:
:no-link:
.. note::
The members will be shown at the indentation normally reserver for class
definitions. To prevent this, you may want to indent the block by indenting
the ``.. doxygenclass`` directive.
.. note::
In the ``readthedocs`` theme, the members will show up in the color scheme of the
class definitions. If you would like them rendered as the other members,
indent like above, create a ``_static/css/custom.css`` file containing
.. code-block:: css
/* render as functions not classes when indented (for :members-only:) */
html.writer-html4 .rst-content blockquote dl:not(.field-list)>dt,
html.writer-html5 .rst-content blockquote dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple)>dt {
margin-bottom: 6px;
border: none;
border-left: 3px solid #ccc;
background: #f0f0f0;
color: #555;
}
and add the following to your ``conf.py``
.. code-block:: python
html_static_path = ['_static']
html_css_files = ['css/custom.css']
Outline Example
---------------
.. cpp:namespace:: @ex_class_outline
This displays only the names of the class members and not their
documentation. The ``:members:`` and ``:private-members:`` options determine
which members are displayed.
.. code-block:: rst
.. doxygenclass:: Nutshell
:project: nutshell
:members:
:outline:
It produces this output:
.. doxygenclass:: Nutshell
:project: nutshell
:members:
:outline:
:no-link:
Qt Signals & Slots Example
--------------------------
.. cpp:namespace:: @ex_class_qt
Doxygen is aware of Qt Signals and Slots and so Breathe can pick them up and
display them in the output. They are displayed in appropriate ``Signals``,
``Public Slots``, ``Protected Slots`` and ``Private Slots`` sections.
.. code-block:: rst
.. doxygenclass:: QtSignalSlotExample
:project: qtsignalsandslots
:members:
Produces the following output:
.. doxygenclass:: QtSignalSlotExample
:project: qtsignalsandslots
:members:
Failing Example
---------------
.. cpp:namespace:: @ex_class_failing
This intentionally fails:
.. code-block:: rst
.. doxygenclass:: made_up_class
:project: class
:members:
It produces the following warning message:
.. warning::
doxygenclass: Cannot find class “made_up_class” in doxygen xml
output for project “class” from directory: ../../examples/doxygen/class/xml/
|