-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blog post: partially or completely override the build process #345
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
title: You can now partially or completely override the build process | ||
date: January 20, 2025 | ||
description: Announcing support for partially or completely override build steps using the `build.jobs` configuration. | ||
category: Feature announcement | ||
tags: configuration-file | ||
authors: Santos Gallegos | ||
status: published | ||
image: /images/override-build-steps-with-build-jobs.jpg | ||
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> | ||
|
||
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. | ||
This allows you to customize the build process to suit your project's specific requirements. | ||
Find more details and examples in our [documentation](https://docs.readthedocs.io/en/stable/build-customization.html). | ||
|
||
Previously, you could only extend the build process by using any of the `pre_` and `post_` build jobs, | ||
we have now extended this functionality to allow you to override the build process completely. | ||
The following build steps are available for you to override: | ||
|
||
- `create_environment` | ||
- `install` | ||
- `build.html` | ||
- `build.pdf` | ||
- `build.epub` | ||
- `build.htmlzip` | ||
|
||
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. | ||
For example, to use the normal build process for HTML and EPUB when building a Sphinx project, | ||
but use [rinohtype](https://www.mos6581.org/rinohtype/master/intro.html#sphinx-builder) for PDF output, you can use the following configuration: | ||
|
||
```yaml | ||
version: 2 | ||
|
||
formats: | ||
- epub | ||
|
||
sphinx: | ||
configuration: docs/conf.py | ||
|
||
python: | ||
install: | ||
- requirements: docs/requirements.txt | ||
|
||
build: | ||
os: ubuntu-24.04 | ||
tools: | ||
python: "3.13" | ||
jobs: | ||
build: | ||
pdf: | ||
- sphinx-build -b rinoh docs _build/pdf/ | ||
- mkdir --parents $READTHEDOCS_OUTPUT/pdf/ | ||
- mv _build/pdf/*.pdf $READTHEDOCS_OUTPUT/pdf/ | ||
``` | ||
|
||
If you are using another tool, or you want complete control over the build process, | ||
you can use a similar configuration without specifying a `sphinx` or `mkdocs` configuration to have full control over the build process. | ||
For example, to build using [Markdoc](https://markdoc.dev/) you can use the following configuration: | ||
|
||
```yaml | ||
version: 2 | ||
|
||
build: | ||
os: ubuntu-24.04 | ||
tools: | ||
nodejs: "22" | ||
jobs: | ||
install: | ||
- cd docs/ && npm install | ||
build: | ||
html: | ||
- cd docs/ && npm run build | ||
- mkdir --parents $READTHEDOCS_OUTPUT/html/ | ||
- cp --recursive docs/out/* $READTHEDOCS_OUTPUT/html/ | ||
``` | ||
|
||
You can check [our docs](https://docs.readthedocs.io/en/stable/intro/markdoc.html) for a working example. | ||
|
||
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), | ||
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, | ||
while also supporting installing system dependencies via `build.apt_packages`. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably put a section in the docs about when each should be used. I think
build.commands
is basically for when you want us to run no additional setup, and the reason apt_packages doesn't work is because we aren't doing any kind of environment setup, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build.jobs can also be used to not run any additional steps, they are basically the same now.