Skip to content

Commit 532da81

Browse files
committed
Improve member detection in autoapi directives
1 parent f22ddbf commit 532da81

File tree

4 files changed

+30
-21
lines changed

4 files changed

+30
-21
lines changed

docs/reST/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929

3030
autoapi_dirs = [
31-
pathlib.Path(os.path.abspath(".")).parent.parent / 'buildconfig' / 'stubs' / 'pygame' / '',
32-
pathlib.Path(os.path.abspath(".")).parent.parent / 'src_py' / '',
31+
pathlib.Path('.').resolve().parent.parent / 'buildconfig' / 'stubs' / 'pygame',
32+
pathlib.Path('.').resolve().parent.parent / 'src_py',
3333
]
3434

3535
autoapi_options = ['members', 'undoc-members']

docs/reST/ext/documenters.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,39 @@ def build_signatures(object):
4646
yield f"| :sg:`{name}({arg_string}) -> {ret}`"
4747

4848

49+
def get_doc(env, obj):
50+
if obj.docstring:
51+
return obj.docstring
52+
53+
# If we don't already have docs, check if a python implementation exists of this
54+
# module and return its docstring if it does
55+
python_object = env.autoapi_all_objects.get(
56+
obj.id.replace("pygame", "src_py"), None
57+
)
58+
if python_object is not None:
59+
return python_object.docstring
60+
61+
return ""
62+
63+
4964
class AutopgDocumenter(autoapi.documenters.AutoapiDocumenter):
5065
def format_signature(self, **kwargs):
5166
return ""
5267

5368
def get_doc(self, encoding=None, ignore=1):
54-
if self.object.docstring:
55-
return super().get_doc(encoding, ignore)
56-
57-
# If we don't already have docs, check if a python implementation exists of this
58-
# module and return its docstring if it does
59-
python_object = self.env.autoapi_all_objects.get(
60-
self.object.id.replace("pygame", "src_py"), None
69+
return [get_doc(self.env, self.object).splitlines()]
70+
71+
def get_object_members(self, want_all):
72+
members_check_module, members = super().get_object_members(want_all)
73+
members = (
74+
member
75+
for member in members
76+
if not member.object.obj.get("hide", False)
77+
and not member.object.imported
78+
and get_doc(self.env, member.object) != ""
6179
)
62-
if python_object is not None:
63-
return [python_object.docstring.splitlines()]
6480

65-
return [""]
81+
return members_check_module, members
6682

6783
def process_doc(self, docstrings):
6884
for docstring in docstrings:

docs/reST/ref/cursors.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
=====================
55

66
.. autopgmodule:: pygame.cursors
7-
:members: compile, load_xbm
8-
9-
10-
.. autopgclass:: Cursor
11-
:members: copy, type, data
7+
:members:
128

139
Example code for creating and settings cursors. (Click the mouse to switch cursor)
1410

docs/reST/ref/time.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@
44
==================
55

66
.. autopgmodule:: pygame.time
7-
:members: get_ticks, wait, delay, set_timer
8-
9-
.. autopgclass:: Clock
10-
:members: tick, tick_busy_loop, get_time, get_rawtime, get_fps
7+
:members:

0 commit comments

Comments
 (0)