Skip to content

Commit 096e292

Browse files
committed
Scissor out and refine changes from #9921
1 parent e32efc0 commit 096e292

File tree

4 files changed

+178
-30
lines changed

4 files changed

+178
-30
lines changed

β€Ždocs/user/config-file/index.rst

Lines changed: 106 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,119 @@
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+
The lifecycle of a documentation project changes both the content and the structure of the documentation.
5+
In addition to this,
6+
**the whole configuration of a project also changes**.
77

8-
.. note::
8+
In this article,
9+
we cover the major concepts that are applied in our configuration file:
910

10-
Some other variants like ``readthedocs.yaml``, ``.readthedocs.yml``, etc
11-
are deprecated.
11+
Versioning the configuration
12+
When the documentation project changes,
13+
its configuration often changes alongside.
14+
15+
Configuration as code
16+
A commonly used term which is good to know the background and meaning of.
17+
18+
Options that are **not** found in the configuration file
19+
Not everything is suitable for *configuration as code*.
20+
21+
.. TODO: Add upcoming configuration file how-to
22+
23+
.. seealso::
24+
25+
:doc:`/config-file/v2`
26+
Reference of all the settings offered in the build configuration file.
27+
28+
Why version your project's configuration?
29+
-----------------------------------------
30+
31+
Consider the following aspects of a documentation project:
32+
33+
Build environments change πŸ“¦οΈ
34+
You may depend on a number of packages but your method for installing them changes.
35+
What is installed, how it's installed and what installs it can change.
36+
37+
For instance,
38+
you might change between Pip, Pipenv, Conda etc.
39+
You might also jump between Python 2 and 3 or Python 3.8 and Python 3.10.
40+
41+
Documentation tool setups change βš™οΈ
42+
Using Sphinx? Using MkDocs? Or some other tool?
43+
All these tools have their own configuration files and special ways to invoke them.
44+
In order to switch between how you are invoking the tool and setting up its environment,
45+
you will need external build configuration.
46+
47+
Switching documentation tools πŸ’£οΈ
48+
Long-lived software projects can go through many phases in their history.
49+
This includes changing the documentation tool.
50+
51+
52+
You can configure your Read the Docs project by adding a special file ``.readthedocs.yaml`` [1]_ to your Git repository.
53+
54+
Because the file is stored in Git,
55+
the configuration will apply to the exact version that is being built.
56+
This allows you to store different configurations for different versions of your documentation.
1257

1358
The main advantages of using a configuration file over the web interface are:
1459

1560
- Settings are per version rather than per project.
16-
- Settings live in your VCS.
61+
- Settings live in your Git repository.
1762
- They enable reproducible build environments over time.
1863
- Some settings are only available using a configuration file
1964

20-
.. tip::
65+
.. [1] Other variants of the configuration file name like ``readthedocs.yaml``, ``.readthedocs.yml``, etc. are deprecated.
66+
You may however, :doc:`configure a custom sub-folder </guides/setup/monorepo>`.
67+
68+
Configuration as Code
69+
---------------------
70+
71+
"Configuration as Code" is a concept whereby the configuration or settings of software is maintained in a Git repository as *code*.
72+
Alternatively, configurations are often added and managed inside the software's own UI,
73+
making it hard to track changes, and reproduce and copy behavior to other projects.
74+
75+
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:
76+
77+
* Sphinx uses a ``conf.py`` file.
78+
* MkDocs uses a ``mkdocs.yaml`` file.
79+
* Python projects in general have a ``requirements.txt`` or similar.
80+
81+
Because of its fragility and uniqueness,
82+
the alternative to "Configuration as Code" is also often referred to as snowflake ❄️ configuration.
83+
Such configurations are hard to copy between projects and also hard to introspect for people without authorization to access the configuration UI.
84+
85+
86+
Expressing a configuration *as code* is therefore considered by many to be the easier option.
87+
It might seem harder to have to write the configuration code from scratch,
88+
but in order to use Read the Docs,
89+
you can usually start by copy-pasting a template and adapting it.
90+
91+
Read the Docs has chosen to offer as much configuration as possible through the usage of ``.readthedocs.yaml``.
92+
Our experience is that projects benefit from such a setup,
93+
and even when the benefits aren't obvious in the beginning of a project's lifecycle,
94+
they will emerge over time.
95+
96+
What's not covered by ``.readthedocs.yaml``?
97+
--------------------------------------------
98+
99+
There are a number of things that aren't possible to cover in the configuration file,
100+
which still belong in your project's Dashboard.
101+
102+
These configuration items are for instance:
103+
104+
Git settings
105+
Since the configuration file is stored in Git,
106+
it doesn't make sense that it would configure the Git setup.
107+
108+
Custom domains and redirects
109+
Settings
21110

22-
Using a configuration file is the recommended way of using Read the Docs.
111+
Other general non-versioned settings
112+
In general,
113+
settings that aren't versioned and do not relate to how your project is built are accessed via your :term:`dashboard`.
23114

24-
.. toctree::
25-
:maxdepth: 3
115+
.. seealso::
26116

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

β€Ždocs/user/config-file/v2.rst

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

44
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``.
5+
It's required to be named ``.readthedocs.yaml`` and be placed in the root of your Git repository.
6+
7+
The 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::
@@ -946,3 +950,23 @@ These settings aren't supported via the configuration file.
946950
* ``Show versions warning``
947951
* ``Privacy level``
948952
* ``Analytics code``
953+
954+
Custom sub-folder for .readthedocs.yaml
955+
---------------------------------------
956+
957+
In order to support *monorepo* layouts,
958+
it's possible to configure the sub-folder where your ``.readthedocs.yaml`` is found.
959+
960+
Using this configuration makes it possible to create several Read the Docs projects pointing at the same Git repository.
961+
This is recommended for monorepo layouts that host several documentation projects in the same repository.
962+
963+
.. seealso::
964+
965+
:doc:`/guides/setup/monorepo`
966+
This guide explains how to use the configuration.
967+
968+
Previous version: v1
969+
--------------------
970+
971+
Version 1 is deprecated and using it is discouraged,
972+
view its reference here :doc:`/config-file/v2`.

β€Ždocs/user/explanation/advanced.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
The lifecycle of a documentation project changes the content and the structure of the documentation.
9+
In addition to this,
10+
the whole configuration of a project also changes.
11+
In this article,
12+
we explain some of the fundamental purposes of having a configuration file.
13+
14+
⏩️ :doc:`/subprojects`
15+
Thinking about gathering several documentation projects under the same umbrella?
16+
This is a common need, and using *subprojects* is a flexible option that is recommended for most cases.
17+
18+
⏩️ :doc:`/localization`
19+
Learn more about multilingual documentation projects and how translation workflows are supported.
20+
21+
⏩️ :doc:`/downloadable-documentation`
22+
An introduction to adding downloadable files that can be read offline to your documentation and keep them versioned.
23+
24+
⏩️ :doc:`/environment-variables`
25+
Environment variables can be used to make your documentation builds flexible and easy to customize.
26+
This is a general introduction to environment variables on our platform, both pre-defined and custom environment variables.
27+
28+
29+
.. toctree::
30+
:maxdepth: 2
31+
:hidden:
32+
33+
/config-file/index
34+
/subprojects
35+
/localization
36+
/downloadable-documentation
37+
/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)