3.5 KiB
3.5 KiB
Flux Help Sync Script README
Overview
This script generates a unified diff that synchronizes Flux function help
entries in ui/src/flux/constants/functions.ts with the Flux v0 docs from the
local docs-v2 repository.
Files and Paths
- Script:
scripts/flux-help-sync.py - Input help file:
ui/src/flux/constants/functions.ts - Docs repo (default):
../docs-v2(override with--docs-v2-repo-dir) - Docs stdlib root:
../docs-v2/content/flux/v0/stdlib - Output patch:
flux-help.diff(repo root)
How it works
- It scans the docs tree and builds a map of functions using:
- front matter
titleanddescription - the
## Parameterssection - the
Function type signatureblock - the first relevant JavaScript example (multi-line preserved)
- front matter
flux/v0/tagsfor category inference
- front matter
- It loads
functions.tsby evaluating it in a Node VM to collect existing help entries. - It updates existing entries with doc-derived content and appends new entries
for functions present in docs but missing in
functions.ts. - It writes the diff to
flux-help.diff. It does not modifyfunctions.ts.
Usage
- Generate a patch:
python scripts/flux-help-sync.py - Tag undocumented stubs:
python scripts/flux-help-sync.py --tag-undocumented - Prune undocumented entries:
python scripts/flux-help-sync.py --prune-undocumented - Prune only removed entries:
python scripts/flux-help-sync.py --prune-removed - Set docs-v2 repo location:
python scripts/flux-help-sync.py --docs-v2-repo-dir /path/to/docs-v2 - Set output path:
python scripts/flux-help-sync.py --output /path/to/flux-help.diff
Undocumented stubs
- If
--tag-undocumentedis used and a function has no matching documentation page, its description is tagged with(Undocumented)or set toUndocumented function.. - This only affects functions already present in
functions.ts.
Pruning
--prune-undocumentedremoves entries missing documentation pages.--prune-removedremoves entries missing documentation pages only if listed as removed incontent/flux/v0/release-notes.mdunder the docs repo root.
Notes and assumptions
- The docs root defaults to
../docs-v2. Override it with--docs-v2-repo-dir. - The script skips
_index.mdandall-functions.md. - It omits the
tablesparameter when the signature shows a piped input (<-tables). - Examples are always updated from docs for entries with matching pages.
- Examples are extracted from the first JavaScript example block by locating
the first call to the function and reducing it to a single-line call
expression (no pipeline, imports, or setup). Full-line and inline
//comments are removed before extracting the call. Trailing commas before a closing parenthesis are removed. If no call is found, new entries default tofunctionName(), and existing entries keep their current example. - Links are sourced directly from docs-v2 paths (for example,
.../flux/v0/stdlib/universe/...) and existing entries are updated to match. - Strings are quoted using single or double quotes to satisfy Prettier when apostrophes are present.
- If multiple doc pages share the same function name, the script prefers
non-deprecated entries. If descriptions differ, it keeps all unless the
only difference is a contrib variant (for example
from), in which case it prefers the non-contrib entry. Otherwise, it prefers non-experimental, non-contrib, and prelude packages. - Variant entries for input-source splits (for example
csv.from) are defined explicitly inVARIANT_SPECSin the script.