|
26 | 26 | from typing import TYPE_CHECKING, cast
|
27 | 27 |
|
28 | 28 | from sphinx.util.inventory import _InventoryItem
|
| 29 | +from sphinx.util.logging import getLogger |
29 | 30 |
|
30 | 31 | if TYPE_CHECKING:
|
31 | 32 | from sphinx.application import Sphinx
|
@@ -167,10 +168,48 @@ def autodoc_process_signature(
|
167 | 168 | return signature, return_annotation
|
168 | 169 |
|
169 | 170 |
|
| 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 | + |
170 | 207 | def setup(app: Sphinx) -> None:
|
171 | 208 | # Add our custom styling to make our documentation better!
|
172 | 209 | app.add_css_file("styles.css")
|
173 | 210 | app.connect("autodoc-process-signature", autodoc_process_signature)
|
| 211 | + app.connect("autodoc-process-docstring", autodoc_process_docstring) |
| 212 | + |
174 | 213 | # After Intersphinx runs, add additional mappings.
|
175 | 214 | app.connect("builder-inited", add_intersphinx, priority=1000)
|
176 | 215 | app.connect("source-read", on_read_source)
|
|
0 commit comments