File tree Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Expand file tree Collapse file tree 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,17 @@ and execute the following command in the root of the repository:
76
76
77
77
The build files are found in the ` book ` directory.
78
78
79
+ ### Pre-commit script
80
+
81
+ We also test that line lengths are less than 100 columns. To test this locally,
82
+ you can run ` ci/check_line_lengths.sh ` .
83
+
84
+ You can also set this to run automatically with the following command:
85
+
86
+ ``` bash
87
+ ln -s ../../ci/check_line_lengths.sh .git/hooks/pre-commit
88
+ ```
89
+
79
90
### Link Validations
80
91
81
92
We use ` mdbook-linkcheck ` to validate URLs included in our documentation. To perform link checks, uncomment the ` [output.linkcheck] ` field in the ` book.toml ` configuration file and install ` mdbook-linkcheck ` with:
Original file line number Diff line number Diff line change 1
- #! /bin/bash
1
+ #! /usr/ bin/env bash
2
2
3
3
if [ " $1 " == " --help" ]; then
4
- echo ' Usage:'
5
- echo ' MAX_LINE_LENGTH=100' " $0 " ' src/**/*.md'
6
- exit 1
4
+ echo ' Usage:' " [MAX_LINE_LENGTH=n] $0 [file ...]"
5
+ exit 1
7
6
fi
8
7
9
8
if [ " $MAX_LINE_LENGTH " == " " ]; then
10
- echo ' `MAX_LINE_LENGTH` environment variable not set. Try --help.'
11
- exit 1
9
+ MAX_LINE_LENGTH=100
12
10
fi
13
11
14
12
if [ " $1 " == " " ]; then
15
- echo ' No files provided.'
16
- exit 1
13
+ files=( src/** /* .md )
14
+ else
15
+ files=( " $@ " )
17
16
fi
18
17
19
18
echo " Checking line lengths in all source files <= $MAX_LINE_LENGTH chars..."
20
19
21
20
echo " Offending files and lines:"
22
21
(( bad_lines = 0 ))
23
22
(( inside_block = 0 ))
24
- for file in " $@ " ; do
23
+ for file in " ${files[@]} " ; do
25
24
echo " $file "
26
25
(( line_no = 0 ))
27
26
while IFS=" " read -r line || [[ -n " $line " ]] ; do
You can’t perform that action at this time.
0 commit comments