This directory contains scripts for the pull-based external documentation synchronization system.
The Waldur documentation repository uses a pull-based approach to aggregate content from multiple source repositories. This system provides better control and visibility over external content by maintaining source mappings in this repository.
Main synchronization script that pulls documentation from external repositories based on the configuration in external-sources.yml.
Usage:
# Sync all configured sources
python scripts/sync-external-docs.py
# Sync specific sources only
python scripts/sync-external-docs.py --sources homeport-ui mastermind-api
# List all configured sources
python scripts/sync-external-docs.py --list
# Dry run (show what would be synced)
python scripts/sync-external-docs.py --dry-runFeatures:
- Clones external repositories with authentication
- Maps specific remote folders to local directories
- Adds external document markers to pulled files
- Removes obsolete external files
- Preserves local files (index.md, .pages, README.md)
- Warns about untracked local files
Validation script that checks sync status and identifies issues with external documentation.
Usage:
# Validate all sources
python scripts/validate-external-sync.py
# Validate specific sources
python scripts/validate-external-sync.py --sources homeport-ui
# Generate detailed report
python scripts/validate-external-sync.py --report validation-report.txtChecks:
- External files have proper markers
- Sync timestamps are recent
- Local files without markers are flagged
- Marker information matches configuration
MkDocs plugin that processes external document markers and adds visual indicators to the rendered documentation.
Features:
- Removes HTML comment markers from rendered output
- Adds visual notice boxes at the top of external documents
- Adds "External" badges to page titles
- Provides CSS classes for styling external content
Central configuration file that defines all external documentation sources and their mappings:
sources:
homeport-ui:
name: "Waldur HomePort UI Documentation"
repository: "https://gitlab.com/waldur/waldur-homeport.git"
branch: "develop"
auth:
token_env: "HOMEPORT_TOKEN"
mappings:
- remote: "docs/developers"
local: "docs/developer-guide/ui"
description: "UI development documentation"
excludes:
- "*.pyc"
- "__pycache__"
settings:
preserve_local:
- "index.md"
- ".pages"
- "README.md"
max_sync_age_hours: 24- Clone: Temporarily clone each configured external repository
- Map: Copy files from remote paths to local paths according to mappings
- Mark: Add external document markers to pulled markdown files
- Clean: Remove obsolete external files that no longer exist in remote
- Preserve: Keep local files that match preserve patterns
- Warn: Flag local files without external markers for manual review
- External Files: Files with
<!-- EXTERNAL DOCUMENT -->markers - managed by sync - Local Files: Files without markers that match preserve patterns - kept locally
- Untracked Files: Local files without markers that don't match preserve patterns - flagged as warnings
External repositories requiring authentication use environment variables:
export HOMEPORT_TOKEN="your-token-here"
export MASTERMIND_TOKEN="your-token-here"
export INTEGRATIONS_TOKEN="your-token-here"Tokens are inserted into repository URLs automatically during cloning.
Include .gitlab-ci-external-sync.yml in your main GitLab CI configuration:
# .gitlab-ci.yml
include:
- .gitlab-ci-external-sync.ymlPipeline Jobs:
- validate-external-sync: Runs on all MRs and branches
- sync-external-docs: Runs on master branch and manual triggers
- post-sync-validation: Validates documentation after sync
- scheduled-sync: For automated daily/weekly syncs
- Python 3.12+
- PyYAML (
pip install pyyaml) - Git (for cloning repositories)
- MkDocs and MkDocs Material theme (for the plugin)