Plugin autogen list: handle variable-width plugin names
We've had a couple of cases where plugin names are longer than our table width. Take the fixed-with table-header out of the header file, and generate it dynamically based on first-column width. To simplify, take advantage that RST allows a variable-length last column and so don't specify it's width. Add a link to the cgit URL for each project you can click on to browse the source (link text remains the git:// URL). Add some logging so you can see what the python generator is doing, should you run it. Change-Id: I5d5e692039bbb30b2508119412472dac1d105c08
This commit is contained in:
parent
0a2a7ae847
commit
c10989bf18
@ -18,7 +18,3 @@ Detected Plugins
|
|||||||
The following are plugins that a script has found in the openstack/
|
The following are plugins that a script has found in the openstack/
|
||||||
namespace, which includes but is not limited to official OpenStack
|
namespace, which includes but is not limited to official OpenStack
|
||||||
projects.
|
projects.
|
||||||
|
|
||||||
+----------------------------+-------------------------------------------------------------------------+
|
|
||||||
|Plugin Name |URL |
|
|
||||||
+----------------------------+-------------------------------------------------------------------------+
|
|
||||||
|
@ -23,9 +23,12 @@
|
|||||||
# working directory
|
# working directory
|
||||||
# * network access to https://git.openstack.org/cgit
|
# * network access to https://git.openstack.org/cgit
|
||||||
|
|
||||||
|
import logging
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
url = 'https://review.openstack.org/projects/'
|
url = 'https://review.openstack.org/projects/'
|
||||||
|
|
||||||
# This is what a project looks like
|
# This is what a project looks like
|
||||||
@ -37,6 +40,8 @@ url = 'https://review.openstack.org/projects/'
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
def is_in_openstack_namespace(proj):
|
def is_in_openstack_namespace(proj):
|
||||||
|
# only interested in openstack namespace (e.g. not retired
|
||||||
|
# stackforge, etc)
|
||||||
return proj.startswith('openstack/')
|
return proj.startswith('openstack/')
|
||||||
|
|
||||||
# Rather than returning a 404 for a nonexistent file, cgit delivers a
|
# Rather than returning a 404 for a nonexistent file, cgit delivers a
|
||||||
@ -50,10 +55,13 @@ def has_devstack_plugin(proj):
|
|||||||
else:
|
else:
|
||||||
False
|
False
|
||||||
|
|
||||||
|
logging.debug("Getting project list from %s" % url)
|
||||||
r = requests.get(url)
|
r = requests.get(url)
|
||||||
projects = sorted(filter(is_in_openstack_namespace, json.loads(r.text[4:])))
|
projects = sorted(filter(is_in_openstack_namespace, json.loads(r.text[4:])))
|
||||||
|
logging.debug("Found %d projects" % len(projects))
|
||||||
|
|
||||||
found_plugins = filter(has_devstack_plugin, projects)
|
found_plugins = filter(has_devstack_plugin, projects)
|
||||||
|
|
||||||
for project in found_plugins:
|
for project in found_plugins:
|
||||||
|
# strip of openstack/
|
||||||
print project[10:]
|
print project[10:]
|
||||||
|
@ -38,6 +38,17 @@
|
|||||||
# current working directory, it will be prepended or appended to
|
# current working directory, it will be prepended or appended to
|
||||||
# the generated reStructuredText plugins table respectively.
|
# the generated reStructuredText plugins table respectively.
|
||||||
|
|
||||||
|
# Print the title underline for a RST table. Argument is the length
|
||||||
|
# of the first column, second column is assumed to be "URL"
|
||||||
|
function title_underline {
|
||||||
|
local len=$1
|
||||||
|
while [[ $len -gt 0 ]]; do
|
||||||
|
printf "="
|
||||||
|
len=$(( len - 1))
|
||||||
|
done
|
||||||
|
printf " ===\n"
|
||||||
|
}
|
||||||
|
|
||||||
(
|
(
|
||||||
declare -A plugins
|
declare -A plugins
|
||||||
|
|
||||||
@ -47,11 +58,24 @@ fi
|
|||||||
|
|
||||||
sorted_plugins=$(python tools/generate-devstack-plugins-list.py)
|
sorted_plugins=$(python tools/generate-devstack-plugins-list.py)
|
||||||
|
|
||||||
for k in ${sorted_plugins}; do
|
# find the length of the name column & pad
|
||||||
project=${k:0:28}
|
name_col_len=$(echo "${sorted_plugins}" | wc -L)
|
||||||
giturl="git://git.openstack.org/openstack/${k:0:26}"
|
name_col_len=$(( name_col_len + 2 ))
|
||||||
printf "|%-28s|%-73s|\n" "${project}" "${giturl}"
|
|
||||||
printf "+----------------------------+-------------------------------------------------------------------------+\n"
|
# ====================== ===
|
||||||
|
# Plugin Name URL
|
||||||
|
# ====================== ===
|
||||||
|
# foobar `git://... <http://...>`__
|
||||||
|
# ...
|
||||||
|
|
||||||
|
title_underline ${name_col_len}
|
||||||
|
printf "%-${name_col_len}s %s\n" "Plugin Name" "URL"
|
||||||
|
title_underline ${name_col_len}
|
||||||
|
|
||||||
|
for plugin in ${sorted_plugins}; do
|
||||||
|
giturl="git://git.openstack.org/openstack/${plugin}"
|
||||||
|
gitlink="https://git.openstack.org/cgit/openstack/${plugin}"
|
||||||
|
printf "%-${name_col_len}s %s\n" "${p}" "\`${giturl} <${gitlink}>\`__"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -r data/devstack-plugins-registry.footer ]]; then
|
if [[ -r data/devstack-plugins-registry.footer ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user