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 output_dir=out/doc/man |
| 27 |
| 28 rm -rf "${output_dir}" |
| 29 mkdir -p \ |
| 30 "${output_dir}/html" \ |
| 31 "${output_dir}/man" |
| 32 |
| 33 # Some extensions of command-line tools behave differently on different systems. |
| 34 # $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 |
| 36 # time corresponding to a time_t string that immediately follows it. |
| 37 uname_s="$(uname -s)" |
| 38 case "${uname_s}" in |
| 39 Darwin) |
| 40 sed_ext="sed -E" |
| 41 date_time_t="date -r" |
| 42 ;; |
| 43 Linux) |
| 44 sed_ext="sed -r" |
| 45 date_time_t="date -d@" |
| 46 ;; |
| 47 *) |
| 48 echo "${0}: unknown operating system" >& 2 |
| 49 exit 1 |
| 50 ;; |
| 51 esac |
| 52 |
| 53 # Get the version from package.h. |
| 54 version=$(${sed_ext} -n -e 's/^#define PACKAGE_VERSION "(.*)"$/\1/p' package.h) |
| 55 |
| 56 for input in \ |
| 57 handler/mac/crashpad_handler.ad \ |
| 58 tools/*.ad \ |
| 59 tools/mac/*.ad; do |
| 60 echo "${input}" |
| 61 |
| 62 base=$(${sed_ext} -e 's%^.*/([^/]+)\.ad$%\1%' <<< "${input}") |
| 63 |
| 64 # Get the last-modified date of $input according to Git, in UTC. |
| 65 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')" |
| 67 |
| 68 # Create HTML output. |
| 69 asciidoc \ |
| 70 --attribute mansource=Crashpad \ |
| 71 --attribute manversion="${version}" \ |
| 72 --attribute manmanual="Crashpad Manual" \ |
| 73 --attribute revdate="${git_date}" \ |
| 74 --conf-file doc/asciidoc.conf \ |
| 75 --doctype manpage \ |
| 76 --backend html5 \ |
| 77 --attribute stylesheet="${PWD}/doc/asciidoc.css" \ |
| 78 --out-file "${output_dir}/html/${base}.html" \ |
| 79 "${input}" |
| 80 |
| 81 # Create “man” output. |
| 82 # |
| 83 # AsciiDoc 8.6.9 produces harmless incorrect warnings each time this is run: |
| 84 # “a2x: WARNING: --destination-dir option is only applicable to HTML based |
| 85 # outputs”. https://github.com/asciidoc/asciidoc/issues/44 |
| 86 a2x \ |
| 87 --attribute mansource=Crashpad \ |
| 88 --attribute manversion="${version}" \ |
| 89 --attribute manmanual="Crashpad Manual" \ |
| 90 --attribute revdate="${git_date}" \ |
| 91 --doctype manpage \ |
| 92 --format manpage \ |
| 93 --destination-dir "${output_dir}/man" \ |
| 94 "${input}" |
| 95 |
| 96 # For PDF output, use an a2x command like the one above, with these options: |
| 97 # --format pdf --fop --destination-dir "${output_dir}/pdf" |
| 98 done |
OLD | NEW |