Skip to content

Commit 3092df5

Browse files
Add docs validation (#105)
Check html, css and links in docs directory.
1 parent 42fda91 commit 3092df5

File tree

7 files changed

+2834
-3
lines changed

7 files changed

+2834
-3
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Docs Validation
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
paths:
7+
- 'docs/**'
8+
- '.github/workflows/docs-validation.yml'
9+
- 'makefile'
10+
- 'package.json'
11+
- '.stylelintrc.json'
12+
pull_request:
13+
branches: [ main, develop ]
14+
paths:
15+
- 'docs/**'
16+
- '.github/workflows/docs-validation.yml'
17+
- 'makefile'
18+
- 'package.json'
19+
- '.stylelintrc.json'
20+
21+
jobs:
22+
validate-docs:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: '20'
33+
cache: 'npm'
34+
35+
- name: Install docs validation dependencies
36+
run: make docs-install-deps
37+
38+
- name: Run complete docs validation
39+
run: make docs-validate

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.DS_Store
22
bin/
33
.idea
4+
node_modules

.stylelintrc.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": ["stylelint-config-standard"],
3+
"rules": {
4+
"property-no-vendor-prefix": null,
5+
"selector-class-pattern": null,
6+
"custom-property-pattern": null,
7+
"declaration-block-single-line-max-declarations": null,
8+
"color-function-notation": null,
9+
"font-family-name-quotes": null,
10+
"rule-empty-line-before": null,
11+
"shorthand-property-no-redundant-values": null,
12+
"color-function-alias-notation": null,
13+
"alpha-value-notation": null,
14+
"at-rule-empty-line-before": null,
15+
"media-feature-range-notation": null
16+
}
17+
}

docs/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ <h2>Generate Serializers</h2>
8181

8282
<h2>Write STEF Records</h2>
8383
<pre><code class="language-go">// Prepare a memory buffer to write the STEF stream to.
84-
buf := &pkg.MemChunkWriter{}
84+
buf := &amp;pkg.MemChunkWriter{}
8585

8686
// Create a Writer for the JSON-like schema
8787
w := jsonlike.NewWriter(buf, pkg.WriterOptions{})
@@ -102,7 +102,7 @@ <h2>Learn More</h2>
102102
<li><a href="https://github.com/splunk/stef">GitHub Repository</a></li>
103103
</ul>
104104
<h2>License</h2>
105-
Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>.</p>
105+
Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>.
106106
</main>
107107
<script src="https://cdn.jsdelivr.net/npm/[email protected]/prism.js"></script>
108108
<script src="https://cdn.jsdelivr.net/npm/[email protected]/components/prism-go.min.js"></script>

makefile

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ default:
1717
cd benchmarks && make
1818

1919
.PHONY: all
20-
all:
20+
all: docs-validate
2121
cd stefgen && make all
2222
cd go/pkg && make all
2323
cd go/grpc && make all
@@ -64,3 +64,66 @@ MODULES := go/pkg go/grpc go/otel go/pdata
6464
releasever: verifyver
6565
echo Tagging version $(VERSION)
6666
$(foreach gomod,$(MODULES),$(call exec-command,git tag $(gomod)/$(VERSION) && git push origin $(gomod)/$(VERSION)))
67+
68+
# Docs validation targets
69+
.PHONY: docs-validate docs-validate-html docs-validate-css docs-check-links docs-install-deps
70+
71+
# Validate all docs (HTML, CSS, and links)
72+
docs-validate: docs-validate-html docs-validate-css docs-check-links
73+
@echo "✅ All docs validation checks passed!"
74+
75+
# Validate HTML files in docs directory
76+
docs-validate-html:
77+
@echo "🔍 Validating HTML files in docs..."
78+
@cd docs && for file in *.html; do \
79+
if [ -f "$$file" ] && [ "$$file" != "benchmarks.html" ]; then \
80+
echo "Validating $$file..."; \
81+
../node_modules/.bin/html-validate "$$file" || (echo "❌ HTML validation failed for $$file" && exit 1); \
82+
elif [ -f "$$file" ] && [ "$$file" = "benchmarks.html" ]; then \
83+
echo "Skipping validation for $$file (excluded)"; \
84+
fi; \
85+
done
86+
@echo "✅ HTML validation complete"
87+
88+
# Validate CSS files in docs directory
89+
docs-validate-css:
90+
@echo "🔍 Validating CSS files in docs..."
91+
@cd docs && for file in *.css; do \
92+
if [ -f "$$file" ]; then \
93+
echo "Validating $$file..."; \
94+
../node_modules/.bin/stylelint "$$file" --config-basedir .. || (echo "❌ CSS validation failed for $$file" && exit 1); \
95+
fi; \
96+
done
97+
@echo "✅ CSS validation complete"
98+
99+
# Check links in HTML files
100+
docs-check-links:
101+
@for file in docs/*.html; do \
102+
if [ -f "$$file" ]; then \
103+
echo "Checking links in $$(basename $$file)..."; \
104+
./node_modules/.bin/markdown-link-check "$$file" --quiet || true; \
105+
echo " ✅ Link check completed for $$(basename $$file)"; \
106+
fi; \
107+
done
108+
@echo "✅ Link checking complete"
109+
110+
# Install npm-based validation dependencies for docs
111+
docs-install-deps:
112+
@echo "📦 Installing npm-based validation dependencies at top level..."
113+
@if ! command -v npm >/dev/null 2>&1; then \
114+
echo "❌ npm not found. Please install Node.js and npm first."; \
115+
echo "Visit: https://nodejs.org/"; \
116+
exit 1; \
117+
fi
118+
@if [ ! -f package.json ]; then \
119+
echo "Creating package.json..."; \
120+
npm init -y; \
121+
fi
122+
@echo "Installing HTML validation tools..."
123+
@npm install html-validate
124+
@echo "Installing CSS validation tools..."
125+
@npm install stylelint stylelint-config-standard
126+
@echo "Installing link checking tools..."
127+
@npm install markdown-link-check
128+
@echo "✅ All docs dependencies installed successfully!"
129+
@echo "Tools installed in ./node_modules/.bin/"

0 commit comments

Comments
 (0)