|
| 1 | +Specification |
| 2 | +============= |
| 3 | + |
| 4 | +``rtd-build`` is a tool that can build Sphinx documentation. It is used |
| 5 | +internally by readthedocs.org to build all Sphinx based documentation. |
| 6 | + |
| 7 | +Creating a build works like this: |
| 8 | + |
| 9 | +- change into the root of the project that you want to build the documentation |
| 10 | + for |
| 11 | +- run ``rtd-build`` |
| 12 | + |
| 13 | +``rtd-build`` will then perform the following actions: |
| 14 | + |
| 15 | +- it searches for all ``readthedocs.yml`` files below the current directory |
| 16 | + and merges all found files into a list of configurations |
| 17 | +- it iterates over all configurations (order is not garuanteed) and performs |
| 18 | + the following actions for each: |
| 19 | + |
| 20 | + - create a fresh virtualenv |
| 21 | + - ``cd`` into the base directory of the documentation |
| 22 | + - ``pip install ...`` whatever is configured in the config |
| 23 | + - ``python setup.py install`` if configured (from the path specified in |
| 24 | + ``python.setup_path``. |
| 25 | + - run ``sphinx-build`` |
| 26 | + |
| 27 | +``readthedocs.yml`` spec |
| 28 | +------------------------ |
| 29 | + |
| 30 | +A ``readthedocs.yml`` file must be in YAML format. If the top level is a block |
| 31 | +sequence (i.e. a list), then the file describes multiple configurations. If |
| 32 | +the top level is mapping, then the file describes a single configuration. |
| 33 | + |
| 34 | +A few complete examples: |
| 35 | + |
| 36 | +- config file living at the root of the repository, configuring only one |
| 37 | + documentation: |
| 38 | + |
| 39 | + .. code-block:: yaml |
| 40 | +
|
| 41 | + # in /readthedocs.yml |
| 42 | + base: docs/ |
| 43 | + type: sphinx |
| 44 | + formats: |
| 45 | + html: true |
| 46 | + pdf: true |
| 47 | + python: |
| 48 | + setup_install: true |
| 49 | +
|
| 50 | +- A project with multiple documentations. The on in ``docs/`` is the english |
| 51 | + one and considered the main documentation. ``docs-de/`` contains a second |
| 52 | + documentation which is the german translation of ``docs/``. |
| 53 | + |
| 54 | + .. code-block:: yaml |
| 55 | +
|
| 56 | + # in /docs/readthedocs.yml |
| 57 | + type: sphinx |
| 58 | + language: en |
| 59 | + python: |
| 60 | + requirements: |
| 61 | + - "-r../requirements.txt" |
| 62 | + setup_install: true |
| 63 | +
|
| 64 | + # in /docs-de/readthedocs.yml |
| 65 | + extend: docs/readthedocs.yml |
| 66 | + language: de |
| 67 | +
|
| 68 | +- The same as the previous example but with everything configured in one |
| 69 | + ``readthedocs.yml`` in the root of the project: |
| 70 | + |
| 71 | + .. code-block:: yaml |
| 72 | +
|
| 73 | + - name: en |
| 74 | + type: sphinx |
| 75 | + language: en |
| 76 | + base: docs/ |
| 77 | + python: |
| 78 | + requirements: |
| 79 | + - "-rrequirements.txt" |
| 80 | + setup_install: true |
| 81 | +
|
| 82 | + - name: de |
| 83 | + extend: en |
| 84 | + language: de |
| 85 | + base: docs-de/ |
| 86 | +
|
| 87 | +
|
| 88 | +Following mapping keys are supported (all but the marked once are optional): |
| 89 | + |
| 90 | +``extend`` |
| 91 | + References the name of another configuration. All mapping keys are |
| 92 | + inherited, except for ``name`` and ``base``. |
| 93 | + |
| 94 | +``name`` |
| 95 | + An identifier of the documentation that this config is about. It might |
| 96 | + simply be ``docs``, or ``docs-de``. It's arbitrary, but must be unique |
| 97 | + with in all readthedocs configs in one project. It can be used to refer to |
| 98 | + a different configuration. |
| 99 | + |
| 100 | + It defaults to the path of the file relative to the project root. E.g. the |
| 101 | + config in ``api-docs/readthedocs.yml`` will get the name |
| 102 | + ``api-docs/readthedocs.yml`` by default. Since the ``name`` must be |
| 103 | + unique, it's an error to have two configurations without a name in the |
| 104 | + same file. |
| 105 | + |
| 106 | +``base`` |
| 107 | + The path to the root directory of the documentation that this config is |
| 108 | + about. That is usually the path that contains the ``conf.py`` file. It |
| 109 | + defaults to the directory that the ``readthedocs.yml`` file lives in. All |
| 110 | + commands for building the documentation will have the ``base`` set as |
| 111 | + working directory. |
| 112 | + |
| 113 | +``type``, *required* |
| 114 | + The documentation framework that this documentation is written in. Allowed |
| 115 | + values are: |
| 116 | + |
| 117 | + - ``sphinx`` |
| 118 | + - ``mkdocs`` |
| 119 | + |
| 120 | +``formats`` |
| 121 | + A mapping of format types to shall be built. The following formats are |
| 122 | + supported: |
| 123 | + |
| 124 | + - ``html``, default: ``true`` |
| 125 | + - ``pdf``, default: ``false`` |
| 126 | + - ``epub``, default: ``false`` |
| 127 | + |
| 128 | +``python`` |
| 129 | + Python specific configuration. All builds are executed inside a |
| 130 | + virtualenv. This config can customize the virtualenv before running the |
| 131 | + build. The following subkeys are allowed: |
| 132 | + |
| 133 | + ``pip_requirements`` |
| 134 | + A list of arguments that will be passed down to a ``pip install`` |
| 135 | + call. You can specify requirements files with ``-r |
| 136 | + path/to/requirements.txt``. Accepts version modifiers like |
| 137 | + ``setuptools>=18.0``. |
| 138 | + |
| 139 | + ``setup_install`` |
| 140 | + If ``true``, then ``python setup.py install`` will be executed before |
| 141 | + building the docs. |
| 142 | + |
| 143 | + ``setup_path`` |
| 144 | + The path in which ``python setup.py install`` will be executed. |
| 145 | + Defaults to the repository root. |
| 146 | + |
| 147 | +``language`` |
| 148 | + The language the doc is written in. Defaults to empty string. |
0 commit comments