| 1 |
# Members options |
| 2 |
|
| 3 |
[](){#option-members} |
| 4 |
## `members` |
| 5 |
|
| 6 |
- **:octicons-package-24: Type <code><autoref identifier="list" optional>list</autoref>\[<autoref identifier="str" optional>str</autoref>\] | |
| 7 |
<autoref identifier="bool" optional>bool</autoref> | None</code> :material-equal: `None`{ title="default value" }** |
| 8 |
<!-- - **:octicons-project-template-24: Template :material-null:** (N/A) --> |
| 9 |
|
| 10 |
An explicit list of members to render. |
| 11 |
|
| 12 |
Only members declared in this list will be rendered. |
| 13 |
A member without a docstring will still be rendered, |
| 14 |
even if [`show_if_no_docstring`][] is set to false. |
| 15 |
|
| 16 |
The members will be rendered in the specified order, |
| 17 |
regardless of the value of [`members_order`][]. |
| 18 |
**Note that members will still be grouped by category, |
| 19 |
according to the [`group_by_category`][] option.** |
| 20 |
|
| 21 |
Passing a falsy value (`no`, `false` in YAML) or an empty list (`[]`) |
| 22 |
will tell the Python handler not to render any member. |
| 23 |
Passing a truthy value (`yes`, `true` in YAML) |
| 24 |
will tell the Python handler to render every member. |
| 25 |
|
| 26 |
Any given value, except for an explicit `None` (`null` in YAML) |
| 27 |
will tell the handler to ignore [`filters`][] for the object's members. |
| 28 |
Filters will still be applied to the next layers of members (grand-children). |
| 29 |
|
| 30 |
```yaml title="in mkdocs.yml (global configuration)" |
| 31 |
plugins: |
| 32 |
- mkdocstrings: |
| 33 |
handlers: |
| 34 |
python: |
| 35 |
options: |
| 36 |
members: |
| 37 |
- hello # (1) |
| 38 |
``` |
| 39 |
|
| 40 |
1. :warning: Most of the time it won't make sense to use this option at the global level. |
| 41 |
|
| 42 |
```md title="or in docs/some_page.md (local configuration)" |
| 43 |
::: package.module |
| 44 |
options: |
| 45 |
members: |
| 46 |
- ThisClass |
| 47 |
- this_function |
| 48 |
``` |
| 49 |
|
| 50 |
```python title="package/module.py" |
| 51 |
"""Module docstring.""" |
| 52 |
|
| 53 |
|
| 54 |
def this_function(): |
| 55 |
"""Function docstring.""" |
| 56 |
|
| 57 |
|
| 58 |
class ThisClass: |
| 59 |
"""Class docstring.""" |
| 60 |
|
| 61 |
def method(self): |
| 62 |
"""Method docstring.""" |
| 63 |
|
| 64 |
|
| 65 |
this_attribute = 0 |
| 66 |
"""Attribute docstring.""" |
| 67 |
``` |
| 68 |
|
| 69 |
/// admonition | Preview |
| 70 |
type: preview |
| 71 |
|
| 72 |
//// tab | With `members: true` |
| 73 |
<p>Module docstring.</p> |
| 74 |
<h2><code>this_function</code></h2> |
| 75 |
<p>Function docstring.</p> |
| 76 |
<h2><code>ThisClass</code></h2> |
| 77 |
<p>Class docstring.</p> |
| 78 |
<h3><code>method</code></h3> |
| 79 |
<p>Method docstring.</p> |
| 80 |
<h2><code>this_attribute</code></h2> |
| 81 |
<p>Attribute docstring.</p> |
| 82 |
//// |
| 83 |
|
| 84 |
//// tab | With `members: false` or `members: []` |
| 85 |
<p>Module docstring.</p> |
| 86 |
//// |
| 87 |
|
| 88 |
//// tab | With `members: [ThisClass]` |
| 89 |
<p>Module docstring.</p> |
| 90 |
<h2><code>ThisClass</code></h2> |
| 91 |
<p>Class docstring.</p> |
| 92 |
<h3><code>method</code></h3> |
| 93 |
<p>Method docstring.</p> |
| 94 |
//// |
| 95 |
/// |
| 96 |
|
| 97 |
INFO: **The default behavior (with unspecified `members` or `members: null`) is to use [`filters`][].** |
| 98 |
|
| 99 |
[](){#option-inherited_members} |
| 100 |
## `inherited_members` |
| 101 |
|
| 102 |
- **:octicons-package-24: Type <code><autoref identifier="list" optional>list</autoref>\[<autoref identifier="str" optional>str</autoref>\] | |
| 103 |
<autoref identifier="bool" optional>bool</autoref></code> :material-equal: `False`{ title="default value" }** |
| 104 |
<!-- - **:octicons-project-template-24: Template :material-null:** (N/A) --> |
| 105 |
|
| 106 |
An explicit list of inherited members (for classes) to render. |
| 107 |
|
| 108 |
Inherited members are always fetched from classes that are in the same package |
| 109 |
as the currently rendered class. To fetch members inherited from base classes, |
| 110 |
themselves coming from external packages, use the [`preload_modules`][preload_modules] option. |
| 111 |
For example, if your class inherits from Pydantic's `BaseModel`, and you want to render |
| 112 |
`BaseModel`'s methods in your class, use `preload_modules: [pydantic]`. |
| 113 |
The `pydantic` package must be available in the current environment. |
| 114 |
|
| 115 |
Passing a falsy value (`no`, `false` in YAML) or an empty list (`[]`) |
| 116 |
will tell the Python handler not to render any inherited member. |
| 117 |
Passing a truthy value (`yes`, `true` in YAML) |
| 118 |
will tell the Python handler to render every inherited member. |
| 119 |
|
| 120 |
When all inherited members are selected with `inherited_members: true`, |
| 121 |
it is possible to specify both members and inherited members in the `members` list: |
| 122 |
|
| 123 |
```yaml |
| 124 |
inherited_members: true |
| 125 |
members: |
| 126 |
- inherited_member_a |
| 127 |
- inherited_member_b |
| 128 |
- member_x |
| 129 |
- member_y |
| 130 |
``` |
| 131 |
|
| 132 |
The alternative is not supported: |
| 133 |
|
| 134 |
```yaml |
| 135 |
inherited_members: |
| 136 |
- inherited_member_a |
| 137 |
- inherited_member_b |
| 138 |
members: |
| 139 |
- member_x |
| 140 |
- member_y |
| 141 |
``` |
| 142 |
|
| 143 |
...because it would make members ordering ambiguous/unspecified. |
| 144 |
|
| 145 |
You can render inherited members *only* by setting `inherited_members: true` |
| 146 |
(or a list of inherited members) and setting `members: false`: |
| 147 |
|
| 148 |
```yaml |
| 149 |
inherited_members: true |
| 150 |
members: false |
| 151 |
``` |
| 152 |
|
| 153 |
```yaml |
| 154 |
inherited_members: |
| 155 |
- inherited_member_a |
| 156 |
- inherited_member_b |
| 157 |
members: false |
| 158 |
``` |
| 159 |
|
| 160 |
You can render *all declared members* and all or specific inherited members |
| 161 |
by leaving `members` as null (default): |
| 162 |
|
| 163 |
```yaml |
| 164 |
inherited_members: |
| 165 |
- inherited_member_a |
| 166 |
- inherited_member_b |
| 167 |
# members: null # (1) |
| 168 |
``` |
| 169 |
|
| 170 |
1. In this case, only declared members will be subject |
| 171 |
to further filtering with [`filters`][filters] and [`docstrings`][show_if_no_docstring]. |
| 172 |
|
| 173 |
```yaml |
| 174 |
inherited_members: true # (1) |
| 175 |
# members: null |
| 176 |
``` |
| 177 |
|
| 178 |
1. In this case, both declared and inherited members will be subject |
| 179 |
to further filtering with [`filters`][filters] and [`docstrings`][show_if_no_docstring]. |
| 180 |
|
| 181 |
You can render *all declared members* and all or specific inherited members, |
| 182 |
avoiding further filtering with [`filters`][filters] and [`docstrings`][show_if_no_docstring] |
| 183 |
by setting `members: true`: |
| 184 |
|
| 185 |
```yaml |
| 186 |
inherited_members: true |
| 187 |
members: true |
| 188 |
``` |
| 189 |
|
| 190 |
```yaml |
| 191 |
inherited_members: |
| 192 |
- inherited_member_a |
| 193 |
- inherited_member_b |
| 194 |
members: true |
| 195 |
``` |
| 196 |
|
| 197 |
The general rule is that declared or inherited members specified in lists |
| 198 |
are never filtered out. |
| 199 |
|
| 200 |
```yaml title="in mkdocs.yml (global configuration)" |
| 201 |
plugins: |
| 202 |
- mkdocstrings: |
| 203 |
handlers: |
| 204 |
python: |
| 205 |
options: |
| 206 |
inherited_members: false |
| 207 |
``` |
| 208 |
|
| 209 |
```md title="or in docs/some_page.md (local configuration)" |
| 210 |
::: package.module |
| 211 |
options: |
| 212 |
inherited_members: true |
| 213 |
``` |
| 214 |
|
| 215 |
```python title="package/module.py" |
| 216 |
"""Module docstring.""" |
| 217 |
|
| 218 |
|
| 219 |
class Base: |
| 220 |
"""Base class.""" |
| 221 |
|
| 222 |
def base(self): |
| 223 |
"""Base method.""" |
| 224 |
|
| 225 |
|
| 226 |
class Main(Base): |
| 227 |
"""Main class.""" |
| 228 |
|
| 229 |
def main(self): |
| 230 |
"""Main method.""" |
| 231 |
``` |
| 232 |
|
| 233 |
/// admonition | Preview |
| 234 |
type: preview |
| 235 |
|
| 236 |
//// tab | With inherited members |
| 237 |
<p>Module docstring.</p> |
| 238 |
<h2><code>Base</code></h2> |
| 239 |
<p>Base class.</p> |
| 240 |
<h3><code>base</code></h3> |
| 241 |
<p>Base method.</p> |
| 242 |
<h2><code>Main</code></h2> |
| 243 |
<p>Main class.</p> |
| 244 |
<h3><code>base</code></h3> |
| 245 |
<p>Base method.</p> |
| 246 |
<h3><code>main</code></h3> |
| 247 |
<p>Main method.</p> |
| 248 |
//// |
| 249 |
|
| 250 |
//// tab | Without inherited members |
| 251 |
<p>Module docstring.</p> |
| 252 |
<h2><code>Base</code></h2> |
| 253 |
<p>Base class.</p> |
| 254 |
<h3><code>base</code></h3> |
| 255 |
<p>Base method.</p> |
| 256 |
<h2><code>Main</code></h2> |
| 257 |
<p>Main class.</p> |
| 258 |
<h3><code>main</code></h3> |
| 259 |
<p>Main method.</p> |
| 260 |
//// |
| 261 |
|
| 262 |
/// |
| 263 |
|
| 264 |
[](){#option-members_order} |
| 265 |
## `members_order` |
| 266 |
|
| 267 |
- **:octicons-package-24: Type `str | list[str]` :material-equal: `"alphabetical"`{ title="default value" }** |
| 268 |
<!-- - **:octicons-project-template-24: Template :material-null:** (N/A) --> |
| 269 |
|
| 270 |
The members ordering to use. Possible values: |
| 271 |
|
| 272 |
- `__all__`: Order according to `__all__` attributes. Since classes do not define `__all__` attributes, you can specify a second ordering method by using a list. |
| 273 |
- `alphabetical`: Order by the members names. |
| 274 |
- `source`: Order members as they appear in the source file. |
| 275 |
|
| 276 |
The order applies for all members, recursively. |
| 277 |
The order will be ignored for members that are explicitely sorted using the [`members`][] option. |
| 278 |
**Note that members will still be grouped by category, |
| 279 |
according to the [`group_by_category`][] option.** |
| 280 |
|
| 281 |
```yaml title="in mkdocs.yml (global configuration)" |
| 282 |
plugins: |
| 283 |
- mkdocstrings: |
| 284 |
handlers: |
| 285 |
python: |
| 286 |
options: |
| 287 |
members_order: alphabetical |
| 288 |
``` |
| 289 |
|
| 290 |
```md title="or in docs/some_page.md (local configuration)" |
| 291 |
::: package.module |
| 292 |
options: |
| 293 |
members_order: source |
| 294 |
``` |
| 295 |
|
| 296 |
```md title="or in docs/some_page.md (local configuration)" |
| 297 |
::: package.module |
| 298 |
options: |
| 299 |
members_order: [__all__, source] |
| 300 |
``` |
| 301 |
|
| 302 |
```python title="package/module.py" |
| 303 |
"""Module docstring.""" |
| 304 |
|
| 305 |
|
| 306 |
def function_b(): |
| 307 |
"""Function a.""" |
| 308 |
|
| 309 |
|
| 310 |
def function_a(): |
| 311 |
"""Function b.""" |
| 312 |
|
| 313 |
|
| 314 |
def function_c(): |
| 315 |
"""Function c.""" |
| 316 |
``` |
| 317 |
|
| 318 |
/// admonition | Preview |
| 319 |
type: preview |
| 320 |
|
| 321 |
//// tab | With alphabetical order |
| 322 |
<p>Module docstring.</p> |
| 323 |
<h2><code>function_a</code></h2> |
| 324 |
<p>Function a.</p> |
| 325 |
<h2><code>function_b</code></h2> |
| 326 |
<p>Function b.</p> |
| 327 |
<h2><code>function_c</code></h2> |
| 328 |
<p>Function c.</p> |
| 329 |
//// |
| 330 |
|
| 331 |
//// tab | With source order |
| 332 |
<p>Module docstring.</p> |
| 333 |
<h2><code>function_b</code></h2> |
| 334 |
<p>Function b.</p> |
| 335 |
<h2><code>function_a</code></h2> |
| 336 |
<p>Function a.</p> |
| 337 |
<h2><code>function_c</code></h2> |
| 338 |
<p>Function c.</p> |
| 339 |
//// |
| 340 |
/// |
| 341 |
|
| 342 |
[](){#option-filters} |
| 343 |
## `filters` |
| 344 |
|
| 345 |
- **:octicons-package-24: Type <code><autoref identifier="list" optional>list</autoref>\[<autoref identifier="str" optional>str</autoref>\] | <autoref identifier="typing.Literal" optional>Literal</autoref>\["public"\] | None</code> :material-equal: `["!^_[^_]"]`{ title="default value" }** |
| 346 |
<!-- - **:octicons-project-template-24: Template :material-null:** (N/A) --> |
| 347 |
|
| 348 |
A list of filters, or `"public"`. |
| 349 |
|
| 350 |
**Filtering methods** |
| 351 |
|
| 352 |
[](){#option-filters-public} |
| 353 |
|
| 354 |
The `public` filtering method will include only public objects: those added to the `__all__` attribute of modules, or not starting with a single underscore. Special methods and attributes ("dunder" methods/attributes, starting and ending with two underscores), like `__init__`, `__call__`, `__mult__`, etc., are always considered public. |
| 355 |
|
| 356 |
**List of filters** |
| 357 |
|
| 358 |
Filters are regular expressions. These regular expressions are evaluated by Python |
| 359 |
and so must match the syntax supported by the [`re`][] module. |
| 360 |
A filter starting with `!` (negative filter) will exclude matching objects instead of including them. |
| 361 |
|
| 362 |
The default value (`["!^_[^_]"]`) means: *render every object, except those |
| 363 |
starting with one underscore, unless they start with two underscores*. |
| 364 |
It means that an object whose name is `hello`, `__hello`, or `__hello__` |
| 365 |
will be rendered, but not one whose name is `_hello`. |
| 366 |
|
| 367 |
Each filter takes precedence over the previous one. This allows for fine-grain |
| 368 |
selection of objects by adding more specific filters. For example, you can |
| 369 |
start by unselecting objects that start with `_`, and add a second filter |
| 370 |
that re-select objects that start with `__`. The default filters can |
| 371 |
therefore be rewritten like this: |
| 372 |
|
| 373 |
```yaml |
| 374 |
filters: |
| 375 |
- "!^_" |
| 376 |
- "^__" |
| 377 |
``` |
| 378 |
|
| 379 |
If there are no negative filters, the handler considers that everything |
| 380 |
is **unselected** first, and then selects things based on your positive filters. |
| 381 |
If there is at least one negative filter, the handler considers that everything |
| 382 |
is **selected** first, and then re-selects/unselects things based on your other filters. |
| 383 |
In short, `filters: ["a"]` means *"keep ***nothing*** except names containing `a`"*, while |
| 384 |
`filters: ["!a"]` means *"keep ***everything*** except names containing `a`"*. |
| 385 |
|
| 386 |
An empty list of filters tells the Python handler to render every object. |
| 387 |
The [`members`][] option takes precedence over filters |
| 388 |
(filters will still be applied recursively to lower members in the hierarchy). |
| 389 |
|
| 390 |
```yaml title="in mkdocs.yml (global configuration)" |
| 391 |
plugins: |
| 392 |
- mkdocstrings: |
| 393 |
handlers: |
| 394 |
python: |
| 395 |
options: |
| 396 |
filters: |
| 397 |
- "!^_[^_]" |
| 398 |
``` |
| 399 |
|
| 400 |
```md title="or in docs/some_page.md (local configuration)" |
| 401 |
::: package.module |
| 402 |
options: |
| 403 |
filters: public |
| 404 |
``` |
| 405 |
|
| 406 |
```python title="package/module.py" |
| 407 |
def hello(): |
| 408 |
... |
| 409 |
|
| 410 |
|
| 411 |
def _world(): |
| 412 |
... |
| 413 |
``` |
| 414 |
|
| 415 |
/// admonition | Preview |
| 416 |
type: preview |
| 417 |
|
| 418 |
//// tab | With `filters: []` |
| 419 |
<p>Module docstring.</p> |
| 420 |
<h2><code>hello</code></h2> |
| 421 |
<p>Function docstring.</p> |
| 422 |
<h2><code>_world</code></h2> |
| 423 |
<p>Function docstring.</p> |
| 424 |
//// |
| 425 |
|
| 426 |
//// tab | With `filters: ["hello"]` |
| 427 |
<p>Module docstring.</p> |
| 428 |
<h2><code>hello</code></h2> |
| 429 |
<p>Function docstring.</p> |
| 430 |
//// |
| 431 |
|
| 432 |
//// tab | With `filters: ["!hello"]` |
| 433 |
<p>Module docstring.</p> |
| 434 |
<h2><code>_world</code></h2> |
| 435 |
<p>Function docstring.</p> |
| 436 |
//// |
| 437 |
/// |
| 438 |
|
| 439 |
/// admonition | Common filters |
| 440 |
type: tip |
| 441 |
|
| 442 |
Here are some common filters that you might to want to use. |
| 443 |
|
| 444 |
- `["!^_"]`: exclude all private/protected/special objects |
| 445 |
- `["!^_", "^__init__$"]`: same as above, but keep `__init__` methods |
| 446 |
- `["!^_[^_]"]`: exclude all private/protected objects, keep special ones (default filters) |
| 447 |
/// |
| 448 |
|
| 449 |
[](){#option-group_by_category} |
| 450 |
## `group_by_category` |
| 451 |
|
| 452 |
- **:octicons-package-24: Type [`bool`][] :material-equal: `True`{ title="default value" }** |
| 453 |
<!-- - **:octicons-project-template-24: Template :material-null:** (N/A) --> |
| 454 |
|
| 455 |
Group the object members by categories: attributes, classes, functions, and modules. |
| 456 |
|
| 457 |
Members within a same category will be ordered according to the [`members_order`][] option. |
| 458 |
You can use the [`show_category_heading`][] option to also render a heading for each category. |
| 459 |
|
| 460 |
```yaml title="in mkdocs.yml (global configuration)" |
| 461 |
plugins: |
| 462 |
- mkdocstrings: |
| 463 |
handlers: |
| 464 |
python: |
| 465 |
options: |
| 466 |
group_by_category: true |
| 467 |
``` |
| 468 |
|
| 469 |
```md title="or in docs/some_page.md (local configuration)" |
| 470 |
::: package.module |
| 471 |
options: |
| 472 |
group_by_category: false |
| 473 |
``` |
| 474 |
|
| 475 |
```python title="package/module.py" |
| 476 |
def function_a(): |
| 477 |
... |
| 478 |
|
| 479 |
|
| 480 |
class ClassB: |
| 481 |
... |
| 482 |
|
| 483 |
|
| 484 |
attribute_C = 0 |
| 485 |
|
| 486 |
|
| 487 |
def function_d(): |
| 488 |
... |
| 489 |
``` |
| 490 |
|
| 491 |
/// admonition | Preview |
| 492 |
type: preview |
| 493 |
|
| 494 |
//// tab | With category grouping |
| 495 |
<p>Module docstring.</p> |
| 496 |
<h2><code>attribute_c</code></h2> |
| 497 |
<p>Attribute docstring.</p> |
| 498 |
<h2><code>ClassB</code></h2> |
| 499 |
<p>Class docstring.</p> |
| 500 |
<h2><code>function_a</code></h2> |
| 501 |
<p>Function docstring.</p> |
| 502 |
<h2><code>function_d</code></h2> |
| 503 |
<p>Function docstring.</p> |
| 504 |
//// |
| 505 |
|
| 506 |
//// tab | Without category grouping |
| 507 |
<p>Module docstring.</p> |
| 508 |
<h2><code>function_a</code></h2> |
| 509 |
<p>Function docstring.</p> |
| 510 |
<h2><code>ClassB</code></h2> |
| 511 |
<p>Class docstring.</p> |
| 512 |
<h2><code>attribute_c</code></h2> |
| 513 |
<p>Attribute docstring.</p> |
| 514 |
<h2><code>function_d</code></h2> |
| 515 |
<p>Function docstring.</p> |
| 516 |
//// |
| 517 |
/// |
| 518 |
|
| 519 |
[](){#option-show_submodules} |
| 520 |
## `show_submodules` |
| 521 |
|
| 522 |
- **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }** |
| 523 |
<!-- - **:octicons-project-template-24: Template :material-null:** (N/A) --> |
| 524 |
|
| 525 |
When rendering a module, show its submodules recursively. |
| 526 |
|
| 527 |
This is false by default, because most of the time we render only one module per page, |
| 528 |
and when rendering a package (a tree of modules and their members) on a single page, |
| 529 |
we quickly run out of [heading levels][heading_level]. |
| 530 |
|
| 531 |
```yaml title="in mkdocs.yml (global configuration)" |
| 532 |
plugins: |
| 533 |
- mkdocstrings: |
| 534 |
handlers: |
| 535 |
python: |
| 536 |
options: |
| 537 |
show_submodules: true |
| 538 |
``` |
| 539 |
|
| 540 |
```md title="or in docs/some_page.md (local configuration)" |
| 541 |
::: package.subpackage |
| 542 |
options: |
| 543 |
show_submodules: false |
| 544 |
``` |
| 545 |
|
| 546 |
```tree title="package" |
| 547 |
package |
| 548 |
__init__.py |
| 549 |
subpackage |
| 550 |
__init__.py |
| 551 |
submodule.py |
| 552 |
``` |
| 553 |
|
| 554 |
/// admonition | Preview |
| 555 |
type: preview |
| 556 |
|
| 557 |
//// tab | With submodules |
| 558 |
<p>Subpackage docstring.</p> |
| 559 |
<h2><code>subpackage_member</code></h2> |
| 560 |
<p>Member docstring.</p> |
| 561 |
<h2><code>submodule</code></h2> |
| 562 |
<p>Submodule docstring.</p> |
| 563 |
<h3><code>submodule_member</code></h3> |
| 564 |
<p>Member docstring.</p> |
| 565 |
//// |
| 566 |
|
| 567 |
//// tab | Without submodules |
| 568 |
<p>Subpackage docstring.</p> |
| 569 |
<h2><code>subpackage_member</code></h2> |
| 570 |
<p>Member docstring.</p> |
| 571 |
//// |
| 572 |
/// |
| 573 |
|
| 574 |
[](){#option-summary} |
| 575 |
## `summary` |
| 576 |
|
| 577 |
- **:octicons-package-24: Type <code><autoref identifier="bool" optional>bool</autoref> | <autoref identifier="dict" optional>dict</autoref>\[<autoref identifier="str" optional>str</autoref>, <autoref identifier="bool" optional>bool</autoref>\]</code> :material-equal: `False`{ title="default value" }** |
| 578 |
<!-- - **:octicons-project-template-24: Template :material-null:** (N/A) --> |
| 579 |
|
| 580 |
Whether to render summaries of modules, classes, functions (methods) and attributes. |
| 581 |
|
| 582 |
This option accepts a boolean (`yes`, `true`, `no`, `false` in YAML) |
| 583 |
or a dictionary with one or more of the following keys: `attributes`, `functions`, `classes`, `modules`, `type_aliases`, |
| 584 |
with booleans as values. Class methods summary is (de)activated with the `functions` key. |
| 585 |
By default, `summary` is false, and by extension all values are false. |
| 586 |
|
| 587 |
Examples: |
| 588 |
|
| 589 |
```yaml |
| 590 |
summary: true |
| 591 |
``` |
| 592 |
|
| 593 |
```yaml |
| 594 |
summary: false |
| 595 |
``` |
| 596 |
|
| 597 |
```yaml |
| 598 |
summary: |
| 599 |
attributes: false |
| 600 |
functions: true |
| 601 |
modules: false |
| 602 |
``` |
| 603 |
|
| 604 |
Summaries will be rendered as the corresponding docstring sections. |
| 605 |
For example, the summary for attributes will be rendered as an Attributes docstring section. |
| 606 |
The section will be rendered in accordance with the [`docstring_section_style`][] option. |
| 607 |
If the objects appearing in the summary are also rendered on the page |
| 608 |
(or somewhere else on the site), their name will automatically link to their rendered documentation. |
| 609 |
|
| 610 |
```yaml title="in mkdocs.yml (global configuration)" |
| 611 |
plugins: |
| 612 |
- mkdocstrings: |
| 613 |
handlers: |
| 614 |
python: |
| 615 |
options: |
| 616 |
summary: true |
| 617 |
``` |
| 618 |
|
| 619 |
```md title="or in docs/some_page.md (local configuration)" |
| 620 |
::: path.to.module |
| 621 |
options: |
| 622 |
summary: false |
| 623 |
``` |
| 624 |
|
| 625 |
/// admonition | Preview |
| 626 |
type: preview |
| 627 |
|
| 628 |
//// tab | With all summaries |
| 629 |
``` |
| 630 |
::: path.to.module.MyClass |
| 631 |
options: |
| 632 |
summary: true |
| 633 |
``` |
| 634 |
<h2>MyClass</h2> |
| 635 |
<p>Class docstring.</p> |
| 636 |
<p>Methods:</p> |
| 637 |
<ul> |
| 638 |
<li><a href="#my_method1">my_method1</a>: Summary of the method (first docstring line).</li> |
| 639 |
<li><a href="#my_method2">my_method2</a>: Summary of the method (first docstring line).</li> |
| 640 |
</ul> |
| 641 |
<p>Attributes:</p> |
| 642 |
<ul> |
| 643 |
<li><a href="#attr1">attr1</a>: Summary of the attribute (first docstring line).</li> |
| 644 |
<li><a href="#attr2">attr2</a>: Summary of the attribute (first docstring line).</li> |
| 645 |
</ul> |
| 646 |
//// |
| 647 |
|
| 648 |
//// tab | With methods summary only |
| 649 |
``` |
| 650 |
::: path.to.module.MyClass |
| 651 |
options: |
| 652 |
summary: |
| 653 |
functions: true |
| 654 |
``` |
| 655 |
|
| 656 |
<h2>MyClass</h2> |
| 657 |
<p>Class docstring.</p> |
| 658 |
<p>Methods:</p> |
| 659 |
<ul> |
| 660 |
<li><a href="#my_method1">my_method1</a>: Summary of the method (first docstring line).</li> |
| 661 |
<li><a href="#my_method2">my_method2</a>: Summary of the method (first docstring line).</li> |
| 662 |
</ul> |
| 663 |
//// |
| 664 |
/// |
| 665 |
|
| 666 |
[](){#option-show_labels} |
| 667 |
## `show_labels` |
| 668 |
|
| 669 |
- **:octicons-package-24: Type [`bool`][] :material-equal: `True`{ title="default value" }** |
| 670 |
<!-- - **:octicons-project-template-24: Template :material-null:** (N/A) --> |
| 671 |
|
| 672 |
Whether to show labels of the members. |
| 673 |
|
| 674 |
```yaml title="in mkdocs.yml (global configuration)" |
| 675 |
plugins: |
| 676 |
- mkdocstrings: |
| 677 |
handlers: |
| 678 |
python: |
| 679 |
options: |
| 680 |
show_labels: true |
| 681 |
``` |
| 682 |
|
| 683 |
```md title="or in docs/some_page.md (local configuration)" |
| 684 |
::: package.module |
| 685 |
options: |
| 686 |
show_labels: false |
| 687 |
``` |
| 688 |
|
| 689 |
```python title="package/module.py" |
| 690 |
class SomeClass: |
| 691 |
some_attr: int |
| 692 |
``` |
| 693 |
|
| 694 |
/// admonition | Preview |
| 695 |
type: preview |
| 696 |
|
| 697 |
//// tab | With labels |
| 698 |
<code class="highlight language-python"> |
| 699 |
<span class="n">some_attr</span><span class="p">:</span> |
| 700 |
<span class="nb">int</span> |
| 701 |
</code> |
| 702 |
<small><code>instance-attribute</code></small> |
| 703 |
//// |
| 704 |
|
| 705 |
//// tab | Without labels |
| 706 |
<code class="highlight language-python"> |
| 707 |
<span class="n">some_attr</span><span class="p">:</span> |
| 708 |
<span class="nb">int</span> |
| 709 |
</code> |
| 710 |
//// |
| 711 |
/// |