Skip to content

Commit 38fca65

Browse files
Docs: Refactor the build & build customization pages (Diátaxis) (#10028)
* Refactor the build & build customization pages This mostly was just cleanup, and didn't change the structure of these pages. I do think we want to break out the examples into a seperate page in the future, but I just wanted an initial refactor here.. Fixes #9575 * Fix up titles * Update docs/user/build-customization.rst * Apply suggestions from code review Co-authored-by: Benjamin Balder Bach <[email protected]> * Apply suggestions from code review --------- Co-authored-by: Benjamin Balder Bach <[email protected]>
1 parent 3b1957e commit 38fca65

File tree

4 files changed

+142
-131
lines changed

4 files changed

+142
-131
lines changed

docs/user/build-customization.rst

+69-62
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
Build customization
2-
===================
1+
Build process customization
2+
===========================
33

4-
Read the Docs has a :doc:`well-defined build process <builds>` that works for many projects,
5-
but we offer additional customization to support more uses of our platform.
6-
This page explains how to extend the build process using :term:`user-defined build jobs` to execute custom commands,
7-
and also how to override the build process completely:
4+
Read the Docs has a :doc:`well-defined build process </builds>` that works for many projects.
5+
We also allow customization of builds in primary ways:
86

97
`Extend the build process`_
10-
If you are using Sphinx or Mkdocs and need to execute additional commands.
8+
Keep using the default build process,
9+
adding your own commands.
1110

1211
`Override the build process`_
13-
If you want full control over your build. This option supports any tool that generates HTML as part of the build.
14-
15-
.. contents:: Table of contents
16-
:local:
12+
This option gives you *full control* over your build.
13+
Read the Docs supports any tool that generates HTML.
1714

1815
Extend the build process
1916
------------------------
2017

2118
In the normal build process,
2219
the pre-defined jobs ``checkout``, ``system_dependencies``, ``create_environment``, ``install``, ``build`` and ``upload`` are executed.
23-
However, Read the Docs exposes extra jobs to users so they can customize the build process by running shell commands.
24-
These extra jobs are:
20+
Read the Docs also exposes these jobs,
21+
which allows you to customize the build process by adding shell commands.
22+
23+
The jobs where users can customize our default build process are:
2524

2625
.. list-table::
2726
:header-rows: 1
27+
:widths: 25 75
2828

2929
* - Step
3030
- Customizable jobs
@@ -39,23 +39,22 @@ These extra jobs are:
3939
* - Build
4040
- ``pre_build``, ``post_build``
4141
* - Upload
42-
- There are no customizable jobs currently
42+
- No customizable jobs currently
4343

4444
.. note::
4545

46-
Currently, the pre-defined jobs (``checkout``, ``system_dependencies``, etc) executed by Read the Docs cannot be overridden or skipped.
47-
46+
The pre-defined jobs (``checkout``, ``system_dependencies``, etc) cannot be overridden or skipped.
47+
You can fully customize things in :ref:`build-customization:override the build process`.
4848

49-
These jobs can be declared by using a :doc:`/config-file/index` with the :ref:`config-file/v2:build.jobs` key on it.
50-
Let's say the project requires commands to be executed *before* installing any dependency into the Python environment and *after* the build has finished.
51-
In that case, a config file similar to this one can be used:
49+
These jobs are defined using the :doc:`/config-file/v2` with the :ref:`config-file/v2:build.jobs` key.
50+
This example configuration defines commands to be executed *before* installing and *after* the build has finished:
5251

5352
.. code-block:: yaml
5453
:caption: .readthedocs.yaml
5554
5655
version: 2
5756
build:
58-
os: "ubuntu-20.04"
57+
os: "ubuntu-22.04"
5958
tools:
6059
python: "3.10"
6160
jobs:
@@ -67,7 +66,8 @@ In that case, a config file similar to this one can be used:
6766
-F "version=${READTHEDOCS_VERSION}" https://example.com/webhooks/readthedocs/
6867
6968
70-
There are some caveats to knowing when using user-defined jobs:
69+
User-defined job limitations
70+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7171

7272
* The current working directory is at the root of your project's cloned repository
7373
* Environment variables are expanded for each individual command (see :doc:`/reference/environment-variables`)
@@ -78,19 +78,19 @@ There are some caveats to knowing when using user-defined jobs:
7878

7979

8080
``build.jobs`` examples
81-
+++++++++++++++++++++++
81+
~~~~~~~~~~~~~~~~~~~~~~~
8282

8383
We've included some common examples where using :ref:`config-file/v2:build.jobs` will be useful.
8484
These examples may require some adaptation for each projects' use case,
8585
we recommend you use them as a starting point.
8686

8787

88-
Unshallow clone
89-
~~~~~~~~~~~~~~~
88+
Unshallow git clone
89+
^^^^^^^^^^^^^^^^^^^
9090

9191
Read the Docs does not perform a full clone on ``checkout`` job to reduce network data and speed up the build process.
9292
Because of this, extensions that depend on the full Git history will fail.
93-
To avoid this, it's possible to unshallow the clone done by Read the Docs:
93+
To avoid this, it's possible to unshallow the :program:`git clone`:
9494

9595
.. code-block:: yaml
9696
:caption: .readthedocs.yaml
@@ -106,7 +106,7 @@ To avoid this, it's possible to unshallow the clone done by Read the Docs:
106106
107107
108108
Cancel build based on a condition
109-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
109+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
110110

111111
When a command exits with code ``183``,
112112
Read the Docs will cancel the build immediately.
@@ -170,7 +170,7 @@ This other example shows how to cancel a build if the commit message contains ``
170170
171171
172172
Generate documentation from annotated sources with Doxygen
173-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
173+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
174174

175175
It's possible to run Doxygen as part of the build process to generate documentation from annotated sources:
176176

@@ -190,7 +190,7 @@ It's possible to run Doxygen as part of the build process to generate documentat
190190
191191
192192
Use MkDocs extensions with extra required steps
193-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
193+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
194194

195195
There are some MkDocs extensions that require specific commands to be run to generate extra pages before performing the build.
196196
For example, `pydoc-markdown <http://niklasrosenstein.github.io/pydoc-markdown/>`_
@@ -209,7 +209,7 @@ For example, `pydoc-markdown <http://niklasrosenstein.github.io/pydoc-markdown/>
209209
210210
211211
Avoid having a dirty Git index
212-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
212+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
213213

214214
Read the Docs needs to modify some files before performing the build to be able to integrate with some of its features.
215215
Because of this reason, it could happen the Git index gets dirty (it will detect modified files).
@@ -231,7 +231,7 @@ In that case, the Git index can be updated to ignore the files that Read the Doc
231231
232232
233233
Perform a check for broken links
234-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
234+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
235235

236236
Sphinx comes with a `linkcheck <https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.linkcheck.CheckExternalLinksBuilder>`_ builder that checks for broken external links included in the project's documentation.
237237
This helps ensure that all external links are still valid and readers aren't linked to non-existent pages.
@@ -251,7 +251,7 @@ This helps ensure that all external links are still valid and readers aren't lin
251251
252252
253253
Support Git LFS (Large File Storage)
254-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
254+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
255255

256256
In case the repository contains large files that are tracked with Git LFS,
257257
there are some extra steps required to be able to download their content.
@@ -284,7 +284,7 @@ It's possible to use ``post_checkout`` user-defined job for this.
284284
285285
286286
Install Node.js dependencies
287-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
287+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
288288

289289
It's possible to install Node.js together with the required dependencies by using :term:`user-defined build jobs`.
290290
To setup it, you need to define the version of Node.js to use and install the dependencies by using ``build.jobs.post_install``:
@@ -307,7 +307,7 @@ To setup it, you need to define the version of Node.js to use and install the de
307307
308308
309309
Install dependencies with Poetry
310-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
310+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
311311

312312
Projects managed with `Poetry <https://python-poetry.org/>`__,
313313
can use the ``post_create_environment`` user-defined job to use Poetry for installing Python dependencies.
@@ -344,30 +344,53 @@ Override the build process
344344

345345
.. warning::
346346

347-
This feature is in a *beta phase* and could suffer incompatible changes or even removed completely in the near feature.
348-
It does not yet support some of the Read the Docs' features like the :term:`flyout menu`, and ads.
349-
However, we do plan to support these features in the future.
350-
Use this feature at your own risk.
351-
347+
This feature is in *beta* and could change without warning.
348+
It does not yet support some of the Read the Docs' features like the :term:`flyout menu`.
349+
We do our best to not break existing configurations,
350+
but use this feature at your own risk.
352351

353352
If your project requires full control of the build process,
354353
and :ref:`extending the build process <build-customization:extend the build process>` is not enough,
355-
all the commands executed during builds can be overridden using the :ref:`config-file/v2:build.commands` configuration file key.
354+
all the commands executed during builds can be overridden using the :ref:`config-file/v2:build.commands`.
356355

357356
As Read the Docs does not have control over the build process,
358-
you are responsible for running all the commands required to install requirements and build your project properly.
359-
Once the build process finishes, the contents of the ``_readthedocs/html/`` directory will be hosted.
357+
you are responsible for running all the commands required to install requirements and build your project.
358+
359+
Where to put files
360+
~~~~~~~~~~~~~~~~~~
360361

362+
It is your responsibility to generate HTML and other formats of your documentation using :ref:`config-file/v2:build.commands`.
363+
The contents of the ``_readthedocs/<format>/`` directory will be hosted as part of your documentation.
364+
365+
Supported :ref:`formats <downloadable-documentation:accessing offline formats>` are published if they exist in the following directories:
366+
367+
* ``_readthedocs/html/`` (required)
368+
* ``_readthedocs/htmlzip/``
369+
* ``_readthedocs/pdf/``
370+
* ``_readthedocs/epub/``
371+
372+
Search support
373+
~~~~~~~~~~~~~~
374+
375+
Read the Docs will automatically index the content of all your HTML files,
376+
respecting the :ref:`search <config-file/v2:search>` option.
377+
378+
You can access the search from the Read the Docs :term:`dashboard`,
379+
or by using the :doc:`/server-side-search/api`.
380+
381+
.. note::
382+
383+
In order for Read the Docs to index your HTML files correctly,
384+
they should follow the conventions described at :doc:`rtd-dev:search-integration`.
361385

362386
``build.commands`` examples
363-
+++++++++++++++++++++++++++
387+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
364388

365-
This section contains some examples that showcase what is possible with :ref:`config-file/v2:build.commands`.
389+
This section contains examples that showcase what is possible with :ref:`config-file/v2:build.commands`.
366390
Note that you may need to modify and adapt these examples depending on your needs.
367391

368-
369392
Pelican
370-
~~~~~~~
393+
^^^^^^^
371394

372395
`Pelican <https://blog.getpelican.com/>`__ is a well-known static site generator that's commonly used for blogs and landing pages.
373396
If you are building your project with Pelican you could use a configuration file similar to the following:
@@ -386,7 +409,7 @@ If you are building your project with Pelican you could use a configuration file
386409
387410
388411
Docsify
389-
~~~~~~~
412+
^^^^^^^
390413

391414
`Docsify <https://docsify.js.org/>`__ generates documentation websites on the fly, without the need to build static HTML.
392415
These projects can be built using a configuration file like this:
@@ -402,19 +425,3 @@ These projects can be built using a configuration file like this:
402425
commands:
403426
- mkdir --parents _readthedocs/html/
404427
- cp --recursive docs/* _readthedocs/html/
405-
406-
407-
Search support
408-
++++++++++++++
409-
410-
Read the Docs will automatically index the content of all your HTML files,
411-
respecting the :ref:`search <config-file/v2:search>` options from your config file.
412-
413-
You can access the search results from the :guilabel:`Search` tab of your project,
414-
or by using the :doc:`/server-side-search/api`.
415-
416-
.. note::
417-
418-
In order for Read the Docs to index your HTML files correctly,
419-
they should follow some of the conventions described
420-
at :doc:`rtd-dev:search-integration`.

0 commit comments

Comments
 (0)