13
13
from sphinx .ext .autosummary import Autosummary , get_documenter
14
14
from sphinx .locale import __
15
15
from sphinx .util import logging
16
- from sphinx .util .inspect import safe_getattr
16
+ from sphinx .util .inspect import safe_getattr , isstaticmethod
17
17
18
18
# from sphinx.directives import directive
19
19
logger = logging .getLogger (__name__ )
@@ -43,6 +43,7 @@ class AutoAutoSummary(Autosummary):
43
43
44
44
option_spec = {
45
45
"methods" : directives .unchanged ,
46
+ "static_methods" : directives .unchanged ,
46
47
"signals" : directives .unchanged ,
47
48
"enums" : directives .unchanged ,
48
49
"attributes" : directives .unchanged ,
@@ -76,7 +77,7 @@ def skip_member(doc, obj: Any, name: str, options, objtype: str) -> bool:
76
77
77
78
@staticmethod
78
79
def get_members (
79
- doc , obj , typ , options , include_public : list | None = None , signal = False , enum = False
80
+ doc , obj , typ , options , include_public : list | None = None , signal = False , enum = False , static = False
80
81
):
81
82
try :
82
83
if not include_public :
@@ -97,7 +98,11 @@ def get_members(
97
98
)
98
99
if skipped is True :
99
100
continue
100
- if typ == "attribute" :
101
+ if typ == "method" :
102
+ method_is_static = isstaticmethod (chobj , obj , name )
103
+ if method_is_static != static :
104
+ continue
105
+ elif typ == "attribute" :
101
106
if signal and not isinstance (chobj , PyQt5 .QtCore .pyqtSignal ):
102
107
continue
103
108
if not signal and isinstance (chobj , PyQt5 .QtCore .pyqtSignal ):
@@ -138,6 +143,12 @@ def run(self):
138
143
_ , rubric_elems = self .get_members (
139
144
self .state .document , c , "method" , self .options , ["__init__" ]
140
145
)
146
+ elif "static_methods" in self .options :
147
+ rubric_title = "Static Methods"
148
+ _ , rubric_elems = self .get_members (self .state .document , c ,
149
+ "method" ,
150
+ self .options ,
151
+ static = True )
141
152
elif "enums" in self .options :
142
153
rubric_title = "Enums"
143
154
_ , rubric_elems = self .get_members (
0 commit comments