Skip to content

Commit 37fce7a

Browse files
committed
Improve RTD and run Cog on docs build (#632)
1 parent 320e61a commit 37fce7a

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

.readthedocs.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
version: 2
33

44
build:
5-
os: ubuntu-22.04
5+
os: ubuntu-lts-latest
66
tools:
77
# Keep version in sync with tox.ini/docs and ci.yml/docs
88
python: "3.12"
9+
jobs:
10+
pre_build:
11+
- cog -rP docs/index.md
912

1013
python:
1114
install:

docs/conf.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@
33
# 2.0, and the MIT License. See the LICENSE file in the root of this
44
# repository for complete details.
55

6+
import os
7+
68
from importlib import metadata
79

810

11+
# Set canonical URL from the Read the Docs Domain
12+
html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "")
13+
14+
# Tell Jinja2 templates the build is running on Read the Docs
15+
if os.environ.get("READTHEDOCS", "") == "True":
16+
html_context = {"READTHEDOCS": True}
17+
918
# We want an image in the README and include the README in the docs.
1019
suppress_warnings = ["image.nonlocal_uri"]
1120

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Release **{sub-ref}`release`** ([What's new?](https://github.com/hynek/structlo
1212
```
1313

1414
<!-- [[[cog
15+
# This is mainly called from RTD's pre_build job!
16+
1517
import pathlib, tomllib, importlib.metadata
1618
1719
if "dev" in (version := importlib.metadata.version("structlog")):

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ tests = [
4848
# Otherwise mypy fails in tox.
4949
typing = ["mypy>=1.4", "rich", "twisted"]
5050
docs = [
51+
"cogapp",
5152
"furo",
5253
"myst-parser",
5354
"sphinx",

0 commit comments

Comments
 (0)