Skip to content

Build: standardize output directory for artifacts #9888

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

Merged
merged 20 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
faec2a2
Build: standardize output directory for artifacts
humitos Jan 11, 2023
0666df6
Build: decideif there is an output type based on the path existence
humitos Jan 11, 2023
b494c64
Test: update build tests to match changes
humitos Jan 11, 2023
d2bf3f0
Test: check if the file exist before continue
humitos Jan 12, 2023
2ab29ba
Build: simplify the code by running the commands inside the container
humitos Jan 12, 2023
faa611f
Test: add checks for more commands
humitos Jan 12, 2023
c80416a
Storage: use constants to make explicit artifact types
humitos Jan 17, 2023
67f0958
PDF builder: raise an error if the PDF file is not found
humitos Jan 17, 2023
f54ca20
Build: use `relative_output_dir` and `absolute_output_dir`
humitos Jan 17, 2023
ad270e9
Builder: execute `sphinx-build` from the same directory as `conf.py`
humitos Jan 17, 2023
da328fd
HTMLZip build: use `zip` inside the Docker container to build it
humitos Jan 17, 2023
782179f
Minor changes about docstring and final dot in a sentence :)
humitos Jan 17, 2023
c999e55
Test: adapt them to match thew path and arguments changes
humitos Jan 17, 2023
411bb4e
Merge branch 'main' of github.com:readthedocs/readthedocs.org into hu…
humitos Jan 17, 2023
8195ecb
pre-commit missing changes
humitos Jan 17, 2023
1f50a3b
Sphinx builder: better default
humitos Jan 18, 2023
a88bf14
Update readthedocs/doc_builder/backends/sphinx.py
humitos Jan 18, 2023
280e8e4
Update readthedocs/projects/tests/test_build_tasks.py
humitos Jan 18, 2023
e78442a
Minor changes to fix tests
humitos Jan 18, 2023
c301c0d
Docstring: explain why there is an exception handling at this place
humitos Jan 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions readthedocs/builds/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,19 @@
MAX_BUILD_COMMAND_SIZE = 1000000 # This keeps us under Azure's upload limit

LOCK_EXPIRE = 60 * 180 # Lock expires in 3 hours

# All artifact types supported by Read the Docs.
# They match the output directory (`_readthedocs/<artifact type>`)
ARTIFACT_TYPES = (
"html",
"json",
"htmlzip",
"pdf",
"epub",
)
# Artifacts that are not deleted when uploading to the storage,
# even if they weren't re-built in the build process.
Comment on lines +161 to +162
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Artifacts that are not deleted when uploading to the storage,
# even if they weren't re-built in the build process.
# Artifacts that are not deleted when uploading to storage.
# This is because we want to only upload changed files,
# whereas single-file types will need to be deleted & recreated on any change.

I think this is the thinking here. Will this be true once we support multiple PDF's? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm, thinking a little more here, I think that both comments (mine and yours) are wrong 😅

Taking into account that HTML is mandatory for a build, we will always update the HTML output in our storage. Since JSON is required for search we also always want to have it there.

The other formats may be required to delete them when they are disabled after being enabled. If the build for version v3 outputs a PDF and then the user disable the PDF for that version, we have to remove the PDF from the storage. This can't happen for HTML nor JSON because those are mandatory.

I complicated myself trying to explain this, but hopefully, I'm being clear enough for you to understand me 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% following... But it's probably not too important as long as we have a reasonably correct comment.

UNDELETABLE_ARTIFACT_TYPES = (
"html",
"json",
)
9 changes: 2 additions & 7 deletions readthedocs/doc_builder/backends/mkdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ class BaseMkdocs(BaseBuilder):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.yaml_file = self.get_yaml_config()
self.old_artifact_path = os.path.join(
os.path.dirname(self.yaml_file),
self.build_dir,
)

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

class MkdocsHTML(BaseMkdocs):

type = 'mkdocs'
builder = 'build'
build_dir = '_build/html'
builder = "build"
build_dir = "_readthedocs/html"


# TODO: find a better way to integrate with MkDocs.
Expand Down
Loading