From 25bb85da678d053635c1b55e45f653e2033a23fb Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Mon, 11 Sep 2017 23:30:50 +0000 Subject: [PATCH] Fix language index for document in sub directories The previous version did not care the case where documents are placed in any sub directories. It assumes all documents are placed in the top doc directory. We now have atc-stats/***.html and the previous build script does not work for these pages. This commit fixes the problem. Change-Id: Ic19c2de6e4bf3f4f5c7ae6dd79372a19fddcc7c3 --- tools/build-docs.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tools/build-docs.sh b/tools/build-docs.sh index b6cf85d..7e8419c 100755 --- a/tools/build-docs.sh +++ b/tools/build-docs.sh @@ -72,9 +72,21 @@ function _add_language_index { local basename basename=$(echo $target_file | sed -e "s|$DIRECTORY/source/||" -e "s|\.rst$||") + path_to_top_level=$(dirname $basename | sed -e 's|[^./]\+|..|g') + + local _basepath + if [ "$basepath"= "." -a "$path_to_top_level" = "." ]; then + _basepath="." + elif [ "$basepath" = "." ]; then + _basepath=$path_to_top_level + elif [ "$path_to_top_level" = "." ]; then + _basepath=$basepath + else + _basepath="$basepath/$path_to_top_level" + fi cp -p $target_file $target_file.backup - sed -e "s|__BASE__|$basepath|" -e "s|__INDEX__|$basename.html|" $LANG_INDEX > $target_file + sed -e "s|__BASE__|$_basepath|" -e "s|__INDEX__|$basename.html|" $LANG_INDEX > $target_file cat $target_file.backup >> $target_file }