Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split static methods to own section in autosummary #159

Merged
merged 2 commits into from
Aug 14, 2024
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
23 changes: 20 additions & 3 deletions autoautosummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from sphinx.ext.autosummary import Autosummary, get_documenter
from sphinx.locale import __
from sphinx.util import logging
from sphinx.util.inspect import safe_getattr
from sphinx.util.inspect import isstaticmethod, safe_getattr

# from sphinx.directives import directive
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -43,6 +43,7 @@ class AutoAutoSummary(Autosummary):

option_spec = {
"methods": directives.unchanged,
"static_methods": directives.unchanged,
"signals": directives.unchanged,
"enums": directives.unchanged,
"attributes": directives.unchanged,
Expand Down Expand Up @@ -76,7 +77,14 @@ def skip_member(doc, obj: Any, name: str, options, objtype: str) -> bool:

@staticmethod
def get_members(
doc, obj, typ, options, include_public: list | None = None, signal=False, enum=False
doc,
obj,
typ,
options,
include_public: list | None = None,
signal=False,
enum=False,
static=False,
):
try:
if not include_public:
Expand All @@ -97,7 +105,11 @@ def get_members(
)
if skipped is True:
continue
if typ == "attribute":
if typ == "method":
method_is_static = isstaticmethod(chobj, obj, name)
if method_is_static != static:
continue
elif typ == "attribute":
if signal and not isinstance(chobj, PyQt5.QtCore.pyqtSignal):
continue
if not signal and isinstance(chobj, PyQt5.QtCore.pyqtSignal):
Expand Down Expand Up @@ -138,6 +150,11 @@ def run(self):
_, rubric_elems = self.get_members(
self.state.document, c, "method", self.options, ["__init__"]
)
elif "static_methods" in self.options:
rubric_title = "Static Methods"
_, rubric_elems = self.get_members(
self.state.document, c, "method", self.options, static=True
)
elif "enums" in self.options:
rubric_title = "Enums"
_, rubric_elems = self.get_members(
Expand Down
5 changes: 5 additions & 0 deletions rst/qgis_pydoc_template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ Class: $CLASS
:nosignatures:
:exclude-members: $EXCLUDE_METHODS

.. autoautosummary:: qgis.$PACKAGE.$CLASS
:static_methods:
:nosignatures:
:exclude-members: $EXCLUDE_METHODS

.. autoautosummary:: qgis.$PACKAGE.$CLASS
:signals:
:nosignatures:
Expand Down