OLD | NEW |
| (Empty) |
1 #!/bin/bash | |
2 | |
3 # Copyright 2015 The Crashpad Authors. All rights reserved. | |
4 # | |
5 # Licensed under the Apache License, Version 2.0 (the "License"); | |
6 # you may not use this file except in compliance with the License. | |
7 # You may obtain a copy of the License at | |
8 # | |
9 # http://www.apache.org/licenses/LICENSE-2.0 | |
10 # | |
11 # Unless required by applicable law or agreed to in writing, software | |
12 # distributed under the License is distributed on an "AS IS" BASIS, | |
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 # See the License for the specific language governing permissions and | |
15 # limitations under the License. | |
16 | |
17 set -e | |
18 | |
19 # Generating AsciiDoc documentation requires AsciiDoc, | |
20 # http://www.methods.co.nz/asciidoc/. For “man” and PDF output, a DocBook | |
21 # toolchain including docbook-xml and docbook-xsl is also required. | |
22 | |
23 # Run from the Crashpad project root directory. | |
24 cd "$(dirname "${0}")/../.." | |
25 | |
26 source doc/support/compat.sh | |
27 | |
28 output_dir=out/doc | |
29 | |
30 rm -rf \ | |
31 "${output_dir}/doc" \ | |
32 "${output_dir}/man" | |
33 mkdir -p \ | |
34 "${output_dir}/doc/html" \ | |
35 "${output_dir}/man/html" \ | |
36 "${output_dir}/man/man" | |
37 | |
38 # Get the version from package.h. | |
39 version=$(${sed_ext} -n -e 's/^#define PACKAGE_VERSION "(.*)"$/\1/p' package.h) | |
40 | |
41 generate() { | |
42 input="$1" | |
43 type="$2" | |
44 | |
45 case "${type}" in | |
46 doc) | |
47 doctype="article" | |
48 ;; | |
49 man) | |
50 doctype="manpage" | |
51 ;; | |
52 *) | |
53 echo "${0}: unknown type ${type}" >& 2 | |
54 exit 1 | |
55 ;; | |
56 esac | |
57 | |
58 echo "${input}" | |
59 | |
60 base=$(${sed_ext} -e 's%^.*/([^/]+)\.ad$%\1%' <<< "${input}") | |
61 | |
62 # Get the last-modified date of $input according to Git, in UTC. | |
63 git_time_t="$(git log -1 --format=%at "${input}")" | |
64 git_date="$(LC_ALL=C ${date_time_t}"${git_time_t}" -u '+%B %-d, %Y')" | |
65 | |
66 # Create HTML output. | |
67 asciidoc \ | |
68 --attribute mansource=Crashpad \ | |
69 --attribute manversion="${version}" \ | |
70 --attribute manmanual="Crashpad Manual" \ | |
71 --attribute git_date="${git_date}" \ | |
72 --conf-file doc/support/asciidoc.conf \ | |
73 --doctype "${doctype}" \ | |
74 --backend html5 \ | |
75 --attribute stylesheet="${PWD}/doc/support/asciidoc.css" \ | |
76 --out-file "${output_dir}/${type}/html/${base}.html" \ | |
77 "${input}" | |
78 | |
79 if [[ "${type}" = "man" ]]; then | |
80 # Create “man” output. | |
81 # | |
82 # AsciiDoc 8.6.9 produces harmless incorrect warnings each time this is run: | |
83 # “a2x: WARNING: --destination-dir option is only applicable to HTML based | |
84 # outputs”. https://github.com/asciidoc/asciidoc/issues/44 | |
85 a2x \ | |
86 --attribute mansource=Crashpad \ | |
87 --attribute manversion="${version}" \ | |
88 --attribute manmanual="Crashpad Manual" \ | |
89 --attribute git_date="${git_date}" \ | |
90 --asciidoc-opts=--conf-file=doc/support/asciidoc.conf \ | |
91 --doctype "${doctype}" \ | |
92 --format manpage \ | |
93 --destination-dir "${output_dir}/${type}/man" \ | |
94 "${input}" | |
95 fi | |
96 | |
97 # For PDF output, use an a2x command like the one above, with these options: | |
98 # --format pdf --fop --destination-dir "${output_dir}/${type}/pdf" | |
99 } | |
100 | |
101 for input in \ | |
102 doc/*.ad; do | |
103 generate "${input}" "doc" | |
104 done | |
105 | |
106 for input in \ | |
107 handler/crashpad_handler.ad \ | |
108 tools/*.ad \ | |
109 tools/mac/*.ad; do | |
110 generate "${input}" "man" | |
111 done | |
OLD | NEW |