Skip to content

Commit 441d648

Browse files
feat: handle cli ref docs
- add "autogenerated content" warning to cli reference docs page (`reference.md`) - add consistency check between pangraph binary and`reference.md` on CI - document the process of (re)generation of `reference.md`
1 parent 567a228 commit 441d648

File tree

6 files changed

+100
-31
lines changed

6 files changed

+100
-31
lines changed

Diff for: .github/workflows/cli.yml

+29
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,35 @@ jobs:
340340
.\.out\pangraph-x86_64-pc-windows-gnu --help
341341
342342
343+
check-cli-docs:
344+
name: "Check that autogenerated CLI documentation is up-to-date"
345+
needs: [ build-cli ]
346+
runs-on: ubuntu-24.04
347+
348+
steps:
349+
- name: "Checkout code"
350+
uses: actions/checkout@v4
351+
with:
352+
fetch-depth: 1
353+
submodules: true
354+
355+
- name: "Download build artifacts"
356+
uses: actions/download-artifact@v4
357+
with:
358+
pattern: pangraph-*
359+
merge-multiple: true
360+
path: ".out"
361+
362+
- name: "Re-generate CLI docs"
363+
run: |
364+
chmod +x ./.out/pangraph-x86_64-unknown-linux-gnu
365+
cd docs/
366+
./generate-reference-docs ../.out/pangraph-x86_64-unknown-linux-gnu docs/reference.md
367+
368+
- name: "Check that the git diff is clean"
369+
run: |
370+
git -c color.ui=always diff --exit-code 'docs/docs/reference.md' || (echo "Looks like command-line interface has changed, but the autogenerated CLI reference documentation at 'docs/docs/reference.md' is not up-to-date. Please build the fresh version of pangraph, then run 'cd docs && ./generate-reference-docs <path_to_pangraph> docs/docs/reference.md', then verify and commit changes to the file docs/docs/reference.md." >&2; exit 1)
371+
343372
344373
# publish-to-github-releases:
345374
# name: "Publish to GitHub Releases"

Diff for: docs/README.md

+24-3
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,32 @@ bun prod:serve
4747
The `build` command will produce the directory with HTML, CSS and JS files ready to be deployed to a web hosting. The `serve` command will serve these files on port `5000`.
4848

4949

50-
## Command-line reference generation
5150

52-
The `reference.md` file is generated using script `./scripts/update_cli_reference_docs`.
51+
## Generate command-line reference documentation
52+
53+
The `docs/docs/reference.md` file is generated using script `generate-reference-docs`:
54+
55+
```bash
56+
cargo build --bin=pangraph
57+
cd docs
58+
./generate-reference-docs "../target/debug/pangraph" "docs/docs/reference.md"
59+
```
60+
61+
> ⚠️ Do not edit the generated file manually! All manual changes will be overwritten by automation.
5362
5463

5564
## Deployment
5665

57-
TODO
66+
The documentation is automatically deployed on changes to `release-docs` branch. See [.github/workflows/docs.yml](../.github/workflows/docs.yml).
67+
68+
If you have documentation changes on `master` branch, which you want to release to the publicly facing documentation site (https://docs.pangraph.org/), then fast forward `release-docs` to `master`:
69+
70+
```bash
71+
git checkout release-docs
72+
git merge --ff-only origin/master
73+
git push origin release-docs
74+
```
75+
76+
You can combine it with the software release as well.
77+
78+
> ️⚠️ Make sure your local branches are up-to-date with the remote repo and that they don't have incompatible changes on them. Otherwise the fast-forward merge will fail. When manipulating `release-*` branches, consider using a git GUI application (e.g. GitKraken) to visually check that you do what you think you do.

Diff for: docs/docs/reference.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
---
22
sidebar_position: 9999
33
---
4-
# CLI commands
4+
5+
# Command-line reference
6+
7+
<!-- WARNING: GENERATED CONTENT -->
8+
<!-- Do not edit the generated file manually! All manual changes will be overwritten by automation. -->
9+
<!-- See developer guide for how to properly work with this. -->
10+
11+
:::warning
12+
Generated content. Report issues at https://github.com/neherlab/pangraph/issues
13+
:::
14+
15+
516

617

718
This document contains the automatically generated reference documentation for command-line arguments of the latest version of Pangraph CLI.
@@ -258,7 +269,7 @@ Export the core-genome alignment. Note that alignment excludes insertions
258269

259270
Generates a simplified graph that only contains a subset of the input genomes
260271

261-
**Usage:** `pangraph simplify [OPTIONS] [INPUT]`
272+
**Usage:** `pangraph simplify [OPTIONS] --strains <STRAINS> [INPUT]`
262273

263274
###### **Arguments:**
264275

Diff for: docs/generate-reference-docs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
trap "exit" INT
4+
5+
if [ "$#" != 2 ]; then
6+
echo "Re-generates CLI reference documentation in Markdown format"
7+
echo "Usage: $0 <executable> <output.md>"
8+
exit 1
9+
fi
10+
11+
exe="$1"
12+
out="$2"
13+
14+
# Add header
15+
cat << EOF > "${out}"
16+
---
17+
sidebar_position: 9999
18+
---
19+
20+
# Command-line reference
21+
22+
<!-- WARNING: GENERATED CONTENT -->
23+
<!-- Do not edit the generated file manually! All manual changes will be overwritten by automation. -->
24+
<!-- See developer guide for how to properly work with this. -->
25+
26+
:::warning
27+
Generated content. Report issues at https://github.com/neherlab/pangraph/issues
28+
:::
29+
30+
EOF
31+
32+
# Append body
33+
./"${exe}" help-markdown >> "${out}"

Diff for: packages/pangraph/src/commands/md_help/print_help_markdown.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::borrow::Cow;
66
pub fn print_help_markdown() -> Result<(), Report> {
77
let help = clap_markdown::help_markdown::<PangraphArgs>();
88

9-
let help = replace(&help, "# Command-Line Help for `pangraph`", "# Reference")?;
9+
let help = replace(&help, "# Command-Line Help for `pangraph`", "")?;
1010

1111
let help = replace(
1212
&help,

Diff for: scripts/update_cli_reference_docs

-25
This file was deleted.

0 commit comments

Comments
 (0)