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