xref: /aosp_15_r20/external/pytorch/docs/cpp/source/check-doxygen.sh (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1#!/bin/bash
2
3set -ex
4
5ignore_warning() {
6  # Invert match to filter out $1.
7  set +e
8  grep -v "$1" doxygen-log.txt > temp.txt
9  set -e
10  mv temp.txt doxygen-log.txt
11}
12
13command -v doxygen >/dev/null 2>&1 || { echo >&2 "doxygen is not supported. Aborting."; exit 1; }
14
15pushd "$(dirname "$0")/../../.."
16
17cp torch/_utils_internal.py tools/shared
18
19python -m torchgen.gen --source-path aten/src/ATen
20
21python tools/setup_helpers/generate_code.py                 \
22  --native-functions-path aten/src/ATen/native/native_functions.yaml \
23  --tags-path aten/src/ATen/native/tags.yaml
24popd
25
26# Run doxygen and log all output.
27doxygen "$(dirname $0)" 2> original-doxygen-log.txt
28cp original-doxygen-log.txt doxygen-log.txt
29
30# Uncomment this if you need it for debugging; we're not printing this
31# by default because it is confusing.
32# echo "Original output"
33# cat original-doxygen-log.txt
34
35# Filter out some warnings.
36ignore_warning "warning: no uniquely matching class member found for"
37ignore_warning "warning: explicit link request to 'Item' could not be resolved"
38ignore_warning "warning: Included by graph for 'types.h' not generated, too many nodes"
39
40# Count the number of remaining warnings.
41warnings="$(grep 'warning:' doxygen-log.txt | wc -l)"
42
43echo "Treating all remaining warnings as errors"
44
45if [[ "$warnings" -ne "0" ]]; then
46  echo "Failing Doxygen test because the following warnings were treated fatally:"
47  cat doxygen-log.txt
48  echo "Please fix these warnings.  To run this test locally, use docs/cpp/source/check-doxygen.sh"
49  rm -f doxygen-log.txt original-doxygen-log.txt
50  exit 1
51fi
52
53rm -f doxygen-log.txt original-doxygen-log.txt
54