This repository has been archived by the owner on May 6, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mkdocs.sh
executable file
·81 lines (65 loc) · 1.76 KB
/
mkdocs.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
godocport=6061
pkgs="\
dialog \
glcaps \
humanizex \
lxstrconv \
operator
"
# build go.html, READMEs, etc.
go run internal/doc/doc.go $pkgs
eval `go env`
# add symlinks to default godoc template files (everything except "*.go")
prefix=$GOPATH/src/golang.org/x/tools/godoc/static/
templates=$(find $prefix -type f \( ! -iname '*.go' \))
for i in $templates
do
# strip prefix
file=${i/#$prefix}
dest="internal/godoc/$file"
# make directories as needed
dir=$(dirname $file)
mkdir -p "internal/godoc/$dir"
# symlink if doesn't already exist
if [ ! -e $dest ]; then
echo "$file => $dest"
ln -s "$prefix$file" "$dest"
fi
done
# start godoc server with customised templates
godoc -http=:$godocport -templates="internal/godoc" -notes="BUG|TODO|FIXME" &
pid=$!
sleep 1
# extract
# (https://github.com/golang/go/issues/2381#issuecomment-66059484)
mkdir -p doc
rm -r doc
wget -q -nv -e robots=off \
--cut-dirs 3 \
-P doc/ \
-A go,html,css,js,gif,png \
-r -nH -E -p -k \
--restrict-file-names=windows \
-I /src/tawesoft.co.uk/go,/pkg/builtin,/pkg/tawesoft.co.uk/go,/lib \
http://localhost:$godocport/
# --restrict-file-names=windows - dont use questionarms
# -R reject
# -A accept
# -P dest dir
# -r : download recursive
# -np : don't ascend to the parent directory
# -nd : no directories
# -nc : no clobber
# -E : add extension .html to html files (if they don't have)
# -p : download all necessary files for each page (css, js, images)
# -k : convert links to relative
# -nv : no verbose
# -nH : Disable generation of host-prefixed directories.
# close server
kill -1 $pid
echo "OK"
# build HTML pages for examples
cd internal/doc/examples
go run doc.go $pkgs
cd ../../../