Skip to content

Commit 4bef2a2

Browse files
committed
feat: Set up pre-commit hooks with AsciiDoc linter
- Add .pre-commit-config.yaml with AsciiDoc linter hook - Add .pre-commit-install.sh installation script - Update CONTRIBUTING.adoc with developer setup section - Hooks run automatically on git commit - Validates all .adoc files before commit Closes #82
1 parent 6458e24 commit 4bef2a2

3 files changed

Lines changed: 99 additions & 0 deletions

File tree

.pre-commit-config.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Pre-commit hooks for Semantic Anchors
2+
# Install: pip install pre-commit
3+
# Setup: pre-commit install
4+
# Run manually: pre-commit run --all-files
5+
6+
repos:
7+
# AsciiDoc Linter
8+
- repo: local
9+
hooks:
10+
- id: asciidoc-linter
11+
name: AsciiDoc Linter
12+
entry: asciidoc-linter
13+
language: system
14+
files: \.adoc$
15+
pass_filenames: true
16+
args: [--format, console]
17+
stages: [commit]
18+
19+
# Trailing whitespace
20+
- repo: https://github.com/pre-commit/pre-commit-hooks
21+
rev: v4.5.0
22+
hooks:
23+
- id: trailing-whitespace
24+
exclude: \.(adoc|md)$
25+
- id: end-of-file-fixer
26+
exclude: \.(adoc|md)$
27+
- id: check-yaml
28+
- id: check-json
29+
- id: check-added-large-files
30+
args: [--maxkb=1000]

.pre-commit-install.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# Installation script for pre-commit hooks
3+
4+
set -e
5+
6+
echo "Installing pre-commit framework..."
7+
8+
# Check if Python is available
9+
if ! command -v python3 &> /dev/null; then
10+
echo "Error: Python 3 is required"
11+
exit 1
12+
fi
13+
14+
# Install pre-commit
15+
pip install pre-commit
16+
17+
# Install AsciiDoc linter
18+
pip install git+https://github.com/doctoolchain/asciidoc-linter.git
19+
20+
# Install pre-commit hooks
21+
pre-commit install
22+
23+
echo "✓ Pre-commit hooks installed successfully!"
24+
echo ""
25+
echo "Usage:"
26+
echo " - Hooks run automatically on 'git commit'"
27+
echo " - Run manually: pre-commit run --all-files"
28+
echo " - Update hooks: pre-commit autoupdate"

CONTRIBUTING.adoc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,47 @@ Evaluate the response:
6161
* *Depth:* Does it cover multiple related concepts?
6262
* *Specificity:* Is the scope well-defined?
6363

64+
== Developer Setup
65+
66+
=== Prerequisites
67+
68+
* Git
69+
* Python 3.12+ (for pre-commit hooks)
70+
* Node.js 20+ (for website development, optional)
71+
72+
=== Installing Pre-Commit Hooks
73+
74+
**Required for all contributors!**
75+
76+
Run the installation script:
77+
78+
[source,bash]
79+
----
80+
./pre-commit-install.sh
81+
----
82+
83+
This installs:
84+
85+
* **AsciiDoc Linter** - validates anchor file syntax automatically
86+
* **pre-commit framework** - runs checks before each commit
87+
* **Standard hooks** - trailing whitespace, YAML/JSON validation
88+
89+
=== Manual Hook Execution
90+
91+
Run all hooks on all files:
92+
93+
[source,bash]
94+
----
95+
pre-commit run --all-files
96+
----
97+
98+
Run specific hook:
99+
100+
[source,bash]
101+
----
102+
pre-commit run asciidoc-linter --all-files
103+
----
104+
64105
== How to Propose a New Anchor
65106

66107
We use an *automated workflow with GitHub Copilot* to validate and enrich proposals:

0 commit comments

Comments
 (0)