diff --git a/src/autodoc2/render/myst_.py b/src/autodoc2/render/myst_.py index 39b1623..77fc5f5 100644 --- a/src/autodoc2/render/myst_.py +++ b/src/autodoc2/render/myst_.py @@ -259,7 +259,7 @@ def render_class(self, item: ItemData) -> t.Iterable[str]: lines.extend(["```", ""]) for child in self.get_children( - item, {"class", "property", "attribute", "method"} + item, {"class", "property", "attribute", "method", "exception"} ): if ( child["full_name"].endswith(".__init__") diff --git a/src/autodoc2/render/rst_.py b/src/autodoc2/render/rst_.py index 1a196f9..d041088 100644 --- a/src/autodoc2/render/rst_.py +++ b/src/autodoc2/render/rst_.py @@ -239,7 +239,7 @@ def render_class(self, item: ItemData) -> t.Iterable[str]: yield "" for child in self.get_children( - item, {"class", "property", "attribute", "method"} + item, {"class", "property", "attribute", "method", "exception"} ): if ( child["full_name"].endswith(".__init__") diff --git a/tests/test_render.py b/tests/test_render.py index 219699d..ddf1fa3 100644 --- a/tests/test_render.py +++ b/tests/test_render.py @@ -258,6 +258,9 @@ def prop(self) -> alias | None: class Nested: '''This is a nested class.''' + + class NestedEx(Exception): + '''This is a nested exception.''' """ ), "utf-8", diff --git a/tests/test_render/test_basic_myst_.md b/tests/test_render/test_basic_myst_.md index 11f0601..aa05a64 100644 --- a/tests/test_render/test_basic_myst_.md +++ b/tests/test_render/test_basic_myst_.md @@ -129,4 +129,20 @@ package.a ```` +````{py:exception} NestedEx() +:canonical: package.Class.NestedEx + +Bases: {py:obj}`Exception` + +```{autodoc2-docstring} package.Class.NestedEx +``` + +```{rubric} Initialization +``` + +```{autodoc2-docstring} package.Class.NestedEx.__init__ +``` + +```` + ````` diff --git a/tests/test_render/test_basic_rst_.rst b/tests/test_render/test_basic_rst_.rst index e1c7c45..15e3de5 100644 --- a/tests/test_render/test_basic_rst_.rst +++ b/tests/test_render/test_basic_rst_.rst @@ -101,3 +101,14 @@ API :canonical: package.Class.Nested .. autodoc2-docstring:: package.Class.Nested + + .. py:exception:: NestedEx() + :canonical: package.Class.NestedEx + + Bases: :py:obj:`Exception` + + .. autodoc2-docstring:: package.Class.NestedEx + + .. rubric:: Initialization + + .. autodoc2-docstring:: package.Class.NestedEx.__init__