Add scripts and docs for creating offline documentation archives#22441
Add scripts and docs for creating offline documentation archives#22441ebembi-crdb wants to merge 6 commits intomainfrom
Conversation
…ives This adds a complete toolkit for creating portable, offline documentation archives for any CockroachDB version: Scripts: - create_single_archive.py: Main entry point for single version archives - create_all_archives_fixed.py: Batch creation for multiple versions - snapshot_relative.py: Core archiver that creates base structure - make_navigation_dynamic_v2.py: Makes navigation work with any folder name - fix_*.py: Supporting scripts for the 14-step archive process Documentation: - README_ARCHIVE_CREATION.md: Comprehensive guide with troubleshooting - CREATE_PORTABLE_ARCHIVE.md: Quick start guide Features: - Creates self-contained offline archives (~100-200MB per version) - Dynamic navigation that works when archive is renamed - Localized Google Fonts for offline use - Single version sidebar (no newer version references) - Relative paths for complete portability Usage: cd src/current python3 create_single_archive.py v23.1
✅ Deploy Preview for cockroachdb-interactivetutorials-docs canceled.
|
Files changed:
|
✅ Deploy Preview for cockroachdb-api-docs canceled.
|
✅ Deploy Preview for cockroachdb-docs canceled.
|
|
Few changes that we'll need -
|
mohini-crl
left a comment
There was a problem hiding this comment.
Please read the comment to check the review changes
- Replace brittle exact-string JS replacement with re.sub() using a flexible regex to match the broken stable URL replace() call regardless of whitespace variation (addresses reviewer concern about fragile string matching) - Write version-specific snapshot_relative.py to a tempfile instead of modifying the checked-in source in-place; temp file is deleted after use (addresses reviewer concern about rewriting checked-in scripts)
|
Use DOM-aware edits (BeautifulSoup) for HTML changes. Ensure snapshot_relative.py is not rewritten in-place. Avoid shell=True for subprocess calls. Add a small CI smoke test. |
- Replace shell=True subprocess.run() calls with list-form args in both create_all_archives_fixed.py and create_single_archive.py - Replace shell operations (find, mkdir, cp, zip) with Python equivalents: Path.glob/unlink, Path.mkdir, shutil.copy2, shutil.make_archive - Fix create_single_archive.py: use tempfile for snapshot_relative.py instead of writing it in-place (was the critical bug flagged in review) - Fix fix_navigation_in_archive() to use BeautifulSoup: extract <script> tags first, apply regex only to their string content, then reserialise - Add test_archive_smoke.py: verifies JS patch works, snapshot_relative.py is unchanged, and no shell=True remains in subprocess calls - Add .github/workflows/test-archive-scripts.yml CI job that runs test_archive_smoke.py and checks git diff on snapshot_relative.py
version.replace('.', '\.') inside an f-string {} is a SyntaxError on
Python < 3.12. Pre-compute the escaped version into a local variable
before using it in the f-string expression.
Working directory is src/current, so the path to snapshot_relative.py should be relative to that, not the repo root. Also add -- to disambiguate the path from a git revision.
Summary
Scripts Added
create_single_archive.pycreate_all_archives_fixed.pysnapshot_relative.pymake_navigation_dynamic_v2.pyfix_*.pyDocumentation Added
README_ARCHIVE_CREATION.md- Comprehensive guide with troubleshootingCREATE_PORTABLE_ARCHIVE.md- Quick start guideUsage
Test plan
create_single_archive.py v22.2successfully