Skip to content

Commit a0651c5

Browse files
Docs: Configuration file pages as explanation and reference (Diátaxis) (#10416)
* Scissor out and refine changes from #9921 * Polish intro sentences * Add how-to reference * Do some content updates. * Emoji ⚖️ * fix mini err * typo fix * typo fixes * Adds a seealso to v2 reference -- many people are visiting the reference directly (because we didn't have any other resources), should add the how-to --------- Co-authored-by: Eric Holscher <[email protected]>
1 parent aeee1ee commit a0651c5

File tree

4 files changed

+179
-31
lines changed

4 files changed

+179
-31
lines changed

docs/user/config-file/index.rst

Lines changed: 107 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,120 @@
1-
Configuration file
2-
==================
1+
Using a configuration file
2+
==========================
33

4-
In addition to using the admin panel of your project to configure your project,
5-
you can use a configuration file in the root of your project.
6-
The configuration file should be named ``.readthedocs.yaml``.
4+
Content and structure of documentation undergo big and small changes.
5+
And eventually, the configuration of a documentation project also changes.
6+
This means you need to be able to track these changes over time,
7+
and keep them up to date.
78

8-
.. note::
9+
In this article,
10+
we cover the major concepts of using a configuration file:
911

10-
Some other variants like ``readthedocs.yaml``, ``.readthedocs.yml``, etc
11-
are deprecated.
12+
Versioning the configuration
13+
A documentation project and its configuration file live together in a Git repository
14+
and are versioned together.
15+
16+
Configuration as code
17+
Configuration uses the same workflow as your source code,
18+
including being reviewed and tested in a Pull Request.
19+
20+
Options that are not found in the configuration file
21+
Not everything is suitable for version-specific configuration,
22+
like the Git repository where the configuration file is read after cloning.
23+
24+
.. seealso::
25+
26+
:doc:`/guides/setup/configuration-file`
27+
Practical steps to add a configuration file to your documentation project.
28+
29+
:doc:`/config-file/v2`
30+
Reference for configuration file settings.
31+
32+
33+
Why version your project's configuration?
34+
-----------------------------------------
35+
36+
Consider the following aspects of a documentation project:
37+
38+
Build environments change 📦️
39+
You may depend on a number of packages but your method for installing them changes.
40+
What is installed, how it's installed and what installs can change,
41+
especially across multiple versions.
42+
43+
You might change between Pip and Poetry.
44+
You might also jump between Python 2 and 3 or Python 3.8 and Python 3.10.
45+
46+
Documentation tools change ⚙️
47+
Using Sphinx? Using MkDocs? Or some other tool?
48+
All these tools have their own configuration files and special ways to invoke them.
49+
In order to switch between how you are invoking the tool and setting up its environment,
50+
you will need external build configuration.
51+
52+
Comparing changes over time ⚖️
53+
As your project changes, you will need to change your configuration.
54+
You might wonder how something was done in the past,
55+
and having it versioned means you can see each commit as it has changed.
56+
57+
You can configure your Read the Docs project by adding a ``.readthedocs.yaml`` file [1]_ to your Git repository.
58+
The configuration will apply to the exact version that is being built.
59+
This allows you to store different configurations for different versions of your documentation.
1260

1361
The main advantages of using a configuration file over the web interface are:
1462

1563
- Settings are per version rather than per project.
16-
- Settings live in your VCS.
64+
- Settings live in your Git repository.
1765
- They enable reproducible build environments over time.
1866
- Some settings are only available using a configuration file
1967

20-
.. tip::
68+
.. [1] Other variants of the configuration file name like ``readthedocs.yaml``, ``.readthedocs.yml``, etc. are deprecated.
69+
You may however, :doc:`configure a custom sub-folder </guides/setup/monorepo>`.
70+
71+
Configuration as Code
72+
---------------------
73+
74+
"Configuration as Code" is a concept where the configuration or settings of software is maintained in a Git repository as *code*.
75+
Contrast this with the approach where configuration is managed inside the software's own UI,
76+
making it hard to track changes, and copy settings to other projects.
77+
78+
Most users of Read the Docs will already be familiar with the concept since many popular tools already require you to store their configuration in your Git repository:
79+
80+
* Sphinx uses a ``conf.py`` file.
81+
* MkDocs uses a ``mkdocs.yaml`` file.
82+
* Python projects often have a ``requirements.txt`` or ``environment.yaml``.
83+
84+
Because of its fragility and uniqueness,
85+
the alternative to "Configuration as Code" is also often referred to as snowflake ❄️ configuration.
86+
Such configurations are hard to copy between projects and also hard to introspect for people without authorization to access the configuration UI.
87+
88+
*Configuration as code* is considered by many to be the easier option.
89+
It might seem harder to have to write the configuration code from scratch,
90+
but in order to use Read the Docs,
91+
you can usually start with a template and adapt it.
92+
93+
Read the Docs has chosen to offer as much configuration as possible through the usage of ``.readthedocs.yaml``.
94+
Our experience is that projects benefit from such a setup,
95+
and even when the benefits aren't obvious in the beginning of a project's lifecycle,
96+
they will emerge over time.
97+
98+
What's not covered by ``.readthedocs.yaml``?
99+
--------------------------------------------
100+
101+
There are a number of things that aren't possible to cover in the configuration file,
102+
which still belong in your project's Dashboard.
103+
104+
These configuration items are for instance:
105+
106+
Git settings
107+
Since the configuration file is stored in Git,
108+
it doesn't make sense that it would configure the Git setup.
109+
110+
Domain-level settings
111+
Since many settings apply to the domain a project is hosted on,
112+
they are configured for the project itself, and not a specific version.
21113

22-
Using a configuration file is the recommended way of using Read the Docs.
114+
The goal over time is to have everything that can be managed in a version-specific YAML file configured that way.
23115

24-
.. toctree::
25-
:maxdepth: 3
116+
.. seealso::
26117

27-
Version 2 <v2>
118+
:doc:`/guides/reproducible-builds`
119+
In addition to storing your configuration in Git,
120+
we also recommend special practices for making your builds resilient to changes in your software dependencies.

docs/user/config-file/v2.rst

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
Configuration file v2
2-
=====================
1+
Configuration file v2 (.readthedocs.yaml)
2+
=========================================
33

4-
Read the Docs supports configuring your documentation builds with a YAML file.
5-
The :doc:`configuration file <index>` must be in the root directory of your project
6-
and be named ``.readthedocs.yaml``.
4+
Read the Docs supports configuring your documentation builds with a configuration file.
5+
This file is named ``.readthedocs.yaml`` and should be placed in the top level of your Git repository.
6+
7+
The ``.readthedocs.yaml`` file can contain a number of settings that are not accessible through the Read the Docs website.
8+
9+
Because the file is stored in Git,
10+
the configuration will apply to the exact version that is being built.
11+
**This allows you to store different configurations for different versions of your documentation.**
712

8-
All options are applied to the version containing this file.
913
Below is an example YAML file which shows the most common configuration options:
1014

1115
.. tabs::
@@ -25,6 +29,12 @@ Below is an example YAML file which shows the most common configuration options:
2529
:caption: .readthedocs.yaml
2630

2731

32+
.. seealso::
33+
34+
:doc:`/guides/setup/configuration-file`
35+
Practical steps to add a configuration file to your documentation project.
36+
37+
2838
Supported settings
2939
------------------
3040

@@ -902,3 +912,23 @@ These settings aren't supported via the configuration file.
902912
* ``Show versions warning``
903913
* ``Privacy level``
904914
* ``Analytics code``
915+
916+
Custom paths for .readthedocs.yaml
917+
----------------------------------
918+
919+
In order to support *monorepo* layouts,
920+
it's possible to configure the path to where your ``.readthedocs.yaml`` is found.
921+
922+
Using this configuration makes it possible to create several Read the Docs projects pointing at the same Git repository.
923+
This is recommended for monorepo layouts that host several documentation projects in the same repository.
924+
925+
.. seealso::
926+
927+
:doc:`/guides/setup/monorepo`
928+
This guide explains how to use the configuration.
929+
930+
Previous version: v1
931+
--------------------
932+
933+
Version 1 is deprecated and using it is discouraged,
934+
view its reference here :doc:`/config-file/v1`.

docs/user/explanation/advanced.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Deep dive into Read the Docs
2+
============================
3+
4+
In this section,
5+
we explain some of the more specific or advanced concepts of writing documentation on Read the Docs.
6+
7+
⏩️ :doc:`/config-file/index`
8+
An explanation of the value of having a versioned configuration file for your project.
9+
10+
⏩️ :doc:`/subprojects`
11+
*Subprojects* are a flexible for gathering multiple projects under the same domain.
12+
13+
⏩️ :doc:`/localization`
14+
Learn more about multilingual documentation projects and how translation workflows are supported.
15+
16+
⏩️ :doc:`/downloadable-documentation`
17+
An introduction to adding downloadable files, like PDFs, that can be read offline.
18+
19+
⏩️ :doc:`/environment-variables`
20+
Environment variables can be used to make your documentation builds flexible and easy to customize.
21+
22+
.. toctree::
23+
:maxdepth: 2
24+
:hidden:
25+
26+
/config-file/index
27+
/subprojects
28+
/localization
29+
/downloadable-documentation
30+
/environment-variables

docs/user/index.rst

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ Read the Docs: documentation simplified
1919

2020
/choosing-a-site
2121
/integrations
22-
/downloadable-documentation
23-
/environment-variables
24-
/subprojects
25-
/localization
22+
/explanation/advanced
2623

2724
.. toctree::
2825
:maxdepth: 2
@@ -44,7 +41,7 @@ Read the Docs: documentation simplified
4441
:caption: 📚 Reference
4542

4643
/reference/features
47-
/config-file/index
44+
/config-file/v2
4845
/builds
4946
/build-customization
5047
/server-side-search/syntax
@@ -129,14 +126,12 @@ Get a high-level overview of our platform:
129126
💡 :doc:`/choosing-a-site`
130127
Learn about the differences between |org_brand| and |com_brand|.
131128

129+
💡 :doc:`/explanation/advanced`
130+
Get familiar with some of the more advanced topics of building and deploying documentation with Read the Docs.
131+
132132
💡 :doc:`All explanation articles </explanation/index>`
133133
Browser all our explanation articles.
134134

135-
.. TODO: This next item needs its article to be finished in a separate PR
136-
.. https://github.com/readthedocs/readthedocs.org/pull/10071
137-
.. TODO: 💡 Advanced topics: Deep-dive into Read the Docs
138-
.. Get familiar with some of the more advanced topics of building and deploying documentation with Read the Docs.
139-
140135

141136
How-to guides
142137
-------------
@@ -171,7 +166,7 @@ Here are a few of the most important reference docs:
171166
📚 :doc:`/reference/features`
172167
Overview of all the main features of Read the Docs.
173168

174-
📚 :doc:`/config-file/index`
169+
📚 :doc:`/config-file/v2`
175170
Information for our configuration file: ``.readthedocs.yaml``.
176171

177172
📚 :doc:`/builds`

0 commit comments

Comments
 (0)