|
| 1 | +.. Next steps: Show an example pattern for a monorepo layout or link to an example project |
| 2 | +
|
| 3 | +How to use a .readthedocs.yaml file in a sub-folder |
| 4 | +=================================================== |
| 5 | + |
| 6 | +This guide shows how to configure a Read the Docs project to use a custom path for the ``.readthedocs.yaml`` build configuration. |
| 7 | +`Monorepos <https://en.wikipedia.org/wiki/Monorepo>`__ that have multiple documentation projects in the same Git repository can benefit from this feature. |
| 8 | + |
| 9 | +By default, |
| 10 | +Read the Docs will use the ``.readthedocs.yaml`` at the top level of your Git repository. |
| 11 | +But if a Git repository contains multiple documentation projects that need different build configurations, |
| 12 | +you will need to have a ``.readthedocs.yaml`` file in multiple sub-folders. |
| 13 | + |
| 14 | +.. seealso:: |
| 15 | + |
| 16 | + `sphinx-multiproject <https://sphinx-multiproject.readthedocs.io/en/latest/>`__ |
| 17 | + If you are only using Sphinx projects and want to share the same build configuration, |
| 18 | + you can also use the ``sphinx-multiproject`` extension. |
| 19 | + |
| 20 | + :doc:`/guides/environment-variables` |
| 21 | + You might also be able to reuse the same configuration file across multiple projects, |
| 22 | + using only environment variables. |
| 23 | + This is possible if the configuration pattern is very similar and the documentation tool is the same. |
| 24 | + |
| 25 | +Implementation considerations |
| 26 | +----------------------------- |
| 27 | + |
| 28 | +This feature is currently *project-wide*. |
| 29 | +A custom build configuration file path is applied to all versions of your documentation. |
| 30 | + |
| 31 | +.. warning:: |
| 32 | + |
| 33 | + Changing the configuration path will apply to all versions. |
| 34 | + Different versions of the project may not be able to build again if this path is changed. |
| 35 | + |
| 36 | +Adding an additional project from the same repository |
| 37 | +----------------------------------------------------- |
| 38 | + |
| 39 | +Once you have added the first project from the :ref:`Import Wizard <intro/import-guide:Automatically import your docs>`, |
| 40 | +it will show as if it has already been imported and cannot be imported again. |
| 41 | +In order to add another project with the same repository, |
| 42 | +you will need to use the :ref:`Manual Import <intro/import-guide:Manually import your docs>`. |
| 43 | + |
| 44 | +Setting the custom build configuration file |
| 45 | +------------------------------------------- |
| 46 | + |
| 47 | +Once you have added a Git repository to a project that needs a custom configuration file path, |
| 48 | +navigate to :menuselection:`Admin --> Advanced Settings` and add the path to the :guilabel:`Build configuration file` field. |
| 49 | + |
| 50 | +.. image:: /img/screenshot-howto-build-configuration-file.png |
| 51 | + :alt: Screenshot of where to find the :guilabel:`Build configuration file` setting. |
| 52 | + |
| 53 | +After pressing :guilabel:`Save`, |
| 54 | +you need to ensure that relevant versions of your documentation are built again. |
| 55 | + |
| 56 | +.. tip:: |
| 57 | + |
| 58 | + Having multiple different build configuration files can be complex. |
| 59 | + 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. |
| 60 | + |
| 61 | +Next steps |
| 62 | +---------- |
| 63 | + |
| 64 | +Once you have your monorepo pattern implemented and tested and it's ready to roll out to all your projects, |
| 65 | +you should also consider the Read the Docs project setup for these individual projects. |
| 66 | + |
| 67 | +Having individual projects gives you the full flexibility of the Read the Docs platform to make individual setups for each project. |
| 68 | + |
| 69 | +For each project, it's now possible to configure: |
| 70 | + |
| 71 | +* Sets of maintainers (or :doc:`organizations </commercial/organizations>` on |com_brand|) |
| 72 | +* :doc:`Custom redirect rules </guides/custom-domains>` |
| 73 | +* :doc:`Custom domains </guides/custom-domains>` |
| 74 | +* :doc:`Automation rules </automation-rules>` |
| 75 | +* :doc:`Traffic and search analytics </reference/analytics>` |
| 76 | +* Additional documentation tools with individual :doc:`build processes </build-customization>`: |
| 77 | + One project might use :doc:`Sphinx <sphinx:index>`, |
| 78 | + while another project setup might use `Asciidoctor <https://asciidoctor.org/>`__. |
| 79 | + |
| 80 | +...and much more. *All* settings for a Read the Docs project is available for each individual project. |
| 81 | + |
| 82 | +.. seealso:: |
| 83 | + |
| 84 | + :doc:`/guides/subprojects` |
| 85 | + More information on nesting one project inside another project. |
| 86 | + In this setup, it is still possible to use the same monorepo for each subproject. |
| 87 | + |
| 88 | +Other tips |
| 89 | +---------- |
| 90 | + |
| 91 | +For a monorepo, |
| 92 | +it's not desirable to have changes in unrelated sub-folders trigger new builds. |
| 93 | + |
| 94 | +Therefore, |
| 95 | +you should consider setting up :ref:`conditional build cancellation rules <build-customization:Cancel build based on a condition>`. |
| 96 | +The configuration is added in each ``.readthedocs.yaml``, |
| 97 | +making it possible to write one conditional build rules per documentation project in the Monorepo 💯️ |
0 commit comments