blob: d57bc8af31aa57261c33bf0fee6f5027a2263531 [file] [log] [blame]
Alice Kober-Sotzekd5c77162019-08-07 15:55:59 +02001#!/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
21SCRIPT_DIR=$(dirname -- "$(readlink -f -- "$BASH_SOURCE")")
22GERRIT_CODE_DIR="$SCRIPT_DIR/.."
23cd "$GERRIT_CODE_DIR"
24
25bazel build Documentation:searchfree
26if [ $? -ne 0 ]
27then
28 echo "Building the documentation failed. Stopping."
29 exit 1
30fi
31
32TMP_DOCS_DIR=/tmp/gerrit_docs
33rm -rf "$TMP_DOCS_DIR"
34unzip bazel-bin/Documentation/searchfree.zip -d "$TMP_DOCS_DIR" </dev/null >/dev/null 2>&1 & disown
35if [ $? -ne 0 ]
36then
37 echo "Unzipping the documentation to $TMP_DOCS_DIR failed. Stopping."
38 exit 1
39fi
40
41if [ "$#" -lt 1 ]
42then
43 FILE_NAME="index.html"
44else
45 FILE_NAME="$1"
46fi
47DOC_FILE_NAME="${FILE_NAME/.txt/.html}"
48google-chrome "file:///$TMP_DOCS_DIR/Documentation/$DOC_FILE_NAME" </dev/null >/dev/null 2>&1 & disown