From 375b1c9f7ac76555b4b08312e4b70f20ba0392d0 Mon Sep 17 00:00:00 2001 From: Philipp Sommer Date: Mon, 21 Oct 2024 14:15:55 +0200 Subject: [PATCH] add autoexception to docs --- docs/conf_settings.rst | 5 +++++ docs/demo_exception.rst | 8 ++++++++ docs/dummy.py | 13 +++++++++++++ docs/examples.rst | 14 ++++++++++---- 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 docs/demo_exception.rst diff --git a/docs/conf_settings.rst b/docs/conf_settings.rst index 7f3e923..51b1a77 100644 --- a/docs/conf_settings.rst +++ b/docs/conf_settings.rst @@ -78,6 +78,11 @@ Directives By default, this directives also sets the `:members:` option unless you specify `:no-members`. +.. rst:directive:: autoexceptionsumm + + The same as the ``autoclasssumm`` directive, just for an ``Exception`` + subclass. + .. rst:directive:: automodulesumm The same as the ``autoclasssumm`` directive, just for a module. diff --git a/docs/demo_exception.rst b/docs/demo_exception.rst new file mode 100644 index 0000000..473a1de --- /dev/null +++ b/docs/demo_exception.rst @@ -0,0 +1,8 @@ +.. _demo_exception: + +Demo Exception +============== + +.. autoexception:: dummy.MyException + :members: + :noindex: \ No newline at end of file diff --git a/docs/dummy.py b/docs/dummy.py index 3383ced..d169088 100644 --- a/docs/dummy.py +++ b/docs/dummy.py @@ -22,5 +22,18 @@ def do_something(self): some_other_attr = None +class MyException(object): + """Some Exception + + With some description""" + + def do_something_exceptional(self): + """Do something exceptional""" + pass + + #: Any instance attribute + some_exception_attr = None + + #: Some module data large_data = 'Whatever' diff --git a/docs/examples.rst b/docs/examples.rst index 14d274b..5d730d9 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -8,6 +8,7 @@ Examples Demo Module Demo Class + Demo Exception Demo Grouper Including a table of contents @@ -24,11 +25,16 @@ The *autosummary* flag introduces a small table of contents. So:: produces :ref:`this `. And:: - .. autoclass:: dummy.SomeClass + .. autoclass:: dummy.MyClass :members: :autosummary: -produces :ref:`this `. +produces :ref:`this `, and for exceptions:: + + .. autoexception:: dummy.MyException + :members: + :autosummary: +produces :ref:`this `. By default, module members are (mainly) grouped according into *Functions*, *Classes* and *Data*, class members are grouped into *Methods* and @@ -178,8 +184,8 @@ section of a class, you can specify:: Multiple sections might be separated by `;;`, e.g. ``:autosummary-sections: Methods ;; Attributes``. -This also works for the ``autoclasssumm`` and ``automodulesumm`` directives, -e.g.:: +This also works for the ``autoclasssumm``, ``autoexceptionsumm`` and +``automodulesumm`` directives, e.g.:: .. autoclasssumm:: dummy.SomeClass :autosummary-sections: Methods