Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: doc/support/generate_asciidoc.sh

Issue 1055523002: Migrate content from wiki (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Post-review Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 2
3 # Copyright 2015 The Crashpad Authors. All rights reserved. 3 # Copyright 2015 The Crashpad Authors. All rights reserved.
4 # 4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with 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 7 # You may obtain a copy of the License at
8 # 8 #
9 # http://www.apache.org/licenses/LICENSE-2.0 9 # http://www.apache.org/licenses/LICENSE-2.0
10 # 10 #
11 # Unless required by applicable law or agreed to in writing, software 11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS, 12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and 14 # See the License for the specific language governing permissions and
15 # limitations under the License. 15 # limitations under the License.
16 16
17 set -e 17 set -e
18 18
19 # Generating AsciiDoc documentation requires AsciiDoc, 19 # Generating AsciiDoc documentation requires AsciiDoc,
20 # http://www.methods.co.nz/asciidoc/. For “man” and PDF output, a DocBook 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. 21 # toolchain including docbook-xml and docbook-xsl is also required.
22 22
23 # Run from the Crashpad project root directory. 23 # Run from the Crashpad project root directory.
24 cd "$(dirname "${0}")/.." 24 cd "$(dirname "${0}")/../.."
25 25
26 output_dir=out/doc/man 26 output_dir=out/doc
27 27
28 rm -rf "${output_dir}" 28 rm -rf \
29 "${output_dir}/doc" \
30 "${output_dir}/man"
29 mkdir -p \ 31 mkdir -p \
30 "${output_dir}/html" \ 32 "${output_dir}/doc/html" \
31 "${output_dir}/man" 33 "${output_dir}/man/html" \
34 "${output_dir}/man/man"
32 35
33 # Some extensions of command-line tools behave differently on different systems. 36 # Some extensions of command-line tools behave differently on different systems.
34 # $sed_ext should be a sed invocation that enables extended regular expressions. 37 # $sed_ext should be a sed invocation that enables extended regular expressions.
35 # $date_time_t should be a date invocation that causes it to print the date and 38 # $date_time_t should be a date invocation that causes it to print the date and
36 # time corresponding to a time_t string that immediately follows it. 39 # time corresponding to a time_t string that immediately follows it.
37 uname_s="$(uname -s)" 40 uname_s="$(uname -s)"
38 case "${uname_s}" in 41 case "${uname_s}" in
39 Darwin) 42 Darwin)
40 sed_ext="sed -E" 43 sed_ext="sed -E"
41 date_time_t="date -r" 44 date_time_t="date -r"
42 ;; 45 ;;
43 Linux) 46 Linux)
44 sed_ext="sed -r" 47 sed_ext="sed -r"
45 date_time_t="date -d@" 48 date_time_t="date -d@"
46 ;; 49 ;;
47 *) 50 *)
48 echo "${0}: unknown operating system" >& 2 51 echo "${0}: unknown operating system" >& 2
49 exit 1 52 exit 1
50 ;; 53 ;;
51 esac 54 esac
52 55
53 # Get the version from package.h. 56 # Get the version from package.h.
54 version=$(${sed_ext} -n -e 's/^#define PACKAGE_VERSION "(.*)"$/\1/p' package.h) 57 version=$(${sed_ext} -n -e 's/^#define PACKAGE_VERSION "(.*)"$/\1/p' package.h)
55 58
56 for input in \ 59 generate() {
57 handler/mac/crashpad_handler.ad \ 60 input="$1"
58 tools/*.ad \ 61 type="$2"
59 tools/mac/*.ad; do 62
63 case "${type}" in
64 doc)
65 doctype="article"
66 ;;
67 man)
68 doctype="manpage"
69 ;;
70 *)
71 echo "${0}: unknown type ${type}" >& 2
72 exit 1
73 ;;
74 esac
75
60 echo "${input}" 76 echo "${input}"
61 77
62 base=$(${sed_ext} -e 's%^.*/([^/]+)\.ad$%\1%' <<< "${input}") 78 base=$(${sed_ext} -e 's%^.*/([^/]+)\.ad$%\1%' <<< "${input}")
63 79
64 # Get the last-modified date of $input according to Git, in UTC. 80 # Get the last-modified date of $input according to Git, in UTC.
65 git_time_t="$(git log -1 --format=%at "${input}")" 81 git_time_t="$(git log -1 --format=%at "${input}")"
66 git_date="$(LC_ALL=C ${date_time_t}"${git_time_t}" -u '+%B %-d, %Y')" 82 git_date="$(LC_ALL=C ${date_time_t}"${git_time_t}" -u '+%B %-d, %Y')"
67 83
68 # Create HTML output. 84 # Create HTML output.
69 asciidoc \ 85 asciidoc \
70 --attribute mansource=Crashpad \ 86 --attribute mansource=Crashpad \
71 --attribute manversion="${version}" \ 87 --attribute manversion="${version}" \
72 --attribute manmanual="Crashpad Manual" \ 88 --attribute manmanual="Crashpad Manual" \
73 --attribute revdate="${git_date}" \ 89 --attribute git_date="${git_date}" \
74 --conf-file doc/asciidoc.conf \ 90 --conf-file doc/support/asciidoc.conf \
75 --doctype manpage \ 91 --doctype "${doctype}" \
76 --backend html5 \ 92 --backend html5 \
77 --attribute stylesheet="${PWD}/doc/asciidoc.css" \ 93 --attribute stylesheet="${PWD}/doc/support/asciidoc.css" \
78 --out-file "${output_dir}/html/${base}.html" \ 94 --out-file "${output_dir}/${type}/html/${base}.html" \
79 "${input}" 95 "${input}"
80 96
81 # Create “man” output. 97 if [[ "${type}" = "man" ]]; then
82 # 98 # Create “man” output.
83 # AsciiDoc 8.6.9 produces harmless incorrect warnings each time this is run: 99 #
84 # “a2x: WARNING: --destination-dir option is only applicable to HTML based 100 # AsciiDoc 8.6.9 produces harmless incorrect warnings each time this is run:
85 # outputs”. https://github.com/asciidoc/asciidoc/issues/44 101 # “a2x: WARNING: --destination-dir option is only applicable to HTML based
86 a2x \ 102 # outputs”. https://github.com/asciidoc/asciidoc/issues/44
87 --attribute mansource=Crashpad \ 103 a2x \
88 --attribute manversion="${version}" \ 104 --attribute mansource=Crashpad \
89 --attribute manmanual="Crashpad Manual" \ 105 --attribute manversion="${version}" \
90 --attribute revdate="${git_date}" \ 106 --attribute manmanual="Crashpad Manual" \
91 --asciidoc-opts=--conf-file=doc/asciidoc.conf \ 107 --attribute git_date="${git_date}" \
92 --doctype manpage \ 108 --asciidoc-opts=--conf-file=doc/support/asciidoc.conf \
93 --format manpage \ 109 --doctype "${doctype}" \
94 --destination-dir "${output_dir}/man" \ 110 --format manpage \
95 "${input}" 111 --destination-dir "${output_dir}/${type}/man" \
112 "${input}"
113 fi
96 114
97 # For PDF output, use an a2x command like the one above, with these options: 115 # For PDF output, use an a2x command like the one above, with these options:
98 # --format pdf --fop --destination-dir "${output_dir}/pdf" 116 # --format pdf --fop --destination-dir "${output_dir}/${type}/pdf"
117 }
118
119 for input in \
120 doc/*.ad; do
121 generate "${input}" "doc"
99 done 122 done
123
124 for input in \
125 handler/mac/crashpad_handler.ad \
126 tools/*.ad \
127 tools/mac/*.ad; do
128 generate "${input}" "man"
129 done
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698