nosync-quiet option added courtesy Robin Johnson (Gentoo project)
[gitolite-doc.git] / bin / build
blob52abd0b6108d69342d99f4244dbd3a625353983e
1 #!/bin/bash
3 # this can only be done from a terminal; do not try to run it from cron or
4 # some other headless mechanism
6 # note: how.html is built manually, using
7 # cd docs; pdh -i how.mkd -o how.html -t html-N
9 # also, a lot of things in here are kinda hardcoded to my setup; if someone
10 # really wants me to clean it up so that it is more generic, I'll work on it
12 die() { echo "$@"; exit 1; }
14 [ -f mkdocs.yml ] || die "are you sure you're in the right directory?"
16 [ -d .git/gen-docs ] && mv .git/gen-docs .
17 [ "$1" = "clean" ] && rm -rf gen-docs
18 mkdir -p gen-docs/{code,contrib,css}
19 rsync -a docs/code gen-docs
20 rsync -a docs/css gen-docs
21 cp docs/gitweb.conf.html gen-docs
22 cp docs/how.html gen-docs
24 cd docs
26 # generate images
27 for f in `find . -name "*.gv"; find . -name "*.aa"`
29 new=${f/%aa/png}
30 new=${new/%gv/png}
31 [ -f ../gen-docs/$new ] && [ ../gen-docs/$new -nt $f ] && continue
32 echo -n >&2 $f...
33 ../bin/mkdocs.pre-build.image-gen $f ../gen-docs/$new
34 echo >&2 "done"
35 done
37 # generate mkd with vim-syntax; this step is slow, but this is the simplest
38 # way to support gitolite syntax highlighting in arbitrary markdown.
39 for f in `find . -name "*.mkd" | sort`
41 [ -f ../gen-docs/$f ] && [ ../gen-docs/$f -nt $f ] && continue
42 echo -n >&2 $f...
43 ../bin/mkdocs.pre-build.mkd-filter < $f > ../gen-docs/$f
44 echo >&2 "done"
45 done
47 # build site
48 cd ..
49 ~/.local/bin/mkdocs build
51 # 2023-03-07 somehow this is overwriting how.html, despite it not being listed in the yml, so we need to copy it again
52 cp docs/how.html site
54 # move them out of my way for normal use (some of my scripts are not
55 # gitignore-aware)
56 mv gen-docs .git
58 # # cater for people holding on to old links
59 # cd site
60 # for i in `find -type f -name index.html -printf "%h\n" | sort | cut -c3-`
61 # do
62 # j=$(basename $i)
63 # sed -e "s,%BASE,$i,g" <<EOF > $j.html
64 # <html>
65 # <head>
66 # <title>redirecting...</title>
67 # <meta http-equiv="refresh" content="2;URL='https://gitolite.com/gitolite/%BASE/index.html'" />
68 # </head>
69 # <body>
70 # <p>This page has moved; redirecting...</p>
71 # </body>
72 # </html>
73 # EOF
74 # done
76 # cd ..
78 rm -rf ../sitaramc.github.com/gitolite
79 mv site ../sitaramc.github.com/gitolite
80 cd ../sitaramc.github.com
81 git add -u
82 read -p "hit enter to start 'gs' followed by a push:"
83 vim -s <(echo gs; echo :only)
84 git pall -f