Skip to content

Commit 253ee2e

Browse files
committed
Warn if there's no docstring for functions
1 parent 578efcb commit 253ee2e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/source/conf.py

Lines changed: 18 additions & 0 deletions
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,6 +168,21 @@ def autodoc_process_signature(
167168
return signature, return_annotation
168169

169170

171+
logger = getLogger("trio")
172+
173+
174+
def autodoc_process_docstring(
175+
app: Sphinx,
176+
what: str,
177+
name: str,
178+
obj: object,
179+
options: object,
180+
lines: list[str],
181+
) -> None:
182+
if not lines:
183+
logger.warning(f"{name} has no docstring")
184+
185+
170186
# XX hack the RTD theme until
171187
# https://github.com/rtfd/sphinx_rtd_theme/pull/382
172188
# is shipped (should be in the release after 0.2.4)
@@ -175,6 +191,8 @@ def autodoc_process_signature(
175191
def setup(app: Sphinx) -> None:
176192
app.add_css_file("hackrtd.css")
177193
app.connect("autodoc-process-signature", autodoc_process_signature)
194+
app.connect("autodoc-process-docstring", autodoc_process_docstring)
195+
178196
# After Intersphinx runs, add additional mappings.
179197
app.connect("builder-inited", add_intersphinx, priority=1000)
180198
app.connect("source-read", on_read_source)

0 commit comments

Comments
 (0)