You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/usage/configuration/docstrings.md
+3
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,9 @@ plugins:
29
29
docstring_style: numpy
30
30
```
31
31
32
+
WARNING: **The style is applied to the specified object only, not its members.** Local `docstring_style` options (in `:::` instructions) will only be applied to the specified object, and not its members. Instead of changing the style when rendering, we strongly recommend to *set the right style as early as possible*, for example by using the [auto-style](https://mkdocstrings.github.io/griffe/reference/docstrings/#auto-style) (sponsors only), or with a custom Griffe extension
Copy file name to clipboardExpand all lines: docs/usage/configuration/general.md
+202-112
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,10 @@ and sometimes the collected data is inaccurate
18
18
(depending on the tool that was used to compile the module)
19
19
or too low-level/technical for API documentation.
20
20
21
+
See also [`force_inspection`](#force_inspection).
22
+
23
+
WARNING: **Packages are loaded only once.** When mkdocstrings-python collects data from a Python package (thanks to [Griffe](https://mkdocstrings.github.io/griffe/)), it collects *the entire package* and *caches it*. Next time an object from the same package is rendered, the package is retrieved from the cache and not collected again. The `allow_inspection` option will therefore only have an effect the first time a package is collected, and will do nothing for objects rendered afterwards.
<!-- - **:octicons-project-template-24: Template :material-null:** (contained in [`class.html`][class template]) -->
67
+
68
+
The `extensions` option lets you enable [Griffe extensions](https://mkdocstrings.github.io/griffe/extensions/), which enhance or modify the data collected from Python sources (or compiled modules).
69
+
70
+
Elements in the list can be strings or dictionaries.
71
+
72
+
Strings denote the path to an extension module, like `griffe_typingdoc`, or to an extension class directly, like `griffe_typingdoc.TypingDocExtension`. When using a module path, all extensions within that module will be loaded and enabled. Strings can also be the path to a Python module, and a class name separated with `:`, like `scripts/griffe_extensions.py` or `scripts/griffe_extensions.py:MyExtension`.
73
+
74
+
Dictionaries have a single key, which is the module/class path (as a dot-separated qualifier or file path and colon-separated class name, like above), and its value is another dictionary specifying options that will be passed when to class constructors when instantiating extensions.
75
+
76
+
WARNING: **Packages are loaded only once.** When mkdocstrings-python collects data from a Python package (thanks to [Griffe](https://mkdocstrings.github.io/griffe/)), it collects *the entire package* and *caches it*. Next time an object from the same package is rendered, the package is retrieved from the cache and not collected again. Only the extensions specified the first time the package is loaded will be used. You cannot use a different set of extensions for specific objects rendered afterwards, and you cannot deactivate extensions for objects rendered afterwards either.
```md title="or in docs/some_page.md (local configuration)"
92
+
::: your_package.your_module.your_func
93
+
options:
94
+
extensions:
95
+
- griffe_typingdoc
96
+
```
97
+
98
+
[](){#option-extra}
99
+
## `extra`
100
+
101
+
- **:octicons-package-24: Type [`dict`][] :material-equal: `{}`{ title="default value" }**
102
+
<!-- - **:octicons-project-template-24: Template :material-null:** (contained in [`class.html`][class template]) -->
103
+
104
+
The `extra` option lets you inject additional variables into the Jinja context used when rendering templates. You can then use this extra context in your [overridden templates][templates].
105
+
106
+
Local `extra` options will be merged into the global `extra` option:
...will inject both `hello` and `foo` into the Jinja context when rendering `your_package.your_module.your_func`.
126
+
127
+
> WARNING: Previously, extra options were supported directly under the `options` key.
128
+
>
129
+
> ```yaml
130
+
> plugins:
131
+
> - mkdocstrings:
132
+
> handlers:
133
+
> python:
134
+
> options:
135
+
> hello: world
136
+
> ```
137
+
>
138
+
> Now that we introduced optional validation of options and automatic JSON schema generation thanks to Pydantic, we require extra options to be put under `options.extra`. Extra options directly under `options` are still supported, but deprecated, and will emit deprecation warnings. Support will be removed in a future version of mkdocstrings-python.
139
+
140
+
[](){#option-find_stubs_package}
141
+
## `find_stubs_package`
142
+
143
+
- **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }**
144
+
<!-- - **:octicons-project-template-24: Template :material-null:** (contained in [`class.html`][class template]) -->
145
+
146
+
When looking for documentation specified in [autodoc instructions][autodoc syntax] (`::: identifier`), also look for
147
+
the stubs package as defined in [PEP 561](https://peps.python.org/pep-0561/) if it exists. This is useful when
148
+
most of your documentation is separately provided by such a package and not inline in your main package.
149
+
150
+
WARNING: **Packages are loaded only once.** When mkdocstrings-python collects data from a Python package (thanks to [Griffe](https://mkdocstrings.github.io/griffe/)), it collects *the entire package* and *caches it*. Next time an object from the same package is rendered, the package is retrieved from the cache and not collected again. The `find_stubs_package` option will therefore only have an effect the first time a package is collected, and will do nothing for objects rendered afterwards.
- **:octicons-package-24: Type [`bool`][] :material-equal: `False`{ title="default value" }**
@@ -64,6 +207,8 @@ Whether to force inspecting modules (importing them) even if their source code i
64
207
65
208
This option is useful when you know that dynamic analysis (inspection) yields better results than static analysis. Do not use this blindly: the recommended approach is to write a Griffe extension that will improve extracted API data. See [How to selectively inspect objects](https://mkdocstrings.github.io/griffe/guide/users/how-to/selectively-inspect/).
WARNING: **Packages are loaded only once.** When mkdocstrings-python collects data from a Python package (thanks to [Griffe](https://mkdocstrings.github.io/griffe/)), it collects *the entire package* and *caches it*. Next time an object from the same package is rendered, the package is retrieved from the cache and not collected again. The `force_inspection` option will therefore only have an effect the first time a package is collected, and will do nothing for objects rendered afterwards.
0 commit comments