Skip to content

📚 Move the docs sources beside conf.py, so Read the Docs can build them - #104

Merged
chrisjsewell merged 1 commit into
mainfrom
prep/docs-layout-rtd
Sep 6, 2026
Merged

chrisjsewell merged 1 commit into
mainfrom
prep/docs-layout-rtd

Conversation

@chrisjsewell

Copy link
Copy Markdown
Member

docs/conf.py sits next to docs/source/**, and the build bridges the gap with
sphinx-build … -c docs docs/source docs/_build/html. Read the Docs has no -c. It takes
the directory of sphinx.configuration as the source directory, so it would build docs/ — a
directory containing one conf.py and no index — and produce nothing. This is the same
finding that reshaped sphinx-mounts' documentation before it was imported into the sphinx-needs
repository, and it is the reason this repository cannot move off GitHub Pages as it stands.

So docs/source/* moves up into docs/*, with git mv, so git log --follow and git blame
keep working; 23 files, all recorded as renames. The -c goes with it:
tox -e docs-clean now runs sphinx-build -nW --keep-going -b html docs docs/_build/html,
which is character for character what Read the Docs runs on its own. gh_pages.yml is untouched
— it uploads docs/_build/html, which has not moved — so Pages keeps working until someone
chooses to turn it off.

conf.py loses the source/ prefix from html_favicon, html_static_path, templates_path
and furo's source_directory. Because docs/ is now the source directory, the build output and
the shared ubproject.toml sit inside it, so exclude_patterns names them; the dead
templates_path = ["_templates"] line (overwritten twelve lines further down) goes at the same
time. quickstart.rst's two literalinclude paths lose one ../ — they were climbing out of
docs/source/basics/ to the repository root, and -nW fails on them otherwise.

The docs requirements become an extra rather than a dependency group. Read the Docs
installs extras — that is what python.install's extra_requirements is — and has no way at
all to install a PEP 735 group, so requirements in a group are simply unreachable from RTD. It
is also the shape a member of the sphinx-needs workspace has, where the root re-exports each
member's extra. The three tox environments that used the group switch to extras = docs.
furo stays in testing too, deliberately: tests/data/sphinx/conf.py sets
html_theme = "furo" and test_src_trace.py builds that project.

Finally, a .readthedocs.yaml at the repository root, modelled on the one sphinx-mounts
carries: ubuntu-24.04, python 3.13, fail_on_warning: true, and a pip install of . with the
docs extra. No apt_packages — these docs render no diagrams — and deliberately no
post_checkout skip job, which only earns its keep once several RTD projects build out of one
repository. Its header records that every path in it is relative to the repository root, so at
import they each gain a packages/sphinx-codelinks/ prefix.

How to verify

tox -e docs-clean
# and the RTD-shaped build, from nothing but the extra:
uv venv /tmp/cl-docs && uv pip install --python /tmp/cl-docs/bin/python '.[docs]'
/tmp/cl-docs/bin/sphinx-build -nW --keep-going -b html docs docs/_build/rtd
git diff --stat -M      # renames, not delete + add

Both builds are green locally (docs-clean 8 s; the RTD-shaped one exits 0).

Out of scope: creating the Read the Docs project itself and pointing
codelinks.useblocks.com at it (Chris/Marco, after the import); turning off the GitHub Pages
deployment; prefixing the historical tags; removing [dependency-groups], [tool.pytest] or
tests/__init__.py; the PyPI trusted publisher; release.yaml; the pre-commit → prek switch;
and any behaviour change to the extension.

@chrisjsewell
chrisjsewell requested a review from ubmarco September 6, 2026 06:17
ubmarco
ubmarco previously approved these changes Sep 6, 2026
`docs/conf.py` sat next to `docs/source/**`, and the build bridged the gap with
`sphinx-build ... -c docs docs/source docs/_build/html`. Read the Docs has no
`-c`: it builds `sphinx.configuration`'s directory as the source directory, so
it would take `docs/` -- a directory holding one `index`-less `conf.py` -- and
produce nothing. This is the same finding that reshaped sphinx-mounts' docs
before its import.

`docs/source/*` moves up to `docs/*` with `git mv`, so `git log --follow` and
`git blame` keep working, and the `-c` goes: `tox -e docs-clean` now runs
`sphinx-build -nW --keep-going -b html docs docs/_build/html`, which is
character for character what Read the Docs runs by itself. `gh_pages.yml` needs
no change -- it uploads `docs/_build/html`, which has not moved.

`conf.py` loses the `source/` prefix from `html_favicon`, `html_static_path`,
`templates_path` and furo's `source_directory`. With `docs/` as the source
directory, the build output and the shared `ubproject.toml` are now inside it,
so `exclude_patterns` names them (the dead `templates_path = ["_templates"]`
line one directive above it, overwritten further down the file, goes at the
same time). `quickstart.rst`'s two `literalinclude` paths lose one `../`; they
were reaching out of `docs/source/basics/` to the repository root, and without
the fix `-nW` fails on them.

The `docs` requirements move from a dependency group to a `docs` **extra**.
Read the Docs installs extras -- `python.install`'s `extra_requirements` -- and
has no way at all to install a PEP 735 group. It is also the shape a member of
the sphinx-needs workspace has, where the root re-exports each member's extra.
The tox docs environments follow, from `dependency_groups = docs` to
`extras = docs`. `furo` stays in `testing` as well: `tests/data/sphinx/conf.py`
sets `html_theme = "furo"` and `test_src_trace.py` builds that project.

A `.readthedocs.yaml` comes with it, modelled on sphinx-mounts': ubuntu-24.04,
python 3.13, `sphinx.configuration: docs/conf.py`, `fail_on_warning: true`, and
a pip install of `.` with the `docs` extra. Its paths are relative to the
repository root, and its header says so, because at import they gain a
`packages/sphinx-codelinks/` prefix. No `post_checkout` job: cancelling builds
for pull requests that miss the package only makes sense once several projects
build out of one repository.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.91%. Comparing base (1d06369) to head (35751b0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #104   +/-   ##
=======================================
  Coverage   92.91%   92.91%           
=======================================
  Files          44       44           
  Lines        3770     3770           
  Branches      381      381           
=======================================
  Hits         3503     3503           
  Misses        157      157           
  Partials      110      110           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chrisjsewell
chrisjsewell merged commit cc99601 into main Sep 6, 2026
13 checks passed
@chrisjsewell
chrisjsewell deleted the prep/docs-layout-rtd branch September 6, 2026 09:21
pull Bot pushed a commit to twodrops/sphinx-needs that referenced this pull request Sep 6, 2026
…em (useblocks/sphinx-codelinks#104)

`docs/conf.py` sits next to `docs/source/**`, and the build bridges the
gap with
`sphinx-build … -c docs docs/source docs/_build/html`. **Read the Docs
has no `-c`.** It takes
the directory of `sphinx.configuration` as the source directory, so it
would build `docs/` — a
directory containing one `conf.py` and no `index` — and produce nothing.
This is the same
finding that reshaped sphinx-mounts' documentation before it was
imported into the sphinx-needs
repository, and it is the reason this repository cannot move off GitHub
Pages as it stands.

So `docs/source/*` moves up into `docs/*`, with `git mv`, so `git log
--follow` and `git blame`
keep working; 23 files, all recorded as renames. The `-c` goes with it:
`tox -e docs-clean` now runs `sphinx-build -nW --keep-going -b html docs
docs/_build/html`,
which is character for character what Read the Docs runs on its own.
`gh_pages.yml` is untouched
— it uploads `docs/_build/html`, which has not moved — so Pages keeps
working until someone
chooses to turn it off.

`conf.py` loses the `source/` prefix from `html_favicon`,
`html_static_path`, `templates_path`
and furo's `source_directory`. Because `docs/` is now the source
directory, the build output and
the shared `ubproject.toml` sit inside it, so `exclude_patterns` names
them; the dead
`templates_path = ["_templates"]` line (overwritten twelve lines further
down) goes at the same
time. `quickstart.rst`'s two `literalinclude` paths lose one `../` —
they were climbing out of
`docs/source/basics/` to the repository root, and `-nW` fails on them
otherwise.

**The `docs` requirements become an extra rather than a dependency
group.** Read the Docs
installs extras — that is what `python.install`'s `extra_requirements`
is — and has no way at
all to install a PEP 735 group, so requirements in a group are simply
unreachable from RTD. It
is also the shape a member of the sphinx-needs workspace has, where the
root re-exports each
member's extra. The three tox environments that used the group switch to
`extras = docs`.
`furo` stays in `testing` too, deliberately: `tests/data/sphinx/conf.py`
sets
`html_theme = "furo"` and `test_src_trace.py` builds that project.

Finally, a **`.readthedocs.yaml`** at the repository root, modelled on
the one sphinx-mounts
carries: ubuntu-24.04, python 3.13, `fail_on_warning: true`, and a pip
install of `.` with the
`docs` extra. No `apt_packages` — these docs render no diagrams — and
deliberately no
`post_checkout` skip job, which only earns its keep once several RTD
projects build out of one
repository. Its header records that every path in it is relative to the
repository root, so at
import they each gain a `packages/sphinx-codelinks/` prefix.

**How to verify**

```
tox -e docs-clean
# and the RTD-shaped build, from nothing but the extra:
uv venv /tmp/cl-docs && uv pip install --python /tmp/cl-docs/bin/python '.[docs]'
/tmp/cl-docs/bin/sphinx-build -nW --keep-going -b html docs docs/_build/rtd
git diff --stat -M      # renames, not delete + add
```

Both builds are green locally (`docs-clean` 8 s; the RTD-shaped one
exits 0).

**Out of scope**: creating the Read the Docs project itself and pointing
`codelinks.useblocks.com` at it (Chris/Marco, after the import); turning
off the GitHub Pages
deployment; prefixing the historical tags; removing
`[dependency-groups]`, `[tool.pytest]` or
`tests/__init__.py`; the PyPI trusted publisher; `release.yaml`; the
pre-commit → prek switch;
and any behaviour change to the extension.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants