Skip to content

Commit 53cd203

Browse files
committed
docs: Add page standardization to external tool integrations
1 parent 48264d4 commit 53cd203

File tree

198 files changed

+1263
-1071
lines changed

Some content is hidden

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

198 files changed

+1263
-1071
lines changed

.ci/lint-docs-tool-page.sh

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#!/bin/bash
2+
set -e
3+
4+
python3 - << 'EOF'
5+
import os
6+
import re
7+
import sys
8+
from pathlib import Path
9+
10+
integration_dir = Path("./docs/en/integrations")
11+
if not integration_dir.exists():
12+
print("Info: Directory './docs/en/integrations' not found. Skipping linting.")
13+
sys.exit(0)
14+
15+
ALLOWED_ORDER = [
16+
"About",
17+
"Compatible Sources",
18+
"Requirements",
19+
"Parameters",
20+
"Example",
21+
"Output Format",
22+
"Reference",
23+
"Advanced Usage",
24+
"Troubleshooting",
25+
"Additional Resources"
26+
]
27+
REQUIRED = {"About", "Example"}
28+
29+
# Regex to catch any variation of the compatible-sources shortcode
30+
SHORTCODE_PATTERN = r"\{\{<\s*compatible-sources.*?>\}\}"
31+
32+
has_errors = False
33+
34+
# Find all .md files, excluding _index.md (which are Source pages)
35+
for filepath in integration_dir.rglob("*.md"):
36+
if filepath.name == "_index.md":
37+
continue
38+
39+
with open(filepath, "r", encoding="utf-8") as f:
40+
content = f.read()
41+
42+
# Separate YAML frontmatter from the markdown body
43+
match = re.match(r'^\s*---\s*\n(.*?)\n---\s*(.*)', content, re.DOTALL)
44+
if match:
45+
frontmatter = match.group(1)
46+
body = match.group(2)
47+
else:
48+
frontmatter = ""
49+
body = content
50+
51+
# If the file has no markdown content (metadata placeholder only), skip it entirely
52+
if not body.strip():
53+
continue
54+
55+
file_errors = False
56+
57+
# 1. Check Frontmatter Title
58+
title_source = frontmatter if frontmatter else content
59+
title_match = re.search(r"^title:\s*[\"']?(.*?)[\"']?\s*$", title_source, re.MULTILINE)
60+
if not title_match or not title_match.group(1).strip().endswith("Tool"):
61+
found_title = title_match.group(1) if title_match else "None"
62+
print(f"[{filepath}] Error: Frontmatter title must end with 'Tool'. Found: '{found_title}'")
63+
file_errors = True
64+
65+
# 2. Check Shortcode Placement
66+
sources_section_match = re.search(r"^##\s+Compatible Sources\s*(.*?)(?=^##\s|\Z)", body, re.MULTILINE | re.DOTALL)
67+
if sources_section_match:
68+
if not re.search(SHORTCODE_PATTERN, sources_section_match.group(1)):
69+
print(f"[{filepath}] Error: The compatible-sources shortcode must be placed under the '## Compatible Sources' heading.")
70+
file_errors = True
71+
else:
72+
# Prevent edge case where shortcode is used but the heading was forgotten
73+
if re.search(SHORTCODE_PATTERN, body):
74+
print(f"[{filepath}] Error: A compatible-sources shortcode was found, but the '## Compatible Sources' heading is missing.")
75+
file_errors = True
76+
77+
# 3. Strip code blocks from body to avoid linting example markdown headings
78+
clean_body = re.sub(r"```.*?```", "", body, flags=re.DOTALL)
79+
80+
# 4. Check H1 Headings
81+
if re.search(r"^#\s+\w+", clean_body, re.MULTILINE):
82+
print(f"[{filepath}] Error: H1 headings (#) are forbidden in the body.")
83+
file_errors = True
84+
85+
# 5. Check H2 Headings
86+
h2s = re.findall(r"^##\s+(.*)", clean_body, re.MULTILINE)
87+
h2s = [h2.strip() for h2 in h2s]
88+
89+
# Missing Required
90+
missing = REQUIRED - set(h2s)
91+
if missing:
92+
print(f"[{filepath}] Error: Missing required H2 headings: {missing}")
93+
file_errors = True
94+
95+
# Unauthorized Headings
96+
unauthorized = set(h2s) - set(ALLOWED_ORDER)
97+
if unauthorized:
98+
print(f"[{filepath}] Error: Unauthorized H2 headings found: {unauthorized}")
99+
file_errors = True
100+
101+
# Strict Ordering
102+
filtered_h2s = [h for h in h2s if h in ALLOWED_ORDER]
103+
expected_order = [h for h in ALLOWED_ORDER if h in h2s]
104+
if filtered_h2s != expected_order:
105+
print(f"[{filepath}] Error: Headings are out of order.")
106+
print(f" Expected: {expected_order}")
107+
print(f" Found: {filtered_h2s}")
108+
file_errors = True
109+
110+
if file_errors:
111+
has_errors = True
112+
113+
if has_errors:
114+
print("Linting failed for Tool pages. Please fix the structure errors above.")
115+
sys.exit(1)
116+
else:
117+
print("Success: All Tool pages passed structure validation.")
118+
EOF

.github/workflows/docs_lint.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ name: Lint Documentation
1717
on:
1818
pull_request:
1919
paths:
20-
- 'integrations/**/*.md'
21-
- '.ci/lint-docs-source-page.sh'
20+
- 'docs/**'
21+
- '.ci/lint-docs-*.sh'
2222

2323
jobs:
2424
lint-source-pages:
@@ -49,8 +49,11 @@ jobs:
4949
echo "Info: docs/ directory not found. Skipping file size check."
5050
fi
5151
52-
- name: Make script executable
53-
run: chmod +x .ci/lint-docs-source-page.sh
52+
- name: Make scripts executable
53+
run: chmod +x .ci/lint-docs-*.sh
5454

5555
- name: Run Structure Linter for Source Pages
56-
run: .ci/lint-docs-source-page.sh
56+
run: .ci/lint-docs-source-page.sh
57+
58+
- name: Run Structure Linter for Tool Pages
59+
run: .ci/lint-docs-tool-page.sh

docs/en/integrations/alloydb-admin/alloydb-create-cluster.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: alloydb-create-cluster
2+
title: alloydb-create-cluster Tool
33
type: docs
44
weight: 1
55
description: "The \"alloydb-create-cluster\" tool creates a new AlloyDB for PostgreSQL cluster in a specified project and location.\n"

docs/en/integrations/alloydb-admin/alloydb-create-instance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: alloydb-create-instance
2+
title: alloydb-create-instance Tool
33
type: docs
44
weight: 1
55
description: "The \"alloydb-create-instance\" tool creates a new AlloyDB instance within a specified cluster.\n"

docs/en/integrations/alloydb-admin/alloydb-create-user.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: alloydb-create-user
2+
title: alloydb-create-user Tool
33
type: docs
44
weight: 2
55
description: "The \"alloydb-create-user\" tool creates a new database user within a specified AlloyDB cluster.\n"

docs/en/integrations/alloydb-admin/alloydb-get-cluster.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: alloydb-get-cluster
2+
title: alloydb-get-cluster Tool
33
type: docs
44
weight: 1
55
description: "The \"alloydb-get-cluster\" tool retrieves details for a specific AlloyDB cluster.\n"

docs/en/integrations/alloydb-admin/alloydb-get-instance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: alloydb-get-instance
2+
title: alloydb-get-instance Tool
33
type: docs
44
weight: 1
55
description: "The \"alloydb-get-instance\" tool retrieves details for a specific AlloyDB instance.\n"

docs/en/integrations/alloydb-admin/alloydb-get-user.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: alloydb-get-user
2+
title: alloydb-get-user Tool
33
type: docs
44
weight: 1
55
description: "The \"alloydb-get-user\" tool retrieves details for a specific AlloyDB user.\n"

docs/en/integrations/alloydb-admin/alloydb-list-clusters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: alloydb-list-clusters
2+
title: alloydb-list-clusters Tool
33
type: docs
44
weight: 1
55
description: "The \"alloydb-list-clusters\" tool lists the AlloyDB clusters in a given project and location.\n"

docs/en/integrations/alloydb-admin/alloydb-list-instances.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: alloydb-list-instances
2+
title: alloydb-list-instances Tool
33
type: docs
44
weight: 1
55
description: "The \"alloydb-list-instances\" tool lists the AlloyDB instances for a given project, cluster and location.\n"

0 commit comments

Comments
 (0)