add deliverables directive and source files
Change-Id: I8da828e08286f371d7c2802810ad25f7eb2365a4
This commit is contained in:
parent
ae42958f37
commit
a6504c20f9
@ -3,12 +3,11 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.abspath('../..'))
|
||||
# -- General configuration ----------------------------------------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
extensions = ['sphinx.ext.autodoc', 'oslosphinx']
|
||||
extensions = ['sphinx.ext.autodoc', 'oslosphinx', 'openstack_releases.sphinxext']
|
||||
|
||||
config_generator_config_file = 'config-generator.conf'
|
||||
|
||||
|
@ -2,4 +2,7 @@
|
||||
OpenStack Releases
|
||||
====================
|
||||
|
||||
boo!
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
releases/index
|
||||
|
6
doc/source/releases/cactus.rst
Normal file
6
doc/source/releases/cactus.rst
Normal file
@ -0,0 +1,6 @@
|
||||
========
|
||||
Cactus
|
||||
========
|
||||
|
||||
.. deliverable::
|
||||
:series: cactus
|
6
doc/source/releases/diablo.rst
Normal file
6
doc/source/releases/diablo.rst
Normal file
@ -0,0 +1,6 @@
|
||||
========
|
||||
Diablo
|
||||
========
|
||||
|
||||
.. deliverable::
|
||||
:series: diablo
|
6
doc/source/releases/essex.rst
Normal file
6
doc/source/releases/essex.rst
Normal file
@ -0,0 +1,6 @@
|
||||
=======
|
||||
Essex
|
||||
=======
|
||||
|
||||
.. deliverable::
|
||||
:series: essex
|
6
doc/source/releases/folsom.rst
Normal file
6
doc/source/releases/folsom.rst
Normal file
@ -0,0 +1,6 @@
|
||||
========
|
||||
Folsom
|
||||
========
|
||||
|
||||
.. deliverable::
|
||||
:series: folsom
|
6
doc/source/releases/grizzly.rst
Normal file
6
doc/source/releases/grizzly.rst
Normal file
@ -0,0 +1,6 @@
|
||||
=========
|
||||
Grizzly
|
||||
=========
|
||||
|
||||
.. deliverable::
|
||||
:series: grizzly
|
6
doc/source/releases/havana.rst
Normal file
6
doc/source/releases/havana.rst
Normal file
@ -0,0 +1,6 @@
|
||||
========
|
||||
Havana
|
||||
========
|
||||
|
||||
.. deliverable::
|
||||
:series: havana
|
6
doc/source/releases/icehouse.rst
Normal file
6
doc/source/releases/icehouse.rst
Normal file
@ -0,0 +1,6 @@
|
||||
==========
|
||||
Icehouse
|
||||
==========
|
||||
|
||||
.. deliverable::
|
||||
:series: icehouse
|
9
doc/source/releases/index.rst
Normal file
9
doc/source/releases/index.rst
Normal file
@ -0,0 +1,9 @@
|
||||
====================
|
||||
OpenStack Releases
|
||||
====================
|
||||
|
||||
.. toctree::
|
||||
:glob:
|
||||
:maxdepth: 1
|
||||
|
||||
*
|
6
doc/source/releases/juno.rst
Normal file
6
doc/source/releases/juno.rst
Normal file
@ -0,0 +1,6 @@
|
||||
======
|
||||
Juno
|
||||
======
|
||||
|
||||
.. deliverable::
|
||||
:series: juno
|
6
doc/source/releases/kilo.rst
Normal file
6
doc/source/releases/kilo.rst
Normal file
@ -0,0 +1,6 @@
|
||||
======
|
||||
Kilo
|
||||
======
|
||||
|
||||
.. deliverable::
|
||||
:series: kilo
|
6
doc/source/releases/liberty.rst
Normal file
6
doc/source/releases/liberty.rst
Normal file
@ -0,0 +1,6 @@
|
||||
=========
|
||||
Liberty
|
||||
=========
|
||||
|
||||
.. deliverable::
|
||||
:series: liberty
|
106
openstack_releases/sphinxext.py
Normal file
106
openstack_releases/sphinxext.py
Normal file
@ -0,0 +1,106 @@
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import glob
|
||||
import os.path
|
||||
|
||||
from docutils import nodes
|
||||
from docutils.parsers import rst
|
||||
from docutils.parsers.rst import directives
|
||||
from docutils.statemachine import ViewList
|
||||
from sphinx.util.nodes import nested_parse_with_titles
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
def _list_table(add, headers, data):
|
||||
"""Build a list-table directive.
|
||||
|
||||
:param add: Function to add one row to output.
|
||||
:param headers: List of header values.
|
||||
:param data: Iterable of row data, yielding lists or tuples with rows.
|
||||
"""
|
||||
add('.. list-table::')
|
||||
add(' :header-rows: 1')
|
||||
add('')
|
||||
add(' - * %s' % headers[0])
|
||||
for h in headers[1:]:
|
||||
add(' * %s' % h)
|
||||
for row in data:
|
||||
add(' - * %s' % row[0])
|
||||
for r in row[1:]:
|
||||
add(' * %s' % r)
|
||||
add('')
|
||||
|
||||
|
||||
class DeliverableDirective(rst.Directive):
|
||||
|
||||
option_spec = {
|
||||
'series': directives.unchanged,
|
||||
}
|
||||
|
||||
def run(self):
|
||||
env = self.state.document.settings.env
|
||||
app = env.app
|
||||
|
||||
series = self.options.get('series')
|
||||
if not series:
|
||||
error = self.state_machine.reporter.error(
|
||||
'No series set for deliverable directive',
|
||||
nodes.literal_block(self.block_text, self.block_text),
|
||||
line=self.lineno)
|
||||
return [error]
|
||||
|
||||
result = ViewList()
|
||||
|
||||
for filename in sorted(glob.glob('deliverables/%s/*.yaml' % series)):
|
||||
app.info('[deliverables] reading %s' % filename)
|
||||
with open(filename, 'r') as f:
|
||||
deliverable_info = yaml.load(f.read())
|
||||
deliverable_name = os.path.basename(filename)[:-5] # strip .yaml ext
|
||||
|
||||
# These closures need to be redefined in each iteration of
|
||||
# the loop because they use the filename.
|
||||
def _add(text):
|
||||
result.append(text, filename)
|
||||
|
||||
def _title(text, underline):
|
||||
text = str(text) # version numbers might be converted to floats
|
||||
_add(text)
|
||||
_add(underline * len(text))
|
||||
_add('')
|
||||
|
||||
def _rubric(text):
|
||||
text = str(text) # version numbers might be converted to floats
|
||||
_add('.. rubric:: %s' % text)
|
||||
_add('')
|
||||
|
||||
_title(deliverable_name, '=')
|
||||
|
||||
for release in deliverable_info.get('releases', []):
|
||||
app.info('[deliverables] release %s' % release['version'])
|
||||
_rubric(release['version'])
|
||||
_list_table(
|
||||
_add, ['Repo', 'SHA'],
|
||||
((p['repo'], p['hash']) for p in release.get('projects', []))
|
||||
)
|
||||
|
||||
node = nodes.section()
|
||||
node.document = self.state.document
|
||||
nested_parse_with_titles(self.state, result, node)
|
||||
return node.children
|
||||
|
||||
|
||||
def setup(app):
|
||||
app.add_directive('deliverable', DeliverableDirective)
|
@ -25,6 +25,11 @@ console_scripts =
|
||||
validate-request = openstack_releases.cmds.validate:main
|
||||
list-changes = openstack_releases.cmds.list_changes:main
|
||||
|
||||
[extras]
|
||||
sphinxext =
|
||||
sphinx
|
||||
oslosphinx
|
||||
|
||||
[build_sphinx]
|
||||
source-dir = doc/source
|
||||
build-dir = doc/build
|
||||
|
Loading…
Reference in New Issue
Block a user