OLD | NEW |
| (Empty) |
1 #!/bin/bash -e | |
2 shopt -s nullglob | |
3 | |
4 cd $(dirname "$0") | |
5 | |
6 # Script which takes all the asciidoc git-*.txt files in this directory, renders | |
7 # them to html + manpage format using git 1.9's doc toolchain, then puts | |
8 # them in depot_tools to be committed. | |
9 | |
10 ensure_in_path() { | |
11 local CMD=$1 | |
12 local PTH=$(which "$CMD") | |
13 if [[ ! $PTH ]] | |
14 then | |
15 echo Must have "$CMD" on your PATH! | |
16 exit 1 | |
17 else | |
18 echo Using \'$PTH\' for ${CMD}. | |
19 fi | |
20 } | |
21 | |
22 ensure_in_path xmlto | |
23 | |
24 DFLT_CATALOG_PATH="/usr/local/etc/xml/catalog" | |
25 if [[ ! $XML_CATALOG_FILES && -f "$DFLT_CATALOG_PATH" ]] | |
26 then | |
27 # Default if you install doctools with homebrew on mac | |
28 export XML_CATALOG_FILES="$DFLT_CATALOG_PATH" | |
29 echo Using \'$DFLT_CATALOG_PATH\' for \$XML_CATALOG_FILES. | |
30 fi | |
31 | |
32 # We pull asciidoc to get the right version | |
33 BRANCH=8.6.9 | |
34 ASCIIDOC_HASH=7fed0aff1b30 | |
35 if [[ ! -d asciidoc || $(cd asciidoc && hg id -i) != $ASCIIDOC_HASH ]] | |
36 then | |
37 echo Cloning asciidoc | |
38 rm -rf asciidoc | |
39 hg clone -r $BRANCH https://asciidoc.googlecode.com/hg/ asciidoc | |
40 (cd asciidoc && ln -s asciidoc.py asciidoc) | |
41 fi | |
42 echo Asciidoc up to date at $ASCIIDOC_HASH \($BRANCH\) | |
43 | |
44 export PATH=`pwd`/asciidoc:$PATH | |
45 | |
46 # We pull ansi2hash to convert demo script output | |
47 BRANCH=1.0.6 | |
48 ANSI2HTML_HASH=6282ab7a24a5a7eab2e0b23bb0055234c533a6e9 | |
49 if [[ ! -d ansi2html || $(git -C ansi2html rev-parse HEAD) != $ANSI2HTML_HASH ]] | |
50 then | |
51 echo Cloning ansi2html | |
52 rm -rf ansi2html | |
53 git clone --single-branch --branch $BRANCH --depth 1 \ | |
54 https://github.com/ralphbean/ansi2html.git 2> /dev/null | |
55 curl https://bitbucket.org/gutworth/six/raw/a875ac34c777fe801569c6c5299bf1a35a
a578cd/six.py > \ | |
56 ansi2html/ansi2html/six.py | |
57 ed ansi2html/ansi2html/converter.py <<EOF | |
58 /version_str | |
59 s/pkg.*$/'cool version bro' | |
60 wq | |
61 EOF | |
62 fi | |
63 | |
64 echo ansi2html up to date at $ANSI2HTML_HASH \($BRANCH\) | |
65 | |
66 # We pull git to get its documentation toolchain | |
67 BRANCH=v1.9.0 | |
68 GITHASH=5f95c9f850b19b368c43ae399cc831b17a26a5ac | |
69 if [[ ! -d git || $(git -C git rev-parse HEAD) != $GITHASH ]] | |
70 then | |
71 echo Cloning git | |
72 rm -rf git | |
73 git clone --single-branch --branch $BRANCH --depth 1 \ | |
74 https://kernel.googlesource.com/pub/scm/git/git.git 2> /dev/null | |
75 | |
76 # Replace the 'source' and 'package' strings. | |
77 ed git/Documentation/asciidoc.conf <<EOF | |
78 H | |
79 81 | |
80 s/Git/depot_tools | |
81 +2 | |
82 s/Git Manual/Chromium depot_tools Manual | |
83 wq | |
84 EOF | |
85 | |
86 # fix Makefile to include non-_-prefixed files as MAN7 entries | |
87 { | |
88 shopt -s extglob | |
89 echo H | |
90 echo 35 | |
91 for x in "$(echo !(git-*|_*).txt)" | |
92 do | |
93 echo i | |
94 echo MAN7_TXT += $x | |
95 echo . | |
96 done | |
97 echo wq | |
98 } | ed git/Documentation/Makefile | |
99 | |
100 # fix build-docdep.perl to ignore attributes on include::[] macros | |
101 ed git/Documentation/build-docdep.perl <<EOF | |
102 H | |
103 12 | |
104 c | |
105 s/\[[^]]*\]//; | |
106 . | |
107 wq | |
108 EOF | |
109 | |
110 # Add additional CSS override file | |
111 ed git/Documentation/Makefile <<EOF | |
112 H | |
113 /ASCIIDOC_EXTRA | |
114 a | |
115 -a stylesheet=$(pwd)/git/Documentation/asciidoc-override.css | |
116 . | |
117 -1 | |
118 j | |
119 /^\$(MAN_HTML): | |
120 a | |
121 asciidoc-override.css | |
122 . | |
123 -1 | |
124 j | |
125 wq | |
126 EOF | |
127 | |
128 cat >> git/Documentation/asciidoc.conf <<EOF | |
129 | |
130 [macros] | |
131 (?su)[\\\\]?(?P<name>demo):(?P<target>\S*?)\[\]= | |
132 | |
133 [demo-inlinemacro] | |
134 {sys3:cd $(pwd); ./{docname}.demo.{target}.sh | python filter_demo_output.py {ba
ckend} } | |
135 EOF | |
136 | |
137 fi | |
138 echo Git up to date at $GITHASH \($BRANCH\) | |
139 | |
140 if [[ ! -d demo_repo ]] | |
141 then | |
142 ./prep_demo_repo.sh | |
143 fi | |
144 | |
145 # build directory files for 'essential' and 'helper' sections of the depot_tools | |
146 # manpage. | |
147 for category in helper essential | |
148 do | |
149 { | |
150 PRINTED_BANNER=0 | |
151 for x in *.${category}.txt | |
152 do | |
153 # If we actually have tools in the category, print the banner first. | |
154 if [[ $PRINTED_BANNER != 1 ]] | |
155 then | |
156 PRINTED_BANNER=1 | |
157 # ex. | |
158 # CATEGORY TOOLS | |
159 # -------------- | |
160 BANNER=$(echo $category tools | awk '{print toupper($0)}') | |
161 echo $BANNER | |
162 for i in $(seq 1 ${#BANNER}) | |
163 do | |
164 echo -n - | |
165 done | |
166 echo | |
167 cat _${category}_prefix.txt 2> /dev/null || true | |
168 echo | |
169 fi | |
170 | |
171 # ex. | |
172 # linkgit:git-tool[1]:: | |
173 # \tinclude::_git-tool_desc.category.txt[] | |
174 PLAIN_PATH=${x%%_desc.*.txt} | |
175 PLAIN_PATH=${PLAIN_PATH:1} | |
176 echo "linkgit:$PLAIN_PATH[1]::" | |
177 echo -e "include::${x}[]" | |
178 echo | |
179 done | |
180 } > __${category}.txt | |
181 done | |
182 | |
183 JOBS=1 | |
184 HTML_TARGETS=() | |
185 MAN1_TARGETS=() | |
186 MAN7_TARGETS=() | |
187 for x in *.txt *.css | |
188 do | |
189 TO="git/Documentation/$x" | |
190 if [[ ! -f "$TO" ]] || ! cmp --silent "$x" "$TO" | |
191 then | |
192 echo \'$x\' differs | |
193 cp $x "$TO" | |
194 # Exclude files beginning with _ from the target list. This is useful to | |
195 # have includable snippet files. | |
196 if [[ ${x:0:1} != _ && ${x:(-4)} == .txt ]] | |
197 then | |
198 HTML_TARGETS+=("${x%%.txt}.html") | |
199 if [[ ! "$NOMAN" ]] | |
200 then | |
201 if [[ ${x:0:3} == git ]] | |
202 then | |
203 MAN1_TARGETS+=("${x%%.txt}.1") | |
204 else | |
205 MAN7_TARGETS+=("${x%%.txt}.7") | |
206 fi | |
207 fi | |
208 JOBS=$[$JOBS + 2] | |
209 fi | |
210 fi | |
211 done | |
212 | |
213 if [[ ${#HTML_TARGETS} == 0 && ${#MAN1_TARGETS} == 0 && ${#MAN7_TARGETS} == 0 ]] | |
214 then | |
215 exit | |
216 fi | |
217 | |
218 VER="v$(git rev-parse --short HEAD)" | |
219 if [[ ! -f git/version ]] || ! cmp --silent git/version <(echo "$VER") | |
220 then | |
221 echo Version changed, cleaning. | |
222 echo "$VER" > git/version | |
223 (cd git/Documentation && make clean) | |
224 fi | |
225 | |
226 # This export is so that asciidoc sys snippets which invoke git run relative to | |
227 # depot_tools instead of the git clone. | |
228 ( | |
229 export GIT_DIR="$(git rev-parse --git-dir)" && | |
230 cd git/Documentation && | |
231 make -j"$JOBS" "${MAN1_TARGETS[@]}" "${MAN7_TARGETS[@]}" "${HTML_TARGETS[@]}" | |
232 ) | |
233 | |
234 for x in "${HTML_TARGETS[@]}" | |
235 do | |
236 echo Copying ../html/$x | |
237 tr -d '\015' <"git/Documentation/$x" >"../html/$x" | |
238 done | |
239 | |
240 for x in "${MAN1_TARGETS[@]}" | |
241 do | |
242 echo Copying ../man1/$x | |
243 cp "git/Documentation/$x" ../man1 | |
244 done | |
245 | |
246 for x in "${MAN7_TARGETS[@]}" | |
247 do | |
248 echo Copying ../man7/$x | |
249 cp "git/Documentation/$x" ../man7 | |
250 done | |
OLD | NEW |