-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregen_docs.sh
More file actions
49 lines (40 loc) · 1.16 KB
/
regen_docs.sh
File metadata and controls
49 lines (40 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
# SPDX-FileCopyrightText: 2026 Alexandre Gomes Gaigalas <alganet@gmail.com>
#
# SPDX-License-Identifier: ISC
_EOL='
'
IFS=
ROOT_DIR="$(cd "$(/bin/dirname "$0")" && /bin/pwd)"
/bin/find docs -name '*.md' | /bin/sort | {
test_no=1
max_header_length=0
while read -r md_file
do
line_no=0
last_line=''
current_h2=''
while read -r md_line
do
line_no=$((line_no + 1))
if
test -n "$md_line" &&
test -z "${md_line##-*}" &&
test ${#md_line} -eq ${#last_line}
then
current_h2="$last_line"
case $last_line in
'Compatibility')
last_line=
/bin/cat "${ROOT_DIR}/compat/${md_file#${ROOT_DIR}/docs/}"
break
;;
esac
fi
test $line_no -lt 2 || printf '%s\n' "$last_line"
last_line="$md_line"
done < "$md_file" > "$md_file.new"
printf '%s' "$last_line" >> "$md_file.new"
/bin/mv -f "$md_file.new" "$md_file"
done
}