Skip to content

Commit

Permalink
add autoexception to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilipp committed Oct 21, 2024
1 parent 4e51644 commit 375b1c9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
5 changes: 5 additions & 0 deletions docs/conf_settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions docs/demo_exception.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. _demo_exception:

Demo Exception
==============

.. autoexception:: dummy.MyException
:members:
:noindex:
13 changes: 13 additions & 0 deletions docs/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
14 changes: 10 additions & 4 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Examples

Demo Module <demo_module>
Demo Class <demo_class>
Demo Exception <demo_exception>
Demo Grouper <demo_grouper>

Including a table of contents
Expand All @@ -24,11 +25,16 @@ The *autosummary* flag introduces a small table of contents. So::

produces :ref:`this <demo_module>`. And::

.. autoclass:: dummy.SomeClass
.. autoclass:: dummy.MyClass
:members:
:autosummary:

produces :ref:`this <demo_class>`.
produces :ref:`this <demo_class>`, and for exceptions::

.. autoexception:: dummy.MyException
:members:
:autosummary:
produces :ref:`this <demo_exception>`.

By default, module members are (mainly) grouped according into *Functions*,
*Classes* and *Data*, class members are grouped into *Methods* and
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 375b1c9

Please sign in to comment.