Dynamic width count for plugin registry table column

There might be chance that few plugin name and url
does not fit into hard coded column width and give error.

This commit count the column width as per plugins name.

Also display the number of plugins in new SR column.
Change-Id: Ia5736d2581ee3b6f851b8d08f855c2a19c157c47
This commit is contained in:
ghanshyam 2018-07-27 09:31:16 +00:00 committed by akhiljain23
parent 82539ad1c1
commit df037310ba
2 changed files with 26 additions and 6 deletions

View File

@ -17,7 +17,3 @@ Detected Plugins
The following are plugins that a script has found in the openstack/
namespace, which includes but is not limited to official OpenStack
projects.
+----------------------------+-------------------------------------------------------------------------+
|Plugin Name |URL |
+----------------------------+-------------------------------------------------------------------------+

View File

@ -49,13 +49,37 @@ fi
sorted_plugins=$(python tools/generate-tempest-plugins-list.py)
name_col_len=$(echo "${sorted_plugins}" | wc -L)
name_col_len=$(( name_col_len + 2 ))
# Print the title underline for a RST table.
function title_underline {
printf "== "
local len=$1
while [[ $len -gt 0 ]]; do
printf "="
len=$(( len - 1))
done
printf " ===\n"
}
printf "\n\n"
title_underline ${name_col_len}
printf "%-3s %-${name_col_len}s %s\n" "SR" "Plugin Name" "URL"
title_underline ${name_col_len}
i=0
for k in ${sorted_plugins}; do
i=$((i+1))
project=${k:0:28}
giturl="git://git.openstack.org/openstack/${k:0:26}"
printf "|%-28s|%-73s|\n" "${project}" "${giturl}"
printf "+----------------------------+-------------------------------------------------------------------------+\n"
printf "%-3s %-${name_col_len}s %s\n" "$i" "${project}" "${giturl}"
done
title_underline ${name_col_len}
printf "\n\n"
if [[ -r doc/source/data/tempest-plugins-registry.footer ]]; then
cat doc/source/data/tempest-plugins-registry.footer
fi