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

[MAINTENANCE] move prepare_prior_versions to allow one version at a time #9246

Merged
merged 4 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions docs/docs_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

from docs.docs_version_bucket_info import S3_URL
from docs.logging import Logger
from docs.prepare_prior_versions import prepare_prior_versions

if TYPE_CHECKING:
from invoke.context import Context
Expand Down Expand Up @@ -52,16 +51,18 @@ def build_docs_locally(self) -> None:
self._context.run("yarn start")

def _prepare(self) -> None:
from docs.prepare_prior_versions import prepare_prior_versions, Version

"""A whole bunch of common work we need"""
self.logger.print_header("Preparing to build docs...")
self._load_files()
versions_loaded = self._load_files()

self.logger.print_header(
"Updating versioned code and docs via prepare_prior_versions.py..."
)
# TODO: none of this messing with current directory stuff
os.chdir("..")
prepare_prior_versions()
prepare_prior_versions([Version.from_string(v) for v in versions_loaded])
os.chdir("docusaurus")
self.logger.print("Updated versioned code and docs")

Expand All @@ -77,11 +78,13 @@ def _load_zip(self, url: str) -> Generator[zipfile.ZipFile, None, None]:
with zipfile.ZipFile(zip_data, "r") as zip_ref:
yield zip_ref

def _load_files(self) -> None:
def _load_files(self) -> List[str]:
"""Load oss_docs_versions zip and relevant versions from github.
oss_docs_versions contains the versioned docs to be used later by prepare_prior_versions, as well
as the versions.json file, which contains the list of versions that we then download from github.
Returns a list of verions loaded.
"""

if os.path.exists("versioned_code"):
Expand All @@ -108,6 +111,7 @@ def _load_files(self) -> None:
self._current_directory / f"versioned_code/version-{version}"
)
shutil.move(str(old_location), str(new_location))
return versions

def _invoke_api_docs(self) -> None:
"""Invokes the invoke api-docs command.
Expand Down