Fred Sladkey | 80a4f08 | 2022-01-05 20:40:15 +0000 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2022 The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | |
| 17 | source gbash.sh || exit |
| 18 | |
| 19 | readonly nativeDirs=( |
| 20 | ) |
| 21 | |
| 22 | # Change directory to this script's location and store the directory |
| 23 | cd "$(dirname $0)" |
| 24 | scriptDirectory=$(pwd) |
| 25 | |
| 26 | |
| 27 | # Working directories for the refdocs |
| 28 | readonly outDir="$scriptDirectory/out" |
| 29 | readonly doxygenDir="reference-docs-doxygen" |
| 30 | |
| 31 | # Remove and recreate the existing out directory to avoid conflicts from previous runs |
| 32 | rm -rf $outDir/$doxygenDir |
| 33 | mkdir -p $outDir/$doxygenDir |
| 34 | cd $outDir |
| 35 | |
| 36 | # Create tmp client for building c2devsite |
| 37 | client="$(p4 g4d -f androidx-doxgyen-staging)" |
| 38 | cd "$client" |
| 39 | readonly c2devsiteDir=$client/devsite/tools/doxygen/c/ |
| 40 | |
| 41 | # Revert all local changes to prevent merge conflicts when syncing. |
| 42 | # This is OK since we always want to start with a fresh CitC client |
| 43 | g4 revert ... |
| 44 | g4 sync |
| 45 | |
| 46 | # Build c2devsite target. |
| 47 | blaze build devsite/tools/doxygen/c:c2devsite |
| 48 | |
| 49 | for dir in "${nativeDirs[@]}" |
| 50 | do |
| 51 | printf "Generating doxygen docs for $dir\n" |
| 52 | |
| 53 | # clear previous tmp folder and recreate it |
| 54 | rm -rf $outDir/$doxygenDir/tmp |
| 55 | mkdir $outDir/$doxygenDir/tmp |
| 56 | cd $outDir/$doxygenDir/tmp |
| 57 | |
| 58 | # Copy the project we're generating docs for into tmp dir |
| 59 | cp -a $scriptDirectory/../../$dir ./ |
| 60 | |
| 61 | # Copy default configs for c2devsite |
| 62 | cp $c2devsiteDir/Doxyfile-local ./Doxyfile-local |
| 63 | cp $c2devsiteDir/config.cfg ./config.cfg |
| 64 | |
| 65 | # Find header files in include directory, separated by spaces instead of newlines |
| 66 | headers=$(find . -type f -wholename "**/include/**/*.h" -printf "%p ") |
| 67 | |
| 68 | # Edit Doxyfile to include public header files |
| 69 | sed -i "s|^INPUT|INPUT = $headers|" ./Doxyfile-local |
| 70 | |
| 71 | # Edit config |
| 72 | sed -i "s|^HTML_PATH=.*|HTML_PATH=/reference/androidx/$dir/|" ./config.cfg |
| 73 | sed -i "s|^BOOK_PATH=.*|BOOK_PATH=/reference/androidx/|" ./config.cfg |
| 74 | sed -i "s|^PROJECT_PATH=.*|PROJECT_PATH=/reference/|" ./config.cfg |
| 75 | sed -i "s|^LANGUAGE=.*|LANGUAGE=cplusplus|" ./config.cfg |
| 76 | sed -i "s|^PROJECT_TITLE=.*|PROJECT_TITLE=$dir|" ./config.cfg # placeholder |
| 77 | sed -i "s|^PROJECT_DESC=.*|PROJECT_DESC=$dir|" ./config.cfg # placeholder |
| 78 | |
| 79 | # Run c2devsite to generate html files |
| 80 | $client/blaze-bin/devsite/tools/doxygen/c/c2devsite |
| 81 | |
| 82 | # Update generated TOC to nest contents under a 'section' |
| 83 | |
| 84 | # Indent everything |
| 85 | sed -i "s|^| |" ./doxhtml/_doxygen.yaml |
| 86 | # except for the first line |
| 87 | sed -i "s| toc:|toc:|" ./doxhtml/_doxygen.yaml |
| 88 | # append title/section after initial 'toc:' |
| 89 | sed -i "s|toc:|toc:\\n- title: androidx.$dir\\n section:|" ./doxhtml/_doxygen.yaml |
| 90 | |
| 91 | # Copy generated docs out of tmp folder |
| 92 | mkdir -p ../reference/androidx/$dir |
| 93 | cp -a ./doxhtml/. ../reference/androidx/$dir |
| 94 | done |