|
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,25 +168,55 @@ def autodoc_process_signature(
|
167 | 168 | return signature, return_annotation
|
168 | 169 |
|
169 | 170 |
|
170 |
| -# XX hack the RTD theme until |
171 |
| -# https://github.com/rtfd/sphinx_rtd_theme/pull/382 |
172 |
| -# is shipped (should be in the release after 0.2.4) |
173 |
| -# ...note that this has since grown to contain a bunch of other CSS hacks too |
174 |
| -# though. |
| 171 | +# currently undocumented things |
| 172 | +logger = getLogger("trio") |
| 173 | +UNDOCUMENTED = { |
| 174 | + "trio.MemorySendChannel", |
| 175 | + "trio.MemoryReceiveChannel", |
| 176 | + "trio.MemoryChannelStatistics", |
| 177 | + "trio.SocketStream.aclose", |
| 178 | + "trio.SocketStream.receive_some", |
| 179 | + "trio.SocketStream.send_all", |
| 180 | + "trio.SocketStream.send_eof", |
| 181 | + "trio.SocketStream.wait_send_all_might_not_block", |
| 182 | + "trio._subprocess.HasFileno.fileno", |
| 183 | + "trio.lowlevel.ParkingLot.broken_by", |
| 184 | +} |
| 185 | + |
| 186 | + |
| 187 | +def autodoc_process_docstring( |
| 188 | + app: Sphinx, |
| 189 | + what: str, |
| 190 | + name: str, |
| 191 | + obj: object, |
| 192 | + options: object, |
| 193 | + lines: list[str], |
| 194 | +) -> None: |
| 195 | + if not lines: |
| 196 | + # TODO: document these and remove them from here |
| 197 | + if name in UNDOCUMENTED: |
| 198 | + return |
| 199 | + |
| 200 | + logger.warning(f"{name} has no docstring") |
| 201 | + else: |
| 202 | + if name in UNDOCUMENTED: |
| 203 | + logger.warning( |
| 204 | + f"outdated list of undocumented things in docs/source/conf.py: {name!r} has a docstring" |
| 205 | + ) |
| 206 | + |
| 207 | + |
175 | 208 | def setup(app: Sphinx) -> None:
|
176 |
| - app.add_css_file("hackrtd.css") |
| 209 | + # Add our custom styling to make our documentation better! |
| 210 | + app.add_css_file("styles.css") |
177 | 211 | app.connect("autodoc-process-signature", autodoc_process_signature)
|
| 212 | + app.connect("autodoc-process-docstring", autodoc_process_docstring) |
| 213 | + |
178 | 214 | # After Intersphinx runs, add additional mappings.
|
179 | 215 | app.connect("builder-inited", add_intersphinx, priority=1000)
|
180 | 216 | app.connect("source-read", on_read_source)
|
181 | 217 |
|
182 | 218 |
|
183 |
| -# Our docs use the READTHEDOCS variable, so copied from: |
184 |
| -# https://about.readthedocs.com/blog/2024/07/addons-by-default/ |
185 |
| -if os.environ.get("READTHEDOCS", "") == "True": |
186 |
| - if "html_context" not in globals(): |
187 |
| - html_context = {} |
188 |
| - html_context["READTHEDOCS"] = True |
| 219 | +html_context = {"current_version": os.environ.get("READTHEDOCS_VERSION_NAME")} |
189 | 220 |
|
190 | 221 | # -- General configuration ------------------------------------------------
|
191 | 222 |
|
@@ -375,6 +406,7 @@ def add_mapping(
|
375 | 406 | "navigation_depth": 4,
|
376 | 407 | "logo_only": True,
|
377 | 408 | "prev_next_buttons_location": "both",
|
| 409 | + "style_nav_header_background": "#d2e7fa", |
378 | 410 | }
|
379 | 411 |
|
380 | 412 | # Add any paths that contain custom static files (such as style sheets) here,
|
|
0 commit comments