Skip to content

Commit 759ec50

Browse files
committed
Various fixes
1 parent 87e022c commit 759ec50

27 files changed

Lines changed: 94 additions & 23 deletions
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env python3
2+
"""Apply cached intros/keywords from .llm_cache/ into .qmd frontmatter (no API).
3+
4+
Run before group_docs_by_category - the cache is keyed by the original path.
5+
Usage: apply_cached_intros.py [DOCS_DIR] # default: DOCS
6+
"""
7+
8+
from __future__ import annotations
9+
10+
import sys
11+
from pathlib import Path
12+
13+
# repo root is three levels up from .github/scripts/build
14+
SCRIPT_DIR = Path(__file__).resolve().parent
15+
SCRIPTS_ROOT = SCRIPT_DIR.parent
16+
sys.path.insert(0, str(SCRIPTS_ROOT))
17+
18+
from helpers.qmd_utils import find_qmd_files # noqa: E402
19+
from helpers.file_updater import apply_all_updates # noqa: E402
20+
21+
ROOT_DIR = (SCRIPT_DIR / "../../..").resolve()
22+
CACHE_DIR = (ROOT_DIR / ".llm_cache").resolve()
23+
# skip non-doc dirs, same set as update_documentation.py
24+
BLACKLISTED_DIRS = {
25+
"templates",
26+
"includes",
27+
"theme",
28+
"_meta",
29+
"assets",
30+
"_site",
31+
".quarto",
32+
}
33+
34+
35+
def main() -> int:
36+
docs_arg = sys.argv[1] if len(sys.argv) > 1 else "DOCS"
37+
input_dir = Path(docs_arg).resolve()
38+
39+
if not input_dir.is_dir():
40+
print(f"[apply_cached_intros] '{input_dir}' is not a directory - skipping")
41+
return 0
42+
43+
if not CACHE_DIR.is_dir():
44+
print(f"[apply_cached_intros] no cache at {CACHE_DIR} - nothing to apply")
45+
return 0
46+
47+
# cache keys start with the DOCS dir name, so resolve against its parent
48+
lookup_root = input_dir.parent
49+
50+
qmd_files = set(find_qmd_files(input_dir, BLACKLISTED_DIRS))
51+
if not qmd_files:
52+
print(f"[apply_cached_intros] no .qmd files under {input_dir}")
53+
return 0
54+
55+
stats = apply_all_updates(
56+
qmd_files,
57+
CACHE_DIR,
58+
dry_run=False,
59+
root_dir=lookup_root,
60+
apply_versions=False,
61+
)
62+
63+
# don't fail the build over a frontmatter glitch
64+
if stats.get("errors"):
65+
print(f"[apply_cached_intros] done, with {len(stats['errors'])} error(s)")
66+
return 0
67+
68+
69+
if __name__ == "__main__":
70+
sys.exit(main())

.github/scripts/build/build-docs.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ step() {
3131
_STEP_PREV=$now; _STEP_NAME="$*"
3232
}
3333

34+
# Apply cached intros/keywords before the rename - the cache is keyed by original path.
35+
echo "Injecting cached intros & keywords (no API)..."
36+
python3 .github/scripts/build/apply_cached_intros.py DOCS
37+
3438
step "[1/6] Copying DOCS to origin_DOCS..."
3539
mv DOCS origin_DOCS
3640

.github/scripts/helpers/file_updater.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,25 @@ def apply_all_updates(
3838
cache_dir: Path,
3939
dry_run: bool = False,
4040
root_dir: Path | None = None,
41+
apply_versions: bool = True,
4142
) -> dict:
4243
"""Merge all cached updates into each .qmd's frontmatter, writing each file once.
4344
Returns a stats dict (files_updated, intros_applied, versions_applied, errors).
4445
4546
root_dir matters: cache keys are repo-relative, so absolute paths in
4647
files_to_update are rewritten to that form before lookup — without it every
47-
lookup silently misses. dry_run shows the changes without writing."""
48+
lookup silently misses. dry_run shows the changes without writing.
49+
50+
apply_versions=False does intros/keywords only, leaving version/date alone -
51+
the build step uses this since fill_version.py handles versions there."""
4852
print("\n" + "=" * 70)
4953
print("📝 Applying All Cached Updates to .qmd Files")
5054
print("=" * 70)
5155

5256
if dry_run:
5357
print("[DRY RUN] Showing updates but NOT modifying files\n")
5458

55-
versions_metadata = load_versions_metadata(cache_dir)
59+
versions_metadata = load_versions_metadata(cache_dir) if apply_versions else {}
5660

5761
stats = {
5862
"files_updated": 0,
@@ -100,7 +104,7 @@ def apply_all_updates(
100104

101105
# 2. Apply version updates if available
102106
filepath_str = str(lookup_path)
103-
if filepath_str in versions_metadata:
107+
if apply_versions and filepath_str in versions_metadata:
104108
version_data = versions_metadata[filepath_str]
105109
new_version = version_data.get("current_version")
106110
if new_version:

.github/workflows/deploy-docs.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,6 @@ jobs:
100100
git push origin HEAD
101101
fi
102102
103-
# Hotfix: install chrome into the job's HOME so the Typst diagram render
104-
# finds it (container jobs set HOME=/github/home). Drop once the rebuilt
105-
# image bakes XDG_DATA_HOME in.
106-
#- name: Ensure headless Chrome for diagram rendering
107-
# run: quarto install chrome-headless-shell
108-
109103
- name: Build Docs
110104
run: .github/scripts/build/build-docs.sh
111105

.llm_cache/DOCS__High_Resolution_Layer__CLMS_ATBD_HRLSLF_v1.1.qmd.json renamed to .llm_cache/DOCS__High_Resolution_Layer__CLMS_ATBD_HRLSLF_v1.qmd.json

File renamed without changes.

.llm_cache/DOCS__High_Resolution_Layer__CLMS_PUM_HRLSLF_v1.1.qmd.json renamed to .llm_cache/DOCS__High_Resolution_Layer__CLMS_PUM_HRLSLF_v1.qmd.json

File renamed without changes.

DOCS/High_Resolution_Layer/CLMS_ATBD_HRLSLF_v1.1-media/img-01b50e5d324407691b81fab81cbccc1fefddbb48.png renamed to DOCS/High_Resolution_Layer/CLMS_ATBD_HRLSLF_v1-media/img-01b50e5d324407691b81fab81cbccc1fefddbb48.png

File renamed without changes.

DOCS/High_Resolution_Layer/CLMS_ATBD_HRLSLF_v1.1-media/img-0aeffbc120bdc6740e4085604ad2c7f3d15b624c.png renamed to DOCS/High_Resolution_Layer/CLMS_ATBD_HRLSLF_v1-media/img-0aeffbc120bdc6740e4085604ad2c7f3d15b624c.png

File renamed without changes.

DOCS/High_Resolution_Layer/CLMS_ATBD_HRLSLF_v1.1-media/img-0ffc62228d51c76208316e1bc05e34c4a916189a.png renamed to DOCS/High_Resolution_Layer/CLMS_ATBD_HRLSLF_v1-media/img-0ffc62228d51c76208316e1bc05e34c4a916189a.png

File renamed without changes.

DOCS/High_Resolution_Layer/CLMS_ATBD_HRLSLF_v1.1-media/img-19af4590dd266c8c9cb96e9eebf8f88e30ed117f.png renamed to DOCS/High_Resolution_Layer/CLMS_ATBD_HRLSLF_v1-media/img-19af4590dd266c8c9cb96e9eebf8f88e30ed117f.png

File renamed without changes.

0 commit comments

Comments
 (0)