-
Notifications
You must be signed in to change notification settings - Fork 9
/
update_config.sh
executable file
·46 lines (35 loc) · 1.38 KB
/
update_config.sh
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
#!/bin/sh
# Update the config documentation from its scdoc file.
if [ "$#" -ne 2 ]; then
echo "USAGE: update_config.sh <MANPAGE_DIR> <VERSION>"
exit 1
fi
manpage_dir=$(realpath "$1")
version="$2"
mkdir -p "./static/releases/$version"
for manpage in $(ls "$manpage_dir"/*.scd); do
# Log operation.
case "$manpage" in
*.1.scd)
outfile="./static/releases/$version/cmd-$(basename "$manpage" .1.scd).html"
;;
*.5.scd)
outfile="./static/releases/$version/config-$(basename "$manpage" .5.scd).html"
;;
esac
echo "Converting \"$manpage\" to \"$outfile\""
# Convert from scd to roff.
roff_name="$(basename "$manpage" .scd).roff"
scdoc < "$manpage" > "$roff_name"
# Convert from roff to html.
pandoc --template "./manpage_template.html" -f man -t html -s "$roff_name" -o "$outfile"
# Fix maintainers list.
sed -zi 's/<p>·<\/p>\n *<p>/<p>· /g' "$outfile"
# Automatically link other config pages.
sed -zi 's/<strong>\([^<]*\)<\/strong>(5)/<strong><a href=".\/config-\1.html">\1(5)<\/a><\/strong>/g' "$outfile"
sed -zi 's/<strong>\([^<]*\)<\/strong>(1)/<strong><a href=".\/cmd-\1.html">\1(1)<\/a><\/strong>/g' "$outfile"
# Delete roff file.
rm "$roff_name"
done
# Add version to JavaScript dropdown.
sed -i "s/const versions = \[/\0\n '$version',/" ./static/select_release.js