Skip to content

Commit db78cdf

Browse files
committed
Build: standardize output directory for artifacts
Always expose the final artifacts under `_readthedocs/<format>` directory, where `<format>` can be one of the following: - html - htmlzip - pdf - epub - json This allows all users of the platform to have the same behavior. No matter if they are using the default Sphinx/MkDocs builders or a custom one by using `build.commands`. Besides, this commit removes the "intermediary" directory used _before_ uploading the files to S3. This allows users to modify the output files directly from `_readthedocs/<format>` using `build.jobs.post_build`, for example. Some important notes: - `BaseBuilder.type` is removed since it was not required anymore. - There is no `old_artifact_path` anymore since there is no intermediary folder. - The `sphinx-build` command is executed from path where the repository is cloned, instead from the the directory where the `conf.py` lives. This is to simplify the code and be able to use relative path for the build output directory (e.g. `sphinx-build -b html ... docs/ _readthedocs/html`). - A new `BaseSphinx._post_build` method was added to cleanup the output directory (leave only one .epub, .html and .pdf file before moving forward). - These changes should allow us to support _all formats_ for `build.commands`. We would need to check if these standard directories exist, set these formats in the version and upload their content. - Upload step now validate there is one and only one PDF, ePUB and ZIP file when they are built. Currently, we only support one file per version. In the future we could remove this restriction. It fails silently for now, which is not great. We need to refactor this code a little to fail the build properly and communicate this to the user. I think it's _the correct way_ of doing it. - This could also allow to support other ways to build PDF (SimplePDF or `tectonic`, see #9598) and also ZIP (e.g. zundler, see readthedocs/meta#77 (comment)). Closes #9179
1 parent 84a149a commit db78cdf

File tree

6 files changed

+154
-207
lines changed

6 files changed

+154
-207
lines changed

readthedocs/doc_builder/backends/mkdocs.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ class BaseMkdocs(BaseBuilder):
4646
def __init__(self, *args, **kwargs):
4747
super().__init__(*args, **kwargs)
4848
self.yaml_file = self.get_yaml_config()
49-
self.old_artifact_path = os.path.join(
50-
os.path.dirname(self.yaml_file),
51-
self.build_dir,
52-
)
5349

5450
# README: historically, the default theme was ``readthedocs`` but in
5551
# https://github.com/rtfd/readthedocs.org/pull/4556 we change it to
@@ -343,9 +339,8 @@ def get_theme_name(self, mkdocs_config):
343339

344340
class MkdocsHTML(BaseMkdocs):
345341

346-
type = 'mkdocs'
347-
builder = 'build'
348-
build_dir = '_build/html'
342+
builder = "build"
343+
build_dir = "_readthedocs/html"
349344

350345

351346
# TODO: find a better way to integrate with MkDocs.

0 commit comments

Comments
 (0)