crosvm/tools/cargo-doc
Keiichi Watanabe 98dd4c211a docs: Generate API docs only for first-party crates
Pass `--workspace` and `--no-deps` as cargo-doc's arguements.
As a result:
* it won't generate API docs for third-party crates
* it'll generate API docs for our first crates that are not used by the
  minimal crosvm build. (e.g. qcow_utils, libvda, etc)

BUG=none
TEST=test on personal GitHub

Change-Id: I8911eb7d830f1cda77d264c1dc19ff948cfa4768
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578146
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-04-12 22:59:34 +00:00

49 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# Copyright 2021 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
set -ex
# Build cargo-doc
# $ ./tools/cargo-doc --target-dir /path/to/dir
echo "start cargo-doc"
MANIFEST_PATH=$(dirname "$0")/../Cargo.toml
echo "manifest = ${MANIFEST_PATH}"
DISABLED_FEATURES=(
audio_cras
chromeos
libvda
power-monitor-powerd
video-decoder
video-encoder
)
ALL_FEATURES=$(
cargo metadata --manifest-path "${MANIFEST_PATH}" | \
jq -r '.packages[] |
select(.name == "crosvm") |
.features |
keys[]')
features=""
for f in $ALL_FEATURES; do
if [[ ! "${DISABLED_FEATURES[*]}" =~ $f ]]; then
features+=",${f}"
fi
done
# Set an environment variable 'CARGO_DOC' here so that each build.rs can skip
# building unnecessary dependencies to generate documentations.
CARGO_DOC="true" cargo doc \
--manifest-path="${MANIFEST_PATH}" \
--workspace \
--no-deps \
--features="${features}" "$@" \
--document-private-items