Skip to content

Commit

Permalink
Improve RTD and run Cog on docs build (#632)
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Jul 17, 2024
1 parent 81b1d44 commit d4ea660
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
version: 2

build:
os: ubuntu-22.04
os: ubuntu-lts-latest
tools:
# Keep version in sync with tox.ini/docs and ci.yml/docs
python: "3.12"
jobs:
pre_build:
- cog -rP docs/index.md

python:
install:
Expand Down
9 changes: 9 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@
# 2.0, and the MIT License. See the LICENSE file in the root of this
# repository for complete details.

import os

from importlib import metadata


# Set canonical URL from the Read the Docs Domain
html_baseurl = os.environ.get("READTHEDOCS_CANONICAL_URL", "")

# Tell Jinja2 templates the build is running on Read the Docs
if os.environ.get("READTHEDOCS", "") == "True":
html_context = {"READTHEDOCS": True}

# We want an image in the README and include the README in the docs.
suppress_warnings = ["image.nonlocal_uri"]

Expand Down
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Release **{sub-ref}`release`** ([What's new?](https://github.com/hynek/structlo
```

<!-- [[[cog
# This is mainly called from RTD's pre_build job!
import pathlib, tomllib, importlib.metadata
if "dev" in (version := importlib.metadata.version("structlog")):
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ tests = [
# Otherwise mypy fails in tox.
typing = ["mypy>=1.4", "rich", "twisted"]
docs = [
"cogapp",
"furo",
"myst-parser",
"sphinx",
Expand Down

0 comments on commit d4ea660

Please sign in to comment.