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
(cherry picked from commit 87cf79ba4c)
This commit is contained in:
Ron Stone 2023-09-01 12:20:59 +00:00
parent 89b098485c
commit 2523634ff0

View File

@ -5,9 +5,11 @@ if ! hash uuidgen 2>/dev/null; then
exit 1 exit 1
fi fi
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"
@ -128,6 +130,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}"