|
1 |
| -Configuration file |
2 |
| -================== |
| 1 | +Using a configuration file |
| 2 | +========================== |
3 | 3 |
|
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**. |
7 | 7 |
|
8 |
| -.. note:: |
| 8 | +In this article, |
| 9 | +we cover the major concepts that are applied in our configuration file: |
9 | 10 |
|
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. |
12 | 57 |
|
13 | 58 | The main advantages of using a configuration file over the web interface are:
|
14 | 59 |
|
15 | 60 | - Settings are per version rather than per project.
|
16 |
| -- Settings live in your VCS. |
| 61 | +- Settings live in your Git repository. |
17 | 62 | - They enable reproducible build environments over time.
|
18 | 63 | - Some settings are only available using a configuration file
|
19 | 64 |
|
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 |
21 | 110 |
|
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`. |
23 | 114 |
|
24 |
| -.. toctree:: |
25 |
| - :maxdepth: 3 |
| 115 | +.. seealso:: |
26 | 116 |
|
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. |
0 commit comments