Skip to content

Commit

Permalink
docs: Improve decorator function autodocumentation
Browse files Browse the repository at this point in the history
- Add: `sphinx_toolbox.decorators` sphinx extension.
- Change: Patch `autodecorator` directive.

  Decorator functions at module are now automatically detected by the
  `automodule` directive.
  • Loading branch information
AnonymouX47 committed Sep 26, 2024
1 parent 9f016d8 commit 05d1439
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# For the full list of configuration options, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

from sphinx.ext.autodoc import DecoratorDocumenter, FunctionDocumenter
from sphinx_toolbox.collapse import CollapseNode
from sphinxcontrib import prettyspecialmethods

Expand All @@ -29,6 +30,7 @@
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"sphinx.ext.intersphinx",
"sphinx_toolbox.decorators",
"sphinx_toolbox.github",
"sphinx_toolbox.sidebar_links",
"sphinx_toolbox.more_autosummary",
Expand Down Expand Up @@ -144,6 +146,19 @@ def autodocssumm_grouper(app, what, name, obj, section, parent):
if isinstance(value, utils.ClassPropertyBase):
delattr(meta, attr)

# # -- autodecorator -------------------------------------------------------------


@classmethod
def can_document_member(cls, member, *args, **kwargs):
return hasattr(member, "_no_redecorate_wrapped_") and (
super(DecoratorDocumenter, cls).can_document_member(member, *args, **kwargs)
)


DecoratorDocumenter.priority = FunctionDocumenter.priority + 5
DecoratorDocumenter.can_document_member = can_document_member

# # -- prettyspecialmethods ------------------------------------------------------


Expand Down

0 comments on commit 05d1439

Please sign in to comment.