forked from quantumlib/Cirq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-rtd-docs.sh
executable file
·59 lines (48 loc) · 1.88 KB
/
build-rtd-docs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
# Copyright 2018 The Cirq Developers
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
# Generates a local copy of Cirq's documentation, using Sphinx.
#
# Output currently goes into [REPO_ROOT]/rtd_docs/_build
#
# Temporary files generated by Sphinx (e.g. by the Napoleon extension
# translating google-style docstrings) are put into [REPO_ROOT]/docs/generated,
# which is cleared before and after this command runs.
#
# Usage:
# dev_tools/docs/build-rtd-docs.sh [fast]
#
# fast: sets the concurrency to the number of CPUs (not recommended on Github
# Actions as it sometimes makes the build hung)
################################################################################
set -e
trap "{ echo -e '\033[31mFAILED\033[0m'; }" ERR
[[ $1 == 'fast' ]] && CPUS='-j auto' || CPUS=''
# Get the working directory to the repo root.
cd "$(git rev-parse --show-toplevel)"/rtd_docs
docs_conf_dir="."
out_dir="${docs_conf_dir}/_build"
# Cleanup pre-existing temporary generated files.
rm -rf "${docs_conf_dir}/generated"
# Cleanup previous output.
rm -rf "${out_dir}"
# Regenerate docs.
sphinx-build -M html "${docs_conf_dir}" "${out_dir}" -W --keep-going $CPUS
# Cleanup newly generated temporary files.
rm -rf "${docs_conf_dir}/generated"
echo
echo Index Page:
echo "file://$(pwd)/${out_dir}/html/index.html"
echo