Alice Kober-Sotzek | d5c7716 | 2019-08-07 15:55:59 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2019 The Android Open Source Project |
| 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 | # This script builds Gerrit's documentation and shows the current state in |
| 18 | # Chrome. Specific pages (e.g. rest-api-changes.txt) including anchors can be |
| 19 | # passed as parameter to jump directly to them. |
| 20 | |
| 21 | SCRIPT_DIR=$(dirname -- "$(readlink -f -- "$BASH_SOURCE")") |
| 22 | GERRIT_CODE_DIR="$SCRIPT_DIR/.." |
| 23 | cd "$GERRIT_CODE_DIR" |
| 24 | |
| 25 | bazel build Documentation:searchfree |
| 26 | if [ $? -ne 0 ] |
| 27 | then |
| 28 | echo "Building the documentation failed. Stopping." |
| 29 | exit 1 |
| 30 | fi |
| 31 | |
| 32 | TMP_DOCS_DIR=/tmp/gerrit_docs |
| 33 | rm -rf "$TMP_DOCS_DIR" |
| 34 | unzip bazel-bin/Documentation/searchfree.zip -d "$TMP_DOCS_DIR" </dev/null >/dev/null 2>&1 & disown |
| 35 | if [ $? -ne 0 ] |
| 36 | then |
| 37 | echo "Unzipping the documentation to $TMP_DOCS_DIR failed. Stopping." |
| 38 | exit 1 |
| 39 | fi |
| 40 | |
| 41 | if [ "$#" -lt 1 ] |
| 42 | then |
| 43 | FILE_NAME="index.html" |
| 44 | else |
| 45 | FILE_NAME="$1" |
| 46 | fi |
| 47 | DOC_FILE_NAME="${FILE_NAME/.txt/.html}" |
| 48 | google-chrome "file:///$TMP_DOCS_DIR/Documentation/$DOC_FILE_NAME" </dev/null >/dev/null 2>&1 & disown |