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
| ... | ... |
@@ -18,7 +18,3 @@ Detected Plugins |
| 18 | 18 |
The following are plugins that a script has found in the openstack/ |
| 19 | 19 |
namespace, which includes but is not limited to official OpenStack |
| 20 | 20 |
projects. |
| 21 |
- |
|
| 22 |
-+----------------------------+-------------------------------------------------------------------------+ |
|
| 23 |
-|Plugin Name |URL | |
|
| 24 |
-+----------------------------+-------------------------------------------------------------------------+ |
| ... | ... |
@@ -23,9 +23,12 @@ |
| 23 | 23 |
# working directory |
| 24 | 24 |
# * network access to https://git.openstack.org/cgit |
| 25 | 25 |
|
| 26 |
+import logging |
|
| 26 | 27 |
import json |
| 27 | 28 |
import requests |
| 28 | 29 |
|
| 30 |
+logging.basicConfig(level=logging.DEBUG) |
|
| 31 |
+ |
|
| 29 | 32 |
url = 'https://review.openstack.org/projects/' |
| 30 | 33 |
|
| 31 | 34 |
# This is what a project looks like |
| ... | ... |
@@ -37,6 +40,8 @@ url = 'https://review.openstack.org/projects/' |
| 37 | 37 |
''' |
| 38 | 38 |
|
| 39 | 39 |
def is_in_openstack_namespace(proj): |
| 40 |
+ # only interested in openstack namespace (e.g. not retired |
|
| 41 |
+ # stackforge, etc) |
|
| 40 | 42 |
return proj.startswith('openstack/')
|
| 41 | 43 |
|
| 42 | 44 |
# Rather than returning a 404 for a nonexistent file, cgit delivers a |
| ... | ... |
@@ -50,10 +55,13 @@ def has_devstack_plugin(proj): |
| 50 | 50 |
else: |
| 51 | 51 |
False |
| 52 | 52 |
|
| 53 |
+logging.debug("Getting project list from %s" % url)
|
|
| 53 | 54 |
r = requests.get(url) |
| 54 | 55 |
projects = sorted(filter(is_in_openstack_namespace, json.loads(r.text[4:]))) |
| 56 |
+logging.debug("Found %d projects" % len(projects))
|
|
| 55 | 57 |
|
| 56 | 58 |
found_plugins = filter(has_devstack_plugin, projects) |
| 57 | 59 |
|
| 58 | 60 |
for project in found_plugins: |
| 61 |
+ # strip of openstack/ |
|
| 59 | 62 |
print project[10:] |
| ... | ... |
@@ -38,6 +38,17 @@ |
| 38 | 38 |
# current working directory, it will be prepended or appended to |
| 39 | 39 |
# the generated reStructuredText plugins table respectively. |
| 40 | 40 |
|
| 41 |
+# Print the title underline for a RST table. Argument is the length |
|
| 42 |
+# of the first column, second column is assumed to be "URL" |
|
| 43 |
+function title_underline {
|
|
| 44 |
+ local len=$1 |
|
| 45 |
+ while [[ $len -gt 0 ]]; do |
|
| 46 |
+ printf "=" |
|
| 47 |
+ len=$(( len - 1)) |
|
| 48 |
+ done |
|
| 49 |
+ printf " ===\n" |
|
| 50 |
+} |
|
| 51 |
+ |
|
| 41 | 52 |
( |
| 42 | 53 |
declare -A plugins |
| 43 | 54 |
|
| ... | ... |
@@ -47,11 +58,24 @@ fi |
| 47 | 47 |
|
| 48 | 48 |
sorted_plugins=$(python tools/generate-devstack-plugins-list.py) |
| 49 | 49 |
|
| 50 |
-for k in ${sorted_plugins}; do
|
|
| 51 |
- project=${k:0:28}
|
|
| 52 |
- giturl="git://git.openstack.org/openstack/${k:0:26}"
|
|
| 53 |
- printf "|%-28s|%-73s|\n" "${project}" "${giturl}"
|
|
| 54 |
- printf "+----------------------------+-------------------------------------------------------------------------+\n" |
|
| 50 |
+# find the length of the name column & pad |
|
| 51 |
+name_col_len=$(echo "${sorted_plugins}" | wc -L)
|
|
| 52 |
+name_col_len=$(( name_col_len + 2 )) |
|
| 53 |
+ |
|
| 54 |
+# ====================== === |
|
| 55 |
+# Plugin Name URL |
|
| 56 |
+# ====================== === |
|
| 57 |
+# foobar `git://... <http://...>`__ |
|
| 58 |
+# ... |
|
| 59 |
+ |
|
| 60 |
+title_underline ${name_col_len}
|
|
| 61 |
+printf "%-${name_col_len}s %s\n" "Plugin Name" "URL"
|
|
| 62 |
+title_underline ${name_col_len}
|
|
| 63 |
+ |
|
| 64 |
+for plugin in ${sorted_plugins}; do
|
|
| 65 |
+ giturl="git://git.openstack.org/openstack/${plugin}"
|
|
| 66 |
+ gitlink="https://git.openstack.org/cgit/openstack/${plugin}"
|
|
| 67 |
+ printf "%-${name_col_len}s %s\n" "${p}" "\`${giturl} <${gitlink}>\`__"
|
|
| 55 | 68 |
done |
| 56 | 69 |
|
| 57 | 70 |
if [[ -r data/devstack-plugins-registry.footer ]]; then |