Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/source/_ext/libsemigroups_pybind11_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ def change_sig(
return_annotation=None,
):
"""Make type replacement in function signatures"""
if what == "class":
return None, None

signature, return_annotation = sig_alternative(
obj.__doc__, signature, return_annotation
)
Expand Down Expand Up @@ -437,11 +440,28 @@ def check_string_replacements(app, env):
logger.info(f"Please correct this in {__file__}")


def document_class(app, what, name, obj, options, lines):
"""Document a class using its __init__ function

This function sets the docstring of a class to be the __init__ function
(including the signature), rather than just the docstring of the __init__
function.
"""
if what != "class":
return
try:
if options["class-doc-from"] == "init":
lines[:] = [f".. autofunction:: {name}.__init__\n"]
except KeyError:
return


def setup(app):
"""Add custom behaviour to the build process"""
app.add_directive("autoclass", ExtendedAutodocDirective, override=True)
app.add_directive("autofunction", ExtendedAutodocDirective, override=True)
app.add_directive("automodule", ExtendedAutodocDirective, override=True)
app.connect("autodoc-process-docstring", document_class)
app.connect("autodoc-process-docstring", only_doc_once)
app.connect("autodoc-process-docstring", fix_overloads)
app.connect("autodoc-process-signature", change_sig)
Expand Down
4 changes: 1 addition & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@
"numpy": ("https://numpy.org/doc/stable/", None),
}

autodoc_default_options = {"show-inheritence": True}

autoclass_content = "both"
autoclass_content = "class"

doctest_global_setup = """from libsemigroups_pybind11 import ReportGuard
ReportGuard(False)"""
3 changes: 1 addition & 2 deletions docs/source/data-structures/adapters/imageleftaction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The ImageLeftAction class

.. autoclass:: ImageLeftAction
:doc-only:
:class-doc-from: class

Contents
--------
Expand All @@ -27,6 +26,6 @@ Full API
--------

.. autoclass:: ImageLeftAction
:members:
:class-doc-from: init
:special-members: __call__
:members:
3 changes: 1 addition & 2 deletions docs/source/data-structures/adapters/imagerightaction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The ImageRightAction class

.. autoclass:: ImageRightAction
:doc-only:
:class-doc-from: class

Contents
--------
Expand All @@ -27,6 +26,6 @@ Full API
--------

.. autoclass:: ImageRightAction
:members:
:class-doc-from: init
:special-members: __call__
:members:
2 changes: 1 addition & 1 deletion docs/source/data-structures/adapters/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ types.
.. toctree::
:maxdepth: 1

imagerightaction
imageleftaction
imagerightaction
4 changes: 1 addition & 3 deletions docs/source/data-structures/elements/bipart/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The Bipartition class

.. autoclass:: Bipartition
:doc-only:
:class-doc-from: class

Contents
--------
Expand All @@ -38,6 +37,5 @@ Full API
--------

.. autoclass:: Bipartition
:members:
:class-doc-from: init
:inherited-members:
:members:
4 changes: 1 addition & 3 deletions docs/source/data-structures/elements/blocks/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The Blocks class

.. autoclass:: Blocks
:doc-only:
:class-doc-from: class

Contents
--------
Expand All @@ -33,6 +32,5 @@ Full API
--------

.. autoclass:: Blocks
:members:
:class-doc-from: init
:inherited-members:
:members:
3 changes: 1 addition & 2 deletions docs/source/data-structures/elements/matrix/bmat8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The BMat8 class

.. autoclass:: BMat8
:doc-only:
:class-doc-from: class

Contents
--------
Expand All @@ -30,5 +29,5 @@ Full API
--------

.. autoclass:: BMat8
:members:
:class-doc-from: init
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ Full API
.. automodule:: libsemigroups_pybind11.matrix
:members:
:imported-members:
:exclude-members: Matrix, MatrixKind
5 changes: 1 addition & 4 deletions docs/source/data-structures/elements/matrix/matrix.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The Matrix class

.. autoclass:: Matrix
:doc-only:
:class-doc-from: class

MatrixKind
----------
Expand All @@ -28,7 +27,7 @@ Contents
.. autosummary::
:signatures: short

Matrix.__init__
~Matrix
Matrix.copy
Matrix.degree
Matrix.number_of_cols
Expand All @@ -48,5 +47,3 @@ Full API
.. autoclass:: Matrix
:class-doc-from: init
:members:
:inherited-members:
:exclude-members: py_template_params_from_cxx_obj, init_cxx_obj
4 changes: 1 addition & 3 deletions docs/source/data-structures/elements/pbr/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The PBR class

.. autoclass:: PBR
:doc-only:
:class-doc-from: class

Contents
--------
Expand All @@ -30,6 +29,5 @@ Full API
--------

.. autoclass:: PBR
:members:
:class-doc-from: init
:inherited-members:
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ The Perm class

.. autoclass:: Perm
:doc-only:
:class-doc-from: class

Contents
--------
Expand All @@ -29,6 +28,7 @@ Contents

~Perm
Perm.copy
Perm.degree
Perm.images
Perm.increase_degree_by
Perm.one
Expand All @@ -42,5 +42,3 @@ Full API
.. autoclass:: Perm
:class-doc-from: init
:members:
:inherited-members:
:exclude-members: init_cxx_obj, py_template_params_from_cxx_obj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The PPerm class

.. autoclass:: PPerm
:doc-only:
:class-doc-from: class

Contents
--------
Expand All @@ -35,5 +34,3 @@ Full API
.. autoclass:: PPerm
:class-doc-from: init
:members:
:inherited-members:
:exclude-members: init_cxx_obj, py_template_params_from_cxx_obj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The Transf class

.. autoclass:: Transf
:doc-only:
:class-doc-from: class

Contents
--------
Expand All @@ -35,5 +34,3 @@ Full API
.. autoclass:: Transf
:class-doc-from: init
:members:
:inherited-members:
:exclude-members: init_cxx_obj, py_template_params_from_cxx_obj
3 changes: 1 addition & 2 deletions docs/source/data-structures/misc/reporter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The Reporter class

.. autoclass:: Reporter
:doc-only:
:class-doc-from: class

Contents
--------
Expand All @@ -35,5 +34,5 @@ Full API
--------

.. autoclass:: Reporter
:members:
:class-doc-from: init
:members:
3 changes: 1 addition & 2 deletions docs/source/data-structures/misc/runner.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The Runner class

.. autoclass:: Runner
:doc-only:
:class-doc-from: class

Contents
--------
Expand Down Expand Up @@ -44,5 +43,5 @@ Full API
--------

.. autoclass:: Runner
:no-doc:
:class-doc-from: init
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The InversePresentation class

.. autoclass:: InversePresentation
:doc-only:
:class-doc-from: class

.. _pseudo_letter_type_inv_class:

Expand Down Expand Up @@ -46,5 +45,5 @@ Full API
.. currentmodule:: libsemigroups_pybind11

.. autoclass:: InversePresentation
:class-doc-from: init
:members:
:no-doc:
3 changes: 1 addition & 2 deletions docs/source/data-structures/presentations/present.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The Presentation class

.. autoclass:: Presentation
:doc-only:
:class-doc-from: class

.. _pseudo_letter_type_class:

Expand Down Expand Up @@ -56,5 +55,5 @@ Full API
--------

.. autoclass:: Presentation
:members:
:class-doc-from: init
:members:
5 changes: 3 additions & 2 deletions docs/source/data-structures/suffix-trees/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The Ukkonen class

.. autoclass:: Ukkonen
:doc-only:
:class-doc-from: class

Contents
--------
Expand Down Expand Up @@ -57,12 +56,14 @@ Full API
--------

.. autoclass:: libsemigroups_pybind11::Ukkonen.State
:class-doc-from: init
:members:

.. autoclass:: libsemigroups_pybind11::Ukkonen.Node
:class-doc-from: init
:members:

.. autoclass:: Ukkonen
:members:
:class-doc-from: init
:members:
:exclude-members: State, Node
3 changes: 1 addition & 2 deletions docs/source/data-structures/tries/class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The AhoCorasick class

.. autoclass:: AhoCorasick
:doc-only:
:class-doc-from: class

Contents
--------
Expand All @@ -37,5 +36,5 @@ Full API
--------

.. autoclass:: AhoCorasick
:members:
:class-doc-from: init
:members:
3 changes: 1 addition & 2 deletions docs/source/data-structures/visualisation/dot.edge.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ The Dot.Edge class
==================

.. autoclass:: libsemigroups_pybind11.Dot.Edge
:members:
:class-doc-from: class
:exclude-members: name
:members:
2 changes: 1 addition & 1 deletion docs/source/data-structures/visualisation/dot.kind.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ The Dot.Kind class
==================

.. autoclass:: libsemigroups_pybind11.Dot.Kind
:members:
:class-doc-from: class
:members:
:exclude-members: name
2 changes: 1 addition & 1 deletion docs/source/data-structures/visualisation/dot.node.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ The Dot.Node class
==================

.. autoclass:: libsemigroups_pybind11.Dot.Node
:members:
:class-doc-from: class
:members:
4 changes: 2 additions & 2 deletions docs/source/data-structures/visualisation/dot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ The Dot class

.. autoclass:: Dot
:doc-only:
:class-doc-from: class

Contents
--------

.. autosummary::
:signatures: short

~Dot
Dot.add_attr
Dot.add_edge
Dot.add_node
Expand All @@ -41,6 +41,6 @@ Full API
--------

.. autoclass:: Dot
:members:
:class-doc-from: init
:members:
:exclude-members: Kind, Node, Edge
4 changes: 1 addition & 3 deletions docs/source/data-structures/word-graph/forest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ The Forest class

.. autoclass:: Forest
:doc-only:
:class-doc-from: class

Contents
--------
Expand All @@ -37,6 +36,5 @@ Full API
--------

.. autoclass:: Forest
:members:
:show-inheritance:
:class-doc-from: init
:members:
Loading