Skip to content

Commit 9e70cda

Browse files
Docs: Refactor Reproducible Builds page (Diátaxis) (#10030)
* Docs: Refactor Reproducible Builds page This is mostly cleaning this page up and removing some repeat concepts. * Apply suggestions from code review Co-authored-by: Benjamin Balder Bach <[email protected]> * Apply suggestions from code review Co-authored-by: Benjamin Balder Bach <[email protected]> --------- Co-authored-by: Benjamin Balder Bach <[email protected]>
1 parent 7ff0025 commit 9e70cda

File tree

2 files changed

+43
-132
lines changed

2 files changed

+43
-132
lines changed

docs/user/config-file/v2.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ Configuration for Conda support.
294294
conda.environment
295295
`````````````````
296296

297-
The path to the Conda environment file, relative to the root of the project.
297+
The path to the Conda `environment file <https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html>`_, relative to the root of the project.
298298

299299
:Type: ``path``
300300
:Required: ``true``
+42-131
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,33 @@
11
Reproducible Builds
22
===================
33

4-
Your docs depend on tools and other dependencies to be built.
4+
Your documentation depends on a number of dependencies to be built.
55
If your docs don't have reproducible builds,
66
an update in a dependency can break your builds when least expected,
77
or make your docs look different from your local version.
8-
This guide will help you to keep your builds working over time, and in a reproducible way.
8+
This guide will help you to keep your builds working over time,
9+
so that you can focus on content.
910

1011
.. contents:: Contents
1112
:local:
1213
:depth: 3
1314

14-
Building your docs
15-
------------------
15+
Use a ``.readthedocs.yaml`` configuration file
16+
----------------------------------------------
1617

17-
To test your build process, you can build them locally in a clean environment
18-
(this is without any dependencies installed).
19-
Then you should make sure you are running those same steps on Read the Docs.
2018

21-
You can configure how your project is built from the web interface (:guilabel:`Admin` tab),
22-
or by :ref:`using a configuration file <guides/reproducible-builds:using a configuration file>` (recommended).
23-
If you aren't familiar with these tools, check our docs:
19+
We recommend using a :doc:`configuration file </config-file/v2>` to manage your documentation.
20+
Our config file *provides you per version settings*,
21+
and *those settings live in your Git repository*.
2422

25-
- :doc:`/intro/getting-started-with-sphinx`
26-
- :doc:`/intro/getting-started-with-mkdocs`
27-
- :doc:`/config-file/v2`
23+
This allows you to validate changes using :doc:`pull requests </pull-requests>`,
24+
and ensures that all your versions can be rebuilt from a reproducible configuration.
2825

29-
.. note::
26+
Use a requirements file for Python dependencies
27+
-----------------------------------------------
3028

31-
You can see the exact commands that are run on Read the Docs by going to the :guilabel:`Builds` tab of your project.
32-
33-
Using a configuration file
34-
--------------------------
35-
36-
If you use the web interface to configure your project,
37-
the options are applied to *all* versions and builds of your docs,
38-
and can be lost after changing them over time.
39-
Using a :doc:`configuration file </config-file/v2>` **provides you per version settings**,
40-
and **those settings live in your repository**.
29+
We recommend using a Pip :ref:`requirements file <pip:requirements-file-format>` or Conda :ref:`environment file <config-file/v2:conda.environment>` to pin Python dependencies.
30+
This ensures that top-level dependencies and extensions don't change.
4131

4232
A configuration file with explicit dependencies looks like this:
4333

@@ -68,130 +58,27 @@ A configuration file with explicit dependencies looks like this:
6858
sphinx_rtd_theme==1.1.1
6959
readthedocs-sphinx-search==0.1.1
7060
71-
Don't rely on implicit dependencies
72-
-----------------------------------
73-
74-
By default Read the Docs will install the tool you chose to build your docs,
75-
and other dependencies, this is done so new users can build their docs without much configuration.
76-
77-
We highly recommend not to assume these dependencies will always be present or that their versions won't change.
78-
Always declare your dependencies explicitly using a :ref:`configuration file <guides/reproducible-builds:using a configuration file>`,
79-
for example:
80-
81-
✅ Good:
82-
Your project is declaring the Python version explicitly,
83-
and its dependencies using a requirements file.
84-
85-
.. code-block:: yaml
86-
:caption: .readthedocs.yaml
87-
88-
version: 2
89-
90-
build:
91-
os: "ubuntu-22.04"
92-
tools:
93-
python: "3.11"
94-
95-
sphinx:
96-
configuration: docs/conf.py
97-
98-
python:
99-
install:
100-
- requirements: docs/requirements.txt
101-
102-
❌ Bad:
103-
Your project is relying on the default Python version and default installed dependencies.
104-
105-
.. code-block:: yaml
106-
:caption: .readthedocs.yaml
107-
108-
version: 2
109-
110-
sphinx:
111-
configuration: docs/conf.py
112-
113-
Pinning dependencies
114-
--------------------
115-
116-
As you shouldn't rely on implicit dependencies,
117-
you shouldn't rely on undefined versions of your dependencies.
118-
Some examples:
119-
120-
✅ Good:
121-
The specified versions will be used for all your builds,
122-
in all platforms, and won't be updated unexpectedly.
123-
124-
.. code-block::
125-
:caption: docs/requirements.txt
126-
127-
sphinx==5.3.0
128-
sphinx_rtd_theme==1.1.1
129-
readthedocs-sphinx-search==0.1.2
130-
131-
.. code-block:: yaml
132-
:caption: docs/environment.yaml
133-
134-
name: docs
135-
channels:
136-
- conda-forge
137-
- defaults
138-
dependencies:
139-
- sphinx==5.3.0
140-
- nbsphinx==0.8.10
141-
- pip:
142-
- sphinx_rtd_theme==1.1.1
143-
144-
❌ Bad:
145-
The latest or any other already installed version will be used,
146-
and your builds can fail or change unexpectedly any time.
147-
148-
.. code-block::
149-
:caption: docs/requirements.txt
150-
151-
sphinx
152-
sphinx_rtd_theme
153-
readthedocs-sphinx-search
154-
155-
.. code-block:: yaml
156-
:caption: docs/environment.yaml
157-
158-
name: docs
159-
channels:
160-
- conda-forge
161-
- defaults
162-
dependencies:
163-
- sphinx
164-
- nbsphinx
165-
- pip:
166-
- sphinx_rtd_theme
167-
168-
Check the `pip user guide`_ for more information about requirements files,
169-
or our Conda docs about :ref:`environment files <guides/conda:creating the \`\`environment.yml\`\`>`.
170-
171-
.. _`pip user guide`: https://pip.pypa.io/en/stable/user_guide/#requirements-files
172-
17361
.. tip::
17462

17563
Remember to update your docs' dependencies from time to time to get new improvements and fixes.
17664
It also makes it easy to manage in case a version reaches its end of support date.
17765

178-
179-
Pinning transitive dependencies
180-
-------------------------------
66+
Pin your transitive dependencies
67+
--------------------------------
18168

18269
Once you have pinned your own dependencies,
18370
the next things to worry about are the dependencies of your dependencies.
18471
These are called *transitive dependencies*,
18572
and they can upgrade without warning if you do not pin these packages as well.
18673

18774
We recommend `pip-tools`_ to help address this problem.
188-
It allows you to specify a ``requirements.in`` file with your first-level dependencies,
75+
It allows you to specify a ``requirements.in`` file with your top-level dependencies,
18976
and it generates a ``requirements.txt`` file with the full set of transitive dependencies.
19077

19178
.. _pip-tools: https://pip-tools.readthedocs.io/en/latest/
19279

19380
✅ Good:
194-
All your transitive dependencies will stay defined,
81+
All your transitive dependencies are defined,
19582
which ensures new package releases will not break your docs.
19683

19784
.. code-block::
@@ -252,3 +139,27 @@ and it generates a ``requirements.txt`` file with the full set of transitive dep
252139
# via sphinx
253140
urllib3==1.26.13
254141
# via requests
142+
143+
Check list ✅
144+
-------------
145+
146+
If you followed this guide,
147+
you have pinned:
148+
149+
* tool versions (Python, Node)
150+
* top-level dependencies (Sphinx, Sphinx extensions)
151+
* transitive dependencies (Pytz, Jinja2)
152+
153+
This will protect your builds from failures because of a random tool or dependency update.
154+
155+
You do still need to upgrade your dependencies from time to time,
156+
but you should do that on your own schedule.
157+
158+
.. seealso::
159+
160+
:doc:`/config-file/v2`
161+
Configuration file reference
162+
:doc:`/builds`
163+
Build process information
164+
:doc:`/build-customization`
165+
Customizing builds to do more

0 commit comments

Comments
 (0)