Skip to content

Commit dc8699a

Browse files
feat(docs): add documentation validation with CI integration and pre-commit hooks (#59)
1 parent 27d45ca commit dc8699a

File tree

8 files changed

+1591
-12
lines changed

8 files changed

+1591
-12
lines changed

.github/workflows/pr-build-and-check.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,61 @@ jobs:
3333
- name: Run Tests
3434
run: yarn test
3535

36+
docs-check:
37+
name: Documentation Validation
38+
runs-on: ubuntu-latest
39+
defaults:
40+
run:
41+
working-directory: docs
42+
steps:
43+
- name: Checkout Repo
44+
uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
48+
- name: Check for docs changes
49+
id: docs-changes
50+
working-directory: .
51+
run: |
52+
DOCS_CHANGED=$(git diff --name-only origin/main...HEAD -- docs/ | grep '\.md$' || true)
53+
if [ -z "$DOCS_CHANGED" ]; then
54+
echo "skip=true" >> "$GITHUB_OUTPUT"
55+
echo "No markdown changes in docs/"
56+
else
57+
echo "skip=false" >> "$GITHUB_OUTPUT"
58+
DELIM=$(openssl rand -hex 8)
59+
echo "changed_files<<$DELIM" >> "$GITHUB_OUTPUT"
60+
echo "$DOCS_CHANGED" >> "$GITHUB_OUTPUT"
61+
echo "$DELIM" >> "$GITHUB_OUTPUT"
62+
echo "Changed docs files:"
63+
echo "$DOCS_CHANGED"
64+
fi
65+
66+
- name: Setup Node.js
67+
if: steps.docs-changes.outputs.skip != 'true'
68+
uses: actions/setup-node@v4
69+
with:
70+
node-version: "22"
71+
72+
- name: Enable Corepack
73+
if: steps.docs-changes.outputs.skip != 'true'
74+
run: corepack enable
75+
76+
- name: Install docs dependencies
77+
if: steps.docs-changes.outputs.skip != 'true'
78+
run: yarn install --immutable
79+
80+
- name: Build documentation (validates internal links)
81+
if: steps.docs-changes.outputs.skip != 'true'
82+
run: yarn build
83+
84+
- name: Check external links in changed files
85+
if: steps.docs-changes.outputs.skip != 'true'
86+
run: |
87+
FILES=$(echo "${{ steps.docs-changes.outputs.changed_files }}" | sed 's|^docs/||' | xargs)
88+
echo "Checking files: $FILES"
89+
yarn markdown-link-check --config .markdown-link-check.json $FILES
90+
3691
version-check:
3792
name: Version Bump Check
3893
runs-on: ubuntu-latest

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarn lint-staged

.lintstagedrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"src/**/*.ts": ["eslint", "prettier --check"],
3+
"{*.{js,ts,json,yml,yaml},.github/**/*.yml}": "prettier --check --ignore-unknown",
4+
"docs/**/*.md": "yarn markdown-link-check --config docs/.markdown-link-check.json"
5+
}

docs/.markdown-link-check.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"ignorePatterns": [
3+
{ "pattern": "^<!--@include:" },
4+
{ "pattern": "^/" },
5+
{ "pattern": "^\\.{1,2}/" },
6+
{ "pattern": "^#" }
7+
],
8+
"httpHeaders": [
9+
{
10+
"urls": ["https://github.com"],
11+
"headers": { "Accept": "text/html" }
12+
}
13+
],
14+
"timeout": "10s",
15+
"retryOn429": true,
16+
"retryCount": 3,
17+
"fallbackRetryDelay": "5s",
18+
"aliveStatusCodes": [200, 206, 301, 302]
19+
}

docs/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
"scripts": {
88
"dev": "vitepress dev",
99
"build": "vitepress build",
10-
"preview": "vitepress preview"
10+
"preview": "vitepress preview",
11+
"lint:links": "markdown-link-check --config .markdown-link-check.json"
1112
},
1213
"devDependencies": {
14+
"markdown-link-check": "^3.13.6",
1315
"vitepress": "^1.5.0"
1416
},
1517
"engines": {

0 commit comments

Comments
 (0)