-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement multiple .readthedocs.yml files per repo (#10001)
* initial work at multiple .readthedocs.yml files per repo * darker * Updates: Rename new field to build_config_file, add on Build and Version data, relax user input validation, introduce very basic reproducibility of builds * Fix for test failures * Fix up tests to expect no build_config_file when default is used * Trimming down the scope by not storing a Version.build_config_path * DDD = Documentation-driven-development: Adding the first draft for a how-to before moving on :) * How-to: Rephrase bad intro * Basic test that a custom path is applied and loaded, default is then ignored * Test that a project-defined build config is read by build tasks * Validate properly in clean_conf_py_file * Validate input, check that we can also handle non-yaml extensions, add test case for Advanced Project page * Handle unrelated linting errors * Update migration * New validation for build config file * Don't fix clean_conf_py_file * Update help_text and test case name * Apply suggestions from @ericholscher's code review Co-authored-by: Eric Holscher <[email protected]> * Disable fetching per-build build_config_file + clarify logic about reproduciblity * New validator, configurable with allowed file names and no regex @humitos :) * Update readthedocs/doc_builder/director.py Co-authored-by: Manuel Kaufmann <[email protected]> * Use new validator on model fields and add database assertion on view test * Swap around if condition blocks * Apply suggestions from @humitos code review Co-authored-by: Manuel Kaufmann <[email protected]> * Update docs/user/guides/setup/monorepo.rst * Improve "next steps" * Unrelated: Fix breakage from similar issue as executablebooks/MyST-Parser#731 * I have no idea about why pre-commit in Circle CI wants this and my local conf does. The line is not > 100 chars! * Update migrations + refactor validator, it wasn't serializable for the migration introspect * Add a seealso for subprojects * Refactor build_config_file=>readthedocs_yaml_path, config_file=>readthedocs_yaml_path * Remove view test from projecs/tests/test_views, this module seems to be mis-located, mosts tests are in rtd_tests * Anohter renaming fix config_file=>readthedocs_yaml_path * Improve help text * Fix a strange formulation in docs * Mark validators as safe strings * Clarify paths that are tested wrt. validation * Update readthedocs/doc_builder/director.py Co-authored-by: Manuel Kaufmann <[email protected]> * Removing pattern from a more generic validator * Add link to Wikipedia definition * Mention ability to use different documentation tools. Clarify introduction text, don't say "nested". * Arrested Software Development: Hello darker my old friend, you've come to talk with me again --------- Co-authored-by: Benjamin Bach <[email protected]> Co-authored-by: Benjamin Bach <[email protected]> Co-authored-by: Benjamin Balder Bach <[email protected]> Co-authored-by: Eric Holscher <[email protected]> Co-authored-by: Manuel Kaufmann <[email protected]>
- Loading branch information
1 parent
0c614d1
commit 758b2b9
Showing
24 changed files
with
650 additions
and
80 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
.. Next steps: Show an example pattern for a monorepo layout or link to an example project | ||
How to use a .readthedocs.yaml file in a sub-folder | ||
=================================================== | ||
|
||
This guide shows how to configure a Read the Docs project to use a custom path for the ``.readthedocs.yaml`` build configuration. | ||
`Monorepos <https://en.wikipedia.org/wiki/Monorepo>`__ that have multiple documentation projects in the same Git repository can benefit from this feature. | ||
|
||
By default, | ||
Read the Docs will use the ``.readthedocs.yaml`` at the top level of your Git repository. | ||
But if a Git repository contains multiple documentation projects that need different build configurations, | ||
you will need to have a ``.readthedocs.yaml`` file in multiple sub-folders. | ||
|
||
.. seealso:: | ||
|
||
`sphinx-multiproject <https://sphinx-multiproject.readthedocs.io/en/latest/>`__ | ||
If you are only using Sphinx projects and want to share the same build configuration, | ||
you can also use the ``sphinx-multiproject`` extension. | ||
|
||
:doc:`/guides/environment-variables` | ||
You might also be able to reuse the same configuration file across multiple projects, | ||
using only environment variables. | ||
This is possible if the configuration pattern is very similar and the documentation tool is the same. | ||
|
||
Implementation considerations | ||
----------------------------- | ||
|
||
This feature is currently *project-wide*. | ||
A custom build configuration file path is applied to all versions of your documentation. | ||
|
||
.. warning:: | ||
|
||
Changing the configuration path will apply to all versions. | ||
Different versions of the project may not be able to build again if this path is changed. | ||
|
||
Adding an additional project from the same repository | ||
----------------------------------------------------- | ||
|
||
Once you have added the first project from the :ref:`Import Wizard <intro/import-guide:Automatically import your docs>`, | ||
it will show as if it has already been imported and cannot be imported again. | ||
In order to add another project with the same repository, | ||
you will need to use the :ref:`Manual Import <intro/import-guide:Manually import your docs>`. | ||
|
||
Setting the custom build configuration file | ||
------------------------------------------- | ||
|
||
Once you have added a Git repository to a project that needs a custom configuration file path, | ||
navigate to :menuselection:`Admin --> Advanced Settings` and add the path to the :guilabel:`Build configuration file` field. | ||
|
||
.. image:: /img/screenshot-howto-build-configuration-file.png | ||
:alt: Screenshot of where to find the :guilabel:`Build configuration file` setting. | ||
|
||
After pressing :guilabel:`Save`, | ||
you need to ensure that relevant versions of your documentation are built again. | ||
|
||
.. tip:: | ||
|
||
Having multiple different build configuration files can be complex. | ||
We recommend setting up 1-2 projects in your Monorepo and getting them to build and publish successfully before adding additional projects to the equation. | ||
|
||
Next steps | ||
---------- | ||
|
||
Once you have your monorepo pattern implemented and tested and it's ready to roll out to all your projects, | ||
you should also consider the Read the Docs project setup for these individual projects. | ||
|
||
Having individual projects gives you the full flexibility of the Read the Docs platform to make individual setups for each project. | ||
|
||
For each project, it's now possible to configure: | ||
|
||
* Sets of maintainers (or :doc:`organizations </commercial/organizations>` on |com_brand|) | ||
* :doc:`Custom redirect rules </guides/custom-domains>` | ||
* :doc:`Custom domains </guides/custom-domains>` | ||
* :doc:`Automation rules </automation-rules>` | ||
* :doc:`Traffic and search analytics </reference/analytics>` | ||
* Additional documentation tools with individual :doc:`build processes </build-customization>`: | ||
One project might use :doc:`Sphinx <sphinx:index>`, | ||
while another project setup might use `Asciidoctor <https://asciidoctor.org/>`__. | ||
|
||
...and much more. *All* settings for a Read the Docs project is available for each individual project. | ||
|
||
.. seealso:: | ||
|
||
:doc:`/guides/subprojects` | ||
More information on nesting one project inside another project. | ||
In this setup, it is still possible to use the same monorepo for each subproject. | ||
|
||
Other tips | ||
---------- | ||
|
||
For a monorepo, | ||
it's not desirable to have changes in unrelated sub-folders trigger new builds. | ||
|
||
Therefore, | ||
you should consider setting up :ref:`conditional build cancellation rules <build-customization:Cancel build based on a condition>`. | ||
The configuration is added in each ``.readthedocs.yaml``, | ||
making it possible to write one conditional build rules per documentation project in the Monorepo 💯️ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
readthedocs/builds/migrations/0050_build_readthedocs_yaml_path.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 3.2.18 on 2023-04-04 13:03 | ||
|
||
from django.db import migrations, models | ||
|
||
import readthedocs.projects.validators | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("builds", "0049_automation_rule_copy"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="build", | ||
name="readthedocs_yaml_path", | ||
field=models.CharField( | ||
blank=True, | ||
default=None, | ||
max_length=1024, | ||
null=True, | ||
validators=[readthedocs.projects.validators.validate_build_config_file], | ||
verbose_name="Custom build configuration file path used in this build", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.