blob: 5b70db74cf8133b718a034b416b9f796d7e9858b (
plain)
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
|
#!/bin/sh
#
# Generate documentation
#
basedir="$(dirname "$0")"
[ "$(echo "$basedir" | cut -c1)" = '/' ] || basedir="$PWD/$basedir"
srcdir="$basedir/.."
die()
{
echo "$*" >&2
exit 1
}
gen()
{
local rst="$1"
local docname="$(basename "$rst" .rst)"
local dir="$(dirname "$rst")"
local html="$dir/$docname.html"
local md="$dir/$docname.md"
echo "Generating $(realpath --relative-to="$srcdir" "$html") from $(realpath --relative-to="$srcdir" "$rst") ..."
python3 -m readme_renderer -o "$html" "$rst" ||\
die "Failed to generate HTML."
echo "Generating $(realpath --relative-to="$srcdir" "$md") from $(realpath --relative-to="$srcdir" "$rst") ..."
pandoc -s -o "$md" "$rst" ||\
die "Failed to generate MD."
}
for i in $(find "$srcdir" \( -name release-archives -prune \) -o \( -name target -prune \) -o \( -name '*.rst' -print \)); do
gen "$i"
done
cd "$srcdir" || die "cd failed."
cargo doc || die "cargo doc failed."
exit 0
|