diff --git a/.gitignore b/.gitignore index 57dd697..3212bc6 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ ChangeLog .bak doc/build/ +doc/source/dashboards diff --git a/README.rst b/README.rst index 9855812..75de60a 100644 --- a/README.rst +++ b/README.rst @@ -44,8 +44,8 @@ the dashboard file you want the URL for:: Then put the URL in your browser and off you go. -A daily updated index of all available dashboards is available -at ``__ +The latest dashboards are available at +``__ Contributions Welcomed diff --git a/doc/source/conf.py b/doc/source/conf.py index 7ed44b3..977af17 100755 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -12,6 +12,7 @@ # limitations under the License. import os +import subprocess import sys sys.path.insert(0, os.path.abspath('../..')) @@ -68,3 +69,15 @@ latex_documents = [ u'%s Documentation' % project, u'OpenStack Foundation', 'manual'), ] + +# this is a bit of a hack that generates the RST for each dashboard +# dynamically and works from tox -e docs & on readthedocs. It has to +# put it in doc/source to get picked up as part of the build. +def setup(app): + if os.getcwd().endswith("doc/source"): + prefix = "cd ../../;" + else: + prefix = "" + + subprocess.call("%s ./tools/generate_dashboards.sh" % (prefix), + shell=True) diff --git a/doc/source/index.rst b/doc/source/index.rst index 7be983a..9aae4e0 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -1,20 +1,12 @@ -Welcome to gerrit-dash-creator's documentation! -=============================================== +.. include:: ../../README.rst -Contents: +Further reading +=============== .. toctree:: - :maxdepth: 2 + :maxdepth: 1 - readme installation usage contributing - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - + dashboards/index diff --git a/doc/source/readme.rst b/doc/source/readme.rst deleted file mode 100644 index a6210d3..0000000 --- a/doc/source/readme.rst +++ /dev/null @@ -1 +0,0 @@ -.. include:: ../../README.rst diff --git a/templates/single.rst b/templates/single.rst index 97f252e..a9ec2ad 100644 --- a/templates/single.rst +++ b/templates/single.rst @@ -2,17 +2,25 @@ ============================================================================== {% if description %} -Description:: - - {{ description }} +Description +----------- +{{ description }} {%- endif %} -URL:: +URL +--- - {{ url }} +:: + + {{ url }} + +`View this dashboard <{{ url }}>`__ {% if configuration %} -Configuration:: +Configuration +------------- + +:: {% for line in configuration.splitlines() %} {{ line }} diff --git a/tools/generate_dashboards.sh b/tools/generate_dashboards.sh index 2d66f4b..094691c 100755 --- a/tools/generate_dashboards.sh +++ b/tools/generate_dashboards.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -12,25 +12,20 @@ # License for the specific language governing permissions and limitations # under the License. -output_directory=doc/dashboards/ +set -x -if [[ -e $output_directory ]]; then - rm -f $output_directory/* +OUTPUT_DIRECTORY=${OUTPUT_DIRECTORY:-doc/source/dashboards/} + +if [[ -e $OUTPUT_DIRECTORY ]]; then + rm -f $OUTPUT_DIRECTORY/* else - mkdir -p $output_directory + mkdir -p $OUTPUT_DIRECTORY fi -cp doc/source/conf.py $output_directory - -echo " -html_theme_options = { - 'nosidebar': True -}" >> $output_directory/conf.py - for dashboard in $(find dashboards -name '*.dash' | sort); do output=$(basename $dashboard .dash) python gerrit_dash_creator/cmd/creator.py --template-directory templates \ - --template single.rst $dashboard > $output_directory/dashboard_$output.rst + --template single.rst $dashboard > $OUTPUT_DIRECTORY/dashboard_$output.rst done echo "=========================== @@ -38,9 +33,10 @@ OpenStack Gerrit Dashboards =========================== .. toctree:: -" >> $output_directory/index.rst + :maxdepth: 1 +" >> $OUTPUT_DIRECTORY/index.rst -for dashboard in $(find $output_directory -name 'dashboard_*.rst' | sort); do +for dashboard in $(find $OUTPUT_DIRECTORY -name 'dashboard_*.rst' | sort); do dashboard=$(basename $dashboard .rst) - echo " " $dashboard >> $output_directory/index.rst + echo " " $dashboard >> $OUTPUT_DIRECTORY/index.rst done diff --git a/tox.ini b/tox.ini index a625090..d20e358 100644 --- a/tox.ini +++ b/tox.ini @@ -26,7 +26,8 @@ commands = python setup.py testr --coverage --testr-args='{posargs}' [testenv:docs] commands = - doc8 -e .rst doc CONTRIBUTING.rst HACKING.rst README.rst +# not happy with generated dashboard pages +# doc8 -e .rst doc CONTRIBUTING.rst HACKING.rst README.rst python setup.py build_sphinx [flake8]