Skip to content
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

Build: allow partial override of build steps #11710

Merged
merged 20 commits into from
Nov 25, 2024
Merged
Prev Previous commit
Next Next commit
Use conditional
stsewd committed Nov 25, 2024

Verified

This commit was signed with the committer’s verified signature.
stsewd Santos Gallegos
commit 0c5fea8624deafaff7700ba78a41e2832b679d69
29 changes: 13 additions & 16 deletions readthedocs/doc_builder/director.py
Original file line number Diff line number Diff line change
@@ -322,16 +322,18 @@ def install(self):

# Build
def build_html(self):
if self.run_build_job("build.html"):
return True
if self.data.config.build.jobs.build.html is not None:
self.run_build_job("build.html")
return
return self.build_docs_class(self.data.config.doctype)

def build_pdf(self):
if "pdf" not in self.data.config.formats or self.data.version.type == EXTERNAL:
return False

if self.run_build_job("build.pdf"):
return True
if self.data.config.build.jobs.build.pdf is not None:
self.run_build_job("build.pdf")
return

# Mkdocs has no pdf generation currently.
if self.is_type_sphinx():
@@ -346,8 +348,9 @@ def build_htmlzip(self):
):
return False

if self.run_build_job("build.htmlzip"):
return True
if self.data.config.build.jobs.build.htmlzip is not None:
self.run_build_job("build.htmlzip")
return

# We don't generate a zip for mkdocs currently.
if self.is_type_sphinx():
@@ -358,8 +361,9 @@ def build_epub(self):
if "epub" not in self.data.config.formats or self.data.version.type == EXTERNAL:
return False

if self.run_build_job("build.epub"):
return True
if self.data.config.build.jobs.build.epub is not None:
self.run_build_job("build.epub")
return

# Mkdocs has no epub generation currently.
if self.is_type_sphinx():
@@ -400,13 +404,8 @@ def run_build_job(self, job):
`sed` command.
"""
commands = get_dotted_attribute(self.data.config, f"build.jobs.{job}", None)
# If it's None, the job wasn't defined.
if commands is None:
return False

# The job was defined, but it's empty.
if not commands:
return True
return

cwd = self.data.project.checkout_path(self.data.version.slug)
environment = self.vcs_environment
@@ -416,8 +415,6 @@ def run_build_job(self, job):
for command in commands:
environment.run(command, escape_command=False, cwd=cwd)

return True

def check_old_output_directory(self):
"""
Check if there the directory '_build/html' exists and fail the build if so.