1#!/bin/bash 2 3# Copyright 2021 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# https://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# Fail on any error 18set -ex 19 20DOCS_ROOT=docs-gen 21 22[ -d $DOCS_ROOT ] && rm -r $DOCS_ROOT 23mkdir $DOCS_ROOT 24 25# Clear out the old API docs 26[ -d docs/api ] && rm -r docs/api 27# Build the docs with dokka 28./gradlew dokkaHtmlMultiModule --stacktrace 29 30# Create a copy of our docs at our $DOCS_ROOT 31cp -a docs/* $DOCS_ROOT 32 33cp README.md $DOCS_ROOT/index.md 34cp CONTRIBUTING.md $DOCS_ROOT/contributing.md 35 36sed -i.bak 's/CONTRIBUTING.md/contributing/' $DOCS_ROOT/index.md 37sed -i.bak 's/README.md//' $DOCS_ROOT/index.md 38sed -i.bak 's/docs\/header.png/header.png/' $DOCS_ROOT/index.md 39 40# Convert docs/xxx.md links to just xxx/ 41sed -i.bak 's/docs\/\([a-zA-Z-]*\).md/\1/' $DOCS_ROOT/index.md 42 43# Finally delete all of the backup files 44find . -name '*.bak' -delete 45