Skip to content

Commit a19343d

Browse files
authored
Merge pull request #3222 from A5rocks/experiments/warn-no-docstring
Warn if there's no docstring for documented things
2 parents 0ea9328 + 2ccff05 commit a19343d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

docs/source/conf.py

+39
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from typing import TYPE_CHECKING, cast
2727

2828
from sphinx.util.inventory import _InventoryItem
29+
from sphinx.util.logging import getLogger
2930

3031
if TYPE_CHECKING:
3132
from sphinx.application import Sphinx
@@ -167,10 +168,48 @@ def autodoc_process_signature(
167168
return signature, return_annotation
168169

169170

171+
# currently undocumented things
172+
logger = getLogger("trio")
173+
UNDOCUMENTED = {
174+
"trio.CancelScope.relative_deadline",
175+
"trio.MemorySendChannel",
176+
"trio.MemoryReceiveChannel",
177+
"trio.MemoryChannelStatistics",
178+
"trio.SocketStream.aclose",
179+
"trio.SocketStream.receive_some",
180+
"trio.SocketStream.send_all",
181+
"trio.SocketStream.send_eof",
182+
"trio.SocketStream.wait_send_all_might_not_block",
183+
"trio._subprocess.HasFileno.fileno",
184+
"trio.lowlevel.ParkingLot.broken_by",
185+
}
186+
187+
188+
def autodoc_process_docstring(
189+
app: Sphinx,
190+
what: str,
191+
name: str,
192+
obj: object,
193+
options: object,
194+
lines: list[str],
195+
) -> None:
196+
if not lines:
197+
# TODO: document these and remove them from here
198+
if name in UNDOCUMENTED:
199+
return
200+
201+
logger.warning(f"{name} has no docstring")
202+
else:
203+
if name in UNDOCUMENTED:
204+
logger.warning("outdated list of undocumented things")
205+
206+
170207
def setup(app: Sphinx) -> None:
171208
# Add our custom styling to make our documentation better!
172209
app.add_css_file("styles.css")
173210
app.connect("autodoc-process-signature", autodoc_process_signature)
211+
app.connect("autodoc-process-docstring", autodoc_process_docstring)
212+
174213
# After Intersphinx runs, add additional mappings.
175214
app.connect("builder-inited", add_intersphinx, priority=1000)
176215
app.connect("source-read", on_read_source)

0 commit comments

Comments
 (0)