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