Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/update-ref-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ jobs:
sed -i 's/>/\>/g' "./out.md"
sed -i 's/__BR_TAG__/<br \/>/g' "./out.md"

# crd-ref-docs's markdown renderer emits multiple consecutive blank
# lines around headings/descriptions. Collapse runs of 2+ blank
# lines to a single one so regenerating doesn't churn whitespace
# against the committed page on every run.
echo "Collapsing excess blank lines..."
sed -i ':a;N;$!ba;s/\n\{3,\}/\n\n/g' "./out.md"

# Drop crd-ref-docs's default leading `# API Reference` H1: Hextra
# renders the frontmatter title as the page H1, so a body H1 would
# duplicate it (same reasoning as the Helm chart step below).
sed -i '0,/^# /{/^# /d}' "./out.md"

# The H1 removal leaves a blank line where the heading was; strip
# leading blank lines so it doesn't stack with the frontmatter's
# own trailing blank line once appended below.
sed -i '/./,$!d' "./out.md"

# Write the Hugo page: plain YAML frontmatter + generated body.
mkdir -p "$(dirname "$KAGENT_API_PAGE")"
cat > "$KAGENT_API_PAGE" <<'EOF'
Expand All @@ -137,6 +154,11 @@ jobs:
cat "./out.md" >> "$KAGENT_API_PAGE"
rm -f "./out.md"

# Normalize to exactly one trailing newline. crd-ref-docs can leave
# trailing blank lines at EOF that would otherwise churn on every
# regeneration even though nothing meaningful changed.
printf '%s\n' "$(cat "$KAGENT_API_PAGE")" > "$KAGENT_API_PAGE"

# Verify the output file was created
if [ ! -f "$KAGENT_API_PAGE" ]; then
echo "Error: Failed to create API docs page"
Expand Down Expand Up @@ -192,6 +214,18 @@ jobs:
sed -i 's/>/\&gt;/g' "./out.md"
sed -i 's/__BR_TAG__/<br \/>/g' "./out.md"

# See the kagent step above for rationale: collapse crd-ref-docs's
# excess blank lines so this doesn't churn whitespace every run.
echo "Collapsing excess blank lines..."
sed -i ':a;N;$!ba;s/\n\{3,\}/\n\n/g' "./out.md"

# See the kagent step above for rationale: drop the duplicate H1.
sed -i '0,/^# /{/^# /d}' "./out.md"

# See the kagent step above for rationale: strip the leading blank
# line the H1 removal leaves behind.
sed -i '/./,$!d' "./out.md"

# Write the Hugo page: plain YAML frontmatter + generated body.
mkdir -p "$(dirname "$KMCP_API_PAGE")"
cat > "$KMCP_API_PAGE" <<'EOF'
Expand All @@ -207,6 +241,9 @@ jobs:
cat "./out.md" >> "$KMCP_API_PAGE"
rm -f "./out.md"

# See the kagent step above for rationale: normalize trailing newline.
printf '%s\n' "$(cat "$KMCP_API_PAGE")" > "$KMCP_API_PAGE"

# Verify the output file was created
if [ ! -f "$KMCP_API_PAGE" ]; then
echo "Error: Failed to create KMCP API docs page"
Expand Down Expand Up @@ -280,6 +317,11 @@ jobs:
# title as the page H1, so a body H1 would duplicate it.
sed -i '0,/^# /{/^# /d}' "helm-temp.md"

# The H1 removal leaves a blank line where the heading was; strip
# leading blank lines so it doesn't stack with the frontmatter's
# own trailing blank line once appended into $HELM_PAGE below.
sed -i '/./,$!d' "helm-temp.md"

# Wrap version placeholders in inline code so they show literally.
python - <<'PY'
import re
Expand Down Expand Up @@ -325,6 +367,10 @@ jobs:
cat "helm-temp.md" >> "$HELM_PAGE"
rm -f "helm-temp.md"

# Normalize to exactly one trailing newline, same as the API ref
# pages above.
printf '%s\n' "$(cat "$HELM_PAGE")" > "$HELM_PAGE"

echo "Final generated file contents (first 50 lines):"
head -50 "$HELM_PAGE"

Expand Down
Loading