#!/bin/bash
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Build all docs with one command
# Documentation will be placed in `build/docs`.
# IMPORTANT: When changing this file make sure to update the
# `build-rust-docs.bat` file, too.
set -xe
CRATE_NAME=glean_core
# Add the changelog file
cp -a CHANGELOG.md docs/user/appendix/changelog.md
# Build the Glean client user book
output=$(mdbook build docs/user/ 2>&1)
if echo "$output" | grep -q "\[ERROR\]" ; then
exit 1
fi
# Build the Glean SDK development book
output=$(mdbook build docs/dev/ 2>&1)
if echo "$output" | grep -q "\[ERROR\]" ; then
exit 1
fi
cargo doc --no-deps
rm -rf build/docs
mkdir -p build/docs
echo '' > build/docs/index.html
# Add redirections for all pages moved on the restructuring done on Bug 1708204
# Android Specific Information
mkdir -p build/docs/book/user/android/
echo '' > build/docs/book/user/android/android-build-configuration-options.html
echo '' > build/docs/book/user/android/android-offline-builds.html
echo '' > build/docs/book/user/instrument-android-crashes-example.html
echo '' > build/docs/book/user/android/index.html
# General API
echo '' > build/docs/book/user/general-api.html
# Metrics API
mkdir -p build/docs/book/user/metrics/
echo '' > build/docs/book/user/metrics/boolean.html
echo '' > build/docs/book/user/metrics/counter.html
echo '' > build/docs/book/user/metrics/custom_distribution.html
echo '' > build/docs/book/user/metrics/datetime.html
echo '' > build/docs/book/user/metrics/event.html
echo '' > build/docs/book/user/metrics/index.html
echo '' > build/docs/book/user/metrics/labeled_booleans.html
echo '' > build/docs/book/user/metrics/labeled_counters.html
echo '' > build/docs/book/user/metrics/labeled_strings.html
echo '' > build/docs/book/user/metrics/memory_distribution.html
echo '' > build/docs/book/user/metrics/quantity.html
echo '' > build/docs/book/user/metrics/rate.html
echo '' > build/docs/book/user/metrics/string.html
echo '' > build/docs/book/user/metrics/string_list.html
echo '' > build/docs/book/user/metrics/timespan.html
echo '' > build/docs/book/user/metrics/timing_distribution.html
echo '' > build/docs/book/user/metrics/uuid.html
# YAML Format
echo '' > build/docs/book/user/metric-parameters.html
# Metric User Guides
echo '' > build/docs/book/user/adding-new-metrics.html
echo '' > build/docs/book/user/error-reporting.html
echo '' > build/docs/book/user/testing-metrics.html
mkdir -p build/docs/book
cp -a docs/user/book/. build/docs/book
mkdir -p build/docs/dev
cp -a docs/dev/book/. build/docs/dev
mkdir -p build/docs/shared
cp -a docs/shared/. build/docs/shared
mkdir -p build/docs/docs
cp -a target/doc/. build/docs/docs
printf '\n' "$CRATE_NAME" > build/docs/docs/index.html