Skip to content

Commit 2b3248c

Browse files
committed
docs: materialize Fern version pages
1 parent aad7a16 commit 2b3248c

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

fern/AGENTS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Published release snapshots live on the CI-managed `docs-website` branch. Do not
2626

2727
The `docs-website` branch must already contain the historical Fern archive (`v0.6.0`, `v0.5.9`, `v0.5.8`, and `older`). The release workflow fails if those redirect targets are missing.
2828

29+
Frozen `vX.Y.Z.yml` navs on `docs-website` must point only at their own `vX.Y.Z/pages/...` files. The release sync materializes shared historical pages into each version folder before publishing.
30+
2931
Dev Notes publishing patches only Dev Notes from `main` into the current latest docs on `docs-website`, mirroring the MkDocs workflow.
3032

3133
## Release Prep

fern/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ fern/versions/
101101
└── older/pages/...
102102
```
103103

104+
Each frozen `vX.Y.Z.yml` nav on `docs-website` must point only at that version's own `vX.Y.Z/pages/...` files. The release sync materializes shared historical pages into each version folder before publishing.
105+
104106
Normal GitHub releases do not need a dedicated pre-release Fern PR. The release workflow snapshots the release into `docs-website` and publishes from that branch.
105107

106108
Dev Notes publishing mirrors MkDocs: it patches only the Dev Notes nav and pages from `main` into the current latest docs on `docs-website`, then republishes Fern.

fern/scripts/fern-published-branch.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,37 @@ def sync_code_reference_archive(source_root: Path, published_root: Path) -> None
295295
)
296296

297297

298+
def materialize_version_nav_pages(published_root: Path) -> None:
299+
versions_dir = published_root / "fern" / "versions"
300+
for nav in sorted(versions_dir.glob("v*.yml")):
301+
slug = nav.stem
302+
lines = nav.read_text().splitlines(keepends=True)
303+
changed = False
304+
if lines and lines[0].startswith(f"# Frozen {slug} release nav. Reuses shared pages"):
305+
lines[0] = f"# Frozen {slug} release nav. Pages are materialized under ./{slug}/pages/.\n"
306+
changed = True
307+
for index, line in enumerate(lines):
308+
match = NAV_PATH_RE.match(line)
309+
if not match:
310+
continue
311+
rel_path = Path(match.group(2))
312+
if len(rel_path.parts) < 3 or rel_path.parts[1] != "pages":
313+
continue
314+
315+
target_rel = Path(slug, "pages", *rel_path.parts[2:])
316+
source_file = versions_dir / rel_path
317+
target_file = versions_dir / target_rel
318+
if not source_file.exists():
319+
raise PublishedBranchError(f"{nav} references missing page {source_file}")
320+
if source_file != target_file:
321+
copy_path(source_file, target_file)
322+
lines[index] = f"{match.group(1)}./{target_rel.as_posix()}{match.group(3)}\n"
323+
changed = True
324+
325+
if changed:
326+
nav.write_text("".join(lines))
327+
328+
298329
def sync_source(args: argparse.Namespace) -> int:
299330
source_root = Path(args.source_root)
300331
published_root = Path(args.published_root)
@@ -313,6 +344,7 @@ def sync_source(args: argparse.Namespace) -> int:
313344
source_root / "fern" / "versions", published_root / "fern" / "versions", preserved_versions
314345
)
315346
sync_code_reference_archive(source_root, published_root)
347+
materialize_version_nav_pages(published_root)
316348
restore_versions_block(published_root / "fern" / "docs.yml", preserved_versions_block)
317349
validate_redirect_targets(published_root)
318350
return 0

0 commit comments

Comments
 (0)