|
| 1 | +title: You can now partially or completely override the build process |
| 2 | +date: January 20, 2025 |
| 3 | +description: Announcing support for partially or completely override build steps using the `build.jobs` configuration. |
| 4 | +category: Feature announcement |
| 5 | +tags: configuration-file |
| 6 | +authors: Santos Gallegos |
| 7 | +status: published |
| 8 | +image: /images/override-build-steps-with-build-jobs.jpg |
| 9 | +image_credit: Photo by <a href="https://unsplash.com/@ryanquintal?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Ryan Quintal</a> on <a href="https://unsplash.com/photos/purple-block-toy-_H7p-RZUVo4?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Unsplash</a> |
| 10 | + |
| 11 | +We are excited to announce that you can now partially or completely override build steps using the [`build.jobs`](https://docs.readthedocs.io/en/stable/config-file/v2.html#build-jobs) configuration in your `.readthedocs.yaml` configuration file. |
| 12 | +This allows you to customize the build process to suit your project's specific requirements. |
| 13 | +Find more details and examples in our [documentation](https://docs.readthedocs.io/en/stable/build-customization.html). |
| 14 | + |
| 15 | +Previously, you could only extend the build process by using any of the `pre_` and `post_` build jobs, |
| 16 | +we have now extended this functionality to allow you to override the build process completely. |
| 17 | +The following build steps are available for you to override: |
| 18 | + |
| 19 | +- `create_environment` |
| 20 | +- `install` |
| 21 | +- `build.html` |
| 22 | +- `build.pdf` |
| 23 | +- `build.epub` |
| 24 | +- `build.htmlzip` |
| 25 | + |
| 26 | +If you are using Sphinx or MkDocs, but you want to have more control over how a specific step is executed, you can override only that step. |
| 27 | +For example, to use the normal build process for HTML and EPUB when building a Sphinx project, |
| 28 | +but use [rinohtype](https://www.mos6581.org/rinohtype/master/intro.html#sphinx-builder) for PDF output, you can use the following configuration: |
| 29 | + |
| 30 | +```yaml |
| 31 | +version: 2 |
| 32 | + |
| 33 | +formats: |
| 34 | + - pdf |
| 35 | + - epub |
| 36 | + |
| 37 | +sphinx: |
| 38 | + configuration: docs/conf.py |
| 39 | + |
| 40 | +python: |
| 41 | + install: |
| 42 | + - requirements: docs/requirements.txt |
| 43 | + |
| 44 | +build: |
| 45 | + os: ubuntu-24.04 |
| 46 | + tools: |
| 47 | + python: "3.13" |
| 48 | + jobs: |
| 49 | + build: |
| 50 | + pdf: |
| 51 | + - sphinx-build -b rinoh docs _build/pdf/ |
| 52 | + - mkdir --parents $READTHEDOCS_OUTPUT/pdf/ |
| 53 | + - mv _build/pdf/*.pdf $READTHEDOCS_OUTPUT/pdf/ |
| 54 | +``` |
| 55 | +
|
| 56 | +If you are using another tool, or you want complete control over the build process, |
| 57 | +you can use a similar configuration without specifying a `sphinx` or `mkdocs` configuration to have full control over the build process. |
| 58 | +For example, to build using [Markdoc](https://markdoc.dev/) you can use the following configuration: |
| 59 | + |
| 60 | +```yaml |
| 61 | +version: 2 |
| 62 | +
|
| 63 | +build: |
| 64 | + os: ubuntu-24.04 |
| 65 | + tools: |
| 66 | + nodejs: "22" |
| 67 | + jobs: |
| 68 | + install: |
| 69 | + - cd docs/ && npm install |
| 70 | + build: |
| 71 | + html: |
| 72 | + - cd docs/ && npm run build |
| 73 | + - mkdir --parents $READTHEDOCS_OUTPUT/html/ |
| 74 | + - cp --recursive docs/out/* $READTHEDOCS_OUTPUT/html/ |
| 75 | +``` |
| 76 | + |
| 77 | +You can check [our docs](https://docs.readthedocs.io/en/stable/intro/markdoc.html) for a working example. |
| 78 | + |
| 79 | +We recommend using [`build.jobs`](https://docs.readthedocs.io/en/stable/config-file/v2.html#build-jobs) over [`build.commands`](https://docs.readthedocs.io/en/stable/config-file/v2.html#build-commands), |
| 80 | +as it offers the same functionality as `build.commands`, but in a more structured way that allows you to define different commands for each format, |
| 81 | +while also supporting installing system dependencies via `build.apt_packages`. |
0 commit comments