#!/usr/bin/env bash # Copyright Materialize, Inc. and contributors. All rights reserved. # # Use of this software is governed by the Business Source License # included in the LICENSE file at the root of this repository. # # As of the Change Date specified in that file, in accordance with # the Business Source License, use of this software will be governed # by the Apache License, Version 2.0. # # doc — renders API documentation. # When using a nightly toolchain, this script will automatically enables the use # of some unstable niceties, like the `doc_cfg` annotations to indicate in the # docs what features must be enabled to use an item. # # CI always uses a nightly toolchain to run this script. To use one locally: # # $ RUSTUP_TOOLCHAIN=nightly bin/doc # set -euo pipefail cd "$(dirname "$0")/.." . misc/shlib/shlib.bash RUSTDOCFLAGS+=" -D warnings " if [[ $(cargo -V) = *nightly* ]]; then RUSTDOCFLAGS+=" --cfg nightly_doc_features" fi export RUSTDOCFLAGS target=${CARGO_TARGET_DIR:-target} cargo doc --all-features "$@" crates=$(cargo metadata --format-version=1 \ | jq -r -f misc/doc/crates.jq --arg pwd "$(pwd)") # Create a nice homepage for the docs. It's awful that we have to copy the # HTML template like this, but the upstream issue [0] that would resolve this is # now five years old and doesn't look close to resolution. # [0]: https://github.com/rust-lang/cargo/issues/739 cat > "$target"/doc/index.html < Materialize - Rust

Materialize documentation

This is the home of Materialize's internal API documentation.

Important crates

$crates
EOF # Make the logo link to the nice homepage we just created. Otherwise it just # links to the root of whatever crate you happen to be looking at. cat >> "$target"/doc/main.js <