Skip to content

Commit 72fb730

Browse files
author
Charlie Egan
authored
docs: Update to allow better regal docs generation (#1578)
To be consumed by https://github.com/StyraInc/docs/pull/424 Signed-off-by: Charlie Egan <charlie@styra.com>
1 parent 72f0510 commit 72fb730

52 files changed

Lines changed: 1176 additions & 63 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 147 additions & 59 deletions
Large diffs are not rendered by default.

build/do.rq

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ job contains "pr" if {
9191

9292
# format
9393
fmt_all
94+
write_readme
9495
golangcilintfix
9596

9697
# verify
@@ -139,6 +140,14 @@ build(false) if {
139140
run("go build -tags=regal_standalone")
140141
} else := true
141142

143+
# METADATA
144+
# title: check_readme
145+
# description: Verify that the rules table in the README is up-to-date
146+
job contains "check_readme" if {
147+
build(true)
148+
check_readme
149+
}
150+
142151
# any binary is good enough when calling `build(false)`, it doesn't need to be
143152
# built freshly
144153
binary_present if {
@@ -161,14 +170,14 @@ e2e if {
161170
lint if {
162171
run("opa check --strict --capabilities build/capabilities.json bundle")
163172
run("./regal lint --format pretty bundle")
164-
run("npx --prefix build markdownlint --config docs/.markdownlint.yaml --ignore docs/CODE_OF_CONDUCT.md README.md docs/")
173+
run("npx --prefix build markdownlint --config docs/.markdownlint.yaml --ignore docs/CODE_OF_CONDUCT.md --ignore README.md docs/")
165174
run("npx --prefix build dprint --config build/dprint.json check")
166175
}
167176

168177
lint_ci if {
169178
run("opa check --strict --capabilities build/capabilities.json bundle")
170179
run_quiet("./regal lint --format github bundle")
171-
run("npx --prefix build markdownlint --config docs/.markdownlint.yaml --ignore docs/CODE_OF_CONDUCT.md README.md docs/")
180+
run("npx --prefix build markdownlint --config docs/.markdownlint.yaml --ignore docs/CODE_OF_CONDUCT.md --ignore README.md docs/")
172181
run("npx --prefix build dprint --config build/dprint.json check")
173182
}
174183

@@ -293,6 +302,14 @@ fetch_eopa_caps if {
293302
}
294303
}
295304

305+
check_readme if {
306+
run("./build/update-readme.sh check")
307+
}
308+
309+
write_readme if {
310+
run("./build/update-readme.sh write")
311+
}
312+
296313
fmt_all if {
297314
opafmt
298315
}

build/update-readme.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
README_SECTIONS_DIR="./docs/readme-sections"
4+
README_PATH="./README.md"
5+
MANIFEST="$README_SECTIONS_DIR/github-manifest"
6+
7+
if [[ $# -ne 1 ]]; then
8+
echo "Usage: $0 {check|write}"
9+
exit 1
10+
fi
11+
12+
MODE="$1"
13+
14+
# Create a temporary file to hold the new content
15+
tmpfile=$(mktemp)
16+
17+
# Build new content into tmpfile
18+
while IFS= read -r file; do
19+
section_path="$README_SECTIONS_DIR/$file"
20+
21+
if [[ -f "$section_path" ]]; then
22+
cat "$section_path" >> "$tmpfile"
23+
echo -e "\n" >> "$tmpfile"
24+
else
25+
echo "Warning: Section file not found: $section_path" >&2
26+
fi
27+
done < "$MANIFEST"
28+
29+
if [[ "$MODE" == "check" ]]; then
30+
if ! cmp -s "$tmpfile" "$README_PATH"; then
31+
echo "README.md is out of date. Please run '$0 write' to update it."
32+
rm "$tmpfile"
33+
exit 1
34+
else
35+
echo "README.md is up to date."
36+
fi
37+
elif [[ "$MODE" == "write" ]]; then
38+
mv "$tmpfile" "$README_PATH"
39+
echo "README.md has been updated."
40+
else
41+
echo "Unknown mode: $MODE"
42+
echo "Usage: $0 {check|write}"
43+
rm "$tmpfile"
44+
exit 1
45+
fi

docs/adopters.md.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sidebar_position: 13

docs/architecture.md.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sidebar_position: 4

docs/cicd.md.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sidebar_label: CI/CD
2+
sidebar_position: 8

docs/custom-rules.md.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sidebar_position: 5

docs/debug-adapter.md.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sidebar_position: 10

docs/editor-support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Editor support
1+
# Editor Support
22

33
## Visual Studio Code
44

docs/editor-support.md.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sidebar_position: 7

0 commit comments

Comments
 (0)