@@ -89,6 +89,169 @@ this_attribute = 0
89
89
90
90
INFO: ** The default behavior (with unspecified ` members ` or ` members: null ` ) is to use [ ` filters ` ] [ ] .**
91
91
92
+ ## ` inherited_members `
93
+
94
+ - ** :octicons-package-24: Type <code ><span data-autorefs-optional =" list " >list</span >[ <span data-autorefs-optional =" str " >str</span >] |
95
+ <span data-autorefs-optional =" bool " >bool</span ></code > :material-equal: ` False ` { title="default value" }**
96
+ <!-- - **:octicons-project-template-24: Template :material-null:** (N/A) -->
97
+
98
+ An explicit list of inherited members (for classes) to render.
99
+
100
+ Inherited members are always fetched from classes that are in the same package
101
+ as the currently rendered class. To fetch members inherited from base classes,
102
+ themselves coming from external packages, use the [ ` preload_modules ` ] [ preload_modules ] option.
103
+ For example, if your class inherits from Pydantic's ` BaseModel ` , and you want to render
104
+ ` BaseModel ` 's methods in your class, use ` preload_modules: [pydantic] ` .
105
+ The ` pydantic ` package must be available in the current environment.
106
+
107
+ Passing a falsy value (` no ` , ` false ` in YAML) or an empty list (` [] ` )
108
+ will tell the Python handler not to render any inherited member.
109
+ Passing a truthy value (` yes ` , ` true ` in YAML)
110
+ will tell the Python handler to render every inherited member.
111
+
112
+ When all inherited members are selected with ` inherited_members: true ` ,
113
+ it is possible to specify both members and inherited members in the ` members ` list:
114
+
115
+ ``` yaml
116
+ inherited_members : true
117
+ members :
118
+ - inherited_member_a
119
+ - inherited_member_b
120
+ - member_x
121
+ - member_y
122
+ ` ` `
123
+
124
+ The alternative is not supported:
125
+
126
+ ` ` ` yaml
127
+ inherited_members :
128
+ - inherited_member_a
129
+ - inherited_member_b
130
+ members :
131
+ - member_x
132
+ - member_y
133
+ ` ` `
134
+
135
+ ...because it would make members ordering ambiguous/unspecified.
136
+
137
+ You can render inherited members *only* by setting ` inherited_members: true`
138
+ (or a list of inherited members) and setting `members : false`:
139
+
140
+ ` ` ` yaml
141
+ inherited_members: true
142
+ members: false
143
+ ` ` `
144
+
145
+ ` ` ` yaml
146
+ inherited_members:
147
+ - inherited_member_a
148
+ - inherited_member_b
149
+ members: false
150
+ ` ` `
151
+
152
+ You can render *all declared members* and all or specific inherited members
153
+ by leaving `members` as null (default) :
154
+
155
+ ` ` ` yaml
156
+ inherited_members:
157
+ - inherited_member_a
158
+ - inherited_member_b
159
+ # members: null # (1)
160
+ ` ` `
161
+
162
+ 1. In this case, only declared members will be subject
163
+ to further filtering with [`filters`][filters] and [`docstrings`][show_if_no_docstring].
164
+
165
+ ` ` ` yaml
166
+ inherited_members: true # (1)
167
+ # members: null
168
+ ` ` `
169
+
170
+ 1. In this case, both declared and inherited members will be subject
171
+ to further filtering with [`filters`][filters] and [`docstrings`][show_if_no_docstring].
172
+
173
+ You can render *all declared members* and all or specific inherited members,
174
+ avoiding further filtering with [`filters`][filters] and [`docstrings`][show_if_no_docstring]
175
+ by setting `members : true`:
176
+
177
+ ` ` ` yaml
178
+ inherited_members: true
179
+ members: true
180
+ ` ` `
181
+
182
+ ` ` ` yaml
183
+ inherited_members:
184
+ - inherited_member_a
185
+ - inherited_member_b
186
+ members: true
187
+ ` ` `
188
+
189
+ The general rule is that declared or inherited members specified in lists
190
+ are never filtered out.
191
+
192
+ ` ` ` yaml title="in mkdocs.yml (global configuration)"
193
+ plugins:
194
+ - mkdocstrings:
195
+ handlers:
196
+ python:
197
+ options:
198
+ inherited_members: false
199
+ ` ` `
200
+
201
+ ` ` ` md title="or in docs/some_page.md (local configuration)"
202
+ ::: package.module
203
+ options:
204
+ inherited_members: true
205
+ ` ` `
206
+
207
+ ` ` ` python title="package/module.py"
208
+ """Module docstring."""
209
+
210
+ class Base:
211
+ """Base class."""
212
+
213
+ def base(self):
214
+ """Base method."""
215
+
216
+
217
+ class Main(Base):
218
+ """Main class."""
219
+
220
+ def main(self):
221
+ """Main method."""
222
+ ` ` `
223
+
224
+ /// admonition | Preview
225
+ type : preview
226
+
227
+ //// tab | With inherited members
228
+ <p>Module docstring.</p>
229
+ <h2><code>Base</code></h2>
230
+ <p>Base class.</p>
231
+ <h3><code>base</code></h3>
232
+ <p>Base method.</p>
233
+ <h2><code>Main</code></h2>
234
+ <p>Main class.</p>
235
+ <h3><code>base</code></h3>
236
+ <p>Base method.</p>
237
+ <h3><code>main</code></h3>
238
+ <p>Main method.</p>
239
+ ////
240
+
241
+ //// tab | Without inherited members
242
+ <p>Module docstring.</p>
243
+ <h2><code>Base</code></h2>
244
+ <p>Base class.</p>
245
+ <h3><code>base</code></h3>
246
+ <p>Base method.</p>
247
+ <h2><code>Main</code></h2>
248
+ <p>Main class.</p>
249
+ <h3><code>main</code></h3>
250
+ <p>Main method.</p>
251
+ ////
252
+
253
+ ///
254
+
92
255
# # `members_order`
93
256
94
257
- **:octicons-package-24: Type [`str`][] :material-equal: `"alphabetical"`{ title="default value" }**
0 commit comments