Skip to content

Commit 1d0f0f5

Browse files
committed
show-bases
1 parent 7339f4d commit 1d0f0f5

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

quartodoc/builder/blueprint.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ def enter(self, el: Auto):
332332
children,
333333
flat=is_flat,
334334
signature_name=el.signature_name,
335+
show_bases=el.show_bases
335336
)
336337

337338
@staticmethod

quartodoc/layout.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ class AutoOptions(_Base):
226226
children: ChoicesChildren = ChoicesChildren.embedded
227227
package: Union[str, None, MISSING] = MISSING()
228228
member_options: Optional["AutoOptions"] = None
229+
show_bases: bool = False
229230

230231
# for tracking fields users manually specify
231232
# so we can tell them apart from defaults
@@ -274,6 +275,8 @@ class Auto(AutoOptions):
274275
If specified, object lookup will be relative to this path.
275276
member_options:
276277
Options to apply to members. These can include any of the options above.
278+
show_bases:
279+
Whether to show the base classes of a class.
277280
278281
279282
"""
@@ -324,6 +327,8 @@ class Doc(_Docable):
324327
The loaded python object.
325328
anchor:
326329
An anchor named, used to locate this documentation on a [](`quartodoc.layout.Page`).
330+
show_bases:
331+
Whether to show the base classes of a class.
327332
328333
See Also
329334
--------
@@ -335,6 +340,7 @@ class Doc(_Docable):
335340
name: str
336341
obj: Union[dc.Object, dc.Alias]
337342
anchor: str
343+
show_bases: bool = False
338344
signature_name: SignatureOptions = "relative"
339345

340346
class Config:
@@ -350,6 +356,7 @@ def from_griffe(
350356
anchor: str = None,
351357
flat: bool = False,
352358
signature_name: str = "relative",
359+
show_bases: bool = False,
353360
):
354361
if members is None:
355362
members = []
@@ -362,6 +369,7 @@ def from_griffe(
362369
"obj": obj,
363370
"anchor": anchor,
364371
"signature_name": signature_name,
372+
"show_bases": show_bases
365373
}
366374

367375
if kind == "function":

quartodoc/renderers/md_renderer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,9 @@ def render(self, el: layout.Doc):
271271
@dispatch
272272
def render(self, el: Union[layout.DocClass, layout.DocModule]):
273273
title = self.render_header(el)
274-
274+
bases=''
275+
if el.show_bases and el.obj.is_class and el.obj.bases:
276+
bases = f"\n\nBases: `{'`, '.join([x.source for x in el.obj.bases])}`"
275277
attr_docs = []
276278
meth_docs = []
277279
class_docs = []
@@ -340,7 +342,7 @@ def render(self, el: Union[layout.DocClass, layout.DocModule]):
340342
body = self.render(el.obj)
341343

342344

343-
return "\n\n".join([title, *sig_part, body, *attr_docs, *class_docs, *meth_docs])
345+
return "\n\n".join([title, *sig_part, bases, body, *attr_docs, *class_docs, *meth_docs])
344346

345347
@dispatch
346348
def render(self, el: Union[layout.DocFunction, layout.DocAttribute]):

0 commit comments

Comments
 (0)