Skip to content
Open
Changes from all commits
Commits
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
21 changes: 15 additions & 6 deletions docs/sphinx/utils/assemble_publish_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

import argparse
import json
import os
import pathlib
import shutil
import sys
Expand Down Expand Up @@ -66,11 +67,19 @@ def main() -> int:
help="Path to the root index.html (redirect page)")
args = parser.parse_args()

publish = pathlib.Path(args.publish_dir)
docs_out = pathlib.Path(args.docs_output)
version = args.version
is_tag = args.is_tag == "true"
repo_url = args.repo_url.rstrip("/")
# Resolve relative paths against BUILD_WORKSPACE_DIRECTORY (set by bazel run).
workspace = pathlib.Path(os.environ.get("BUILD_WORKSPACE_DIRECTORY", "."))

def _ws(p: str) -> pathlib.Path:
path = pathlib.Path(p)
return path if path.is_absolute() else workspace / path

publish = _ws(args.publish_dir)
docs_out = _ws(args.docs_output)
root_index = _ws(args.root_index)
version = args.version
is_tag = args.is_tag == "true"
repo_url = args.repo_url.rstrip("/")

# ── Place current build ───────────────────────────────────────────────────
version_dir = publish / version
Expand Down Expand Up @@ -107,7 +116,7 @@ def main() -> int:
shutil.copy2(_JS, shared_js_dir / _JS.name)

# ── Root files ────────────────────────────────────────────────────────────
shutil.copy2(args.root_index, publish / "index.html")
shutil.copy2(root_index, publish / "index.html")
(publish / ".nojekyll").touch()

# ── switcher.json ─────────────────────────────────────────────────────────
Expand Down
Loading