Shorten long file names (r8, r7, r6, r5)

https://review.opendev.org/c/starlingx/docs/+/893405 revealed
a problem with very long file names not being linkable in some
browsing contexts. The problem was corrected by shortening
the filename to 75 chars + extension. This review checks for
and trims long filename input to 'tox -e newfile' to 75 chars
+ extension. (62 + dash + UUID fragment)

Signed-off-by: Ron Stone <ronald.stone@windriver.com>
Change-Id: Id6fa734c664977606649ff38d7e837fd1f91d178
This commit is contained in:
Ron Stone 2023-09-01 12:20:59 +00:00
parent 0df05f304c
commit 87cf79ba4c

View File

@ -5,9 +5,11 @@ if [[ -z ${utils_loaded+x} ]]; then echo "Could not load utilities"; exit 1; fi
check_util_deps uuidgen check_util_deps uuidgen
INCLUDEDIR="$2/doc/source/_includes" declare INCLUDEDIR="$2/doc/source/_includes"
declare -A charReplacements declare -A charReplacements
# max basename lenght *before* appending UUID
declare MAX_LEN=62
charReplacements=( charReplacements=(
["-"]="minus" ["-"]="minus"
@ -123,6 +125,12 @@ do
filename=`sed "s/$c/${charReplacements[$c]}/g" <<< $filename` filename=`sed "s/$c/${charReplacements[$c]}/g" <<< $filename`
done done
if [[ ${#filename} -gt ${MAX_LEN} ]]; then
filename=${filename:0:$MAX_LEN}
declare FULL_LEN=$(($MAX_LEN + 13))
echo -e "\nFilename and label shortend to $FULL_LEN chars"
fi
filename="${filename//[^[:alnum:]]/-}" filename="${filename//[^[:alnum:]]/-}"
filename=$(echo $filename | tr -s -) filename=$(echo $filename | tr -s -)
filename="${filename}-${myuuid}" filename="${filename}-${myuuid}"