Hello community,
here is the log from the commit of package python-sphinxcontrib-docbookrestapi
for openSUSE:Factory checked in at 2015-10-30 13:43:55
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-sphinxcontrib-docbookrestapi (Old)
and /work/SRC/openSUSE:Factory/.python-sphinxcontrib-docbookrestapi.new
(New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-sphinxcontrib-docbookrestapi"
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-sphinxcontrib-docbookrestapi/python-sphinxcontrib-docbookrestapi.changes
2014-04-20 11:36:37.000000000 +0200
+++
/work/SRC/openSUSE:Factory/.python-sphinxcontrib-docbookrestapi.new/python-sphinxcontrib-docbookrestapi.changes
2015-10-30 13:43:56.000000000 +0100
@@ -2 +2 @@
-Mon Apr 14 13:36:51 UTC 2014 - [email protected]
+Wed Jul 29 11:04:45 UTC 2015 - [email protected]
@@ -4 +4 @@
-- add 0001-Fix-the-code-to-work-with-Python2.6.patch
+- Unify spec file. Use fedora compatible files macros
@@ -7 +7 @@
-Wed Apr 9 13:09:49 UTC 2014 - [email protected]
+Wed Sep 3 13:39:57 UTC 2014 - [email protected]
@@ -9 +9,21 @@
-- go back to released version (0.1)
+- update to 0.2.1:
+ * Bump to 0.2.1
+ * add venv to tox.ini
+ * Bump to 0.2
+ * Add the Python 3 classifiers in setup.cfg
+ * Declare sphinxcontrib.docbookrestapi package
+ * Properly declare namespace package
+ * Properly document the enumeration type
+ * Allow foo_name as well as foo_id in paths
+ * Remove 'xmlns' attribute of 'param' elements
+ * Use 'para' elements instead of 'p' ones
+ * Add the top-level comment that is now mandatory in WADL files
+ * Add an XML declaration in the output
+ * Use 'wadl:doc' instead of 'doc' and fix its attributes
+ * Add a mandatory 'id' attribute to 'resource' elements
+ * Removes whitespaces at the end of self-closing tags
+ * Sync with global requirements
+ * Add tests
+ * Python 3 compatibility
+ * Fix the code to work with Python2.6
+ * tox.ini: clean the pep8 target
@@ -11 +31 @@
-------------------------------------------------------------------
+-------------------------------------------------------------------
Old:
----
0001-Fix-the-code-to-work-with-Python2.6.patch
sphinxcontrib-docbookrestapi-0.1.tar.gz
New:
----
sphinxcontrib-docbookrestapi-0.2.1.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-sphinxcontrib-docbookrestapi.spec ++++++
--- /var/tmp/diff_new_pack.M4K4Qy/_old 2015-10-30 13:43:56.000000000 +0100
+++ /var/tmp/diff_new_pack.M4K4Qy/_new 2015-10-30 13:43:56.000000000 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-sphinxcontrib-docbookrestapi
#
-# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,16 +17,16 @@
Name: python-sphinxcontrib-docbookrestapi
-Version: 0.1
+Version: 0.2.1
Release: 0
Summary: Extension to Sphinx for generating REST API documentation
License: Apache-2.0
Group: Development/Languages/Python
-Url: https://github.com/stackforge/sphinxcontrib-docbookrestapi
-Source: sphinxcontrib-docbookrestapi-%{version}.tar.gz
+Url:
https://git.openstack.org/cgit/stackforge/sphinxcontrib-docbookrestapi/
+Source:
https://pypi.python.org/packages/source/s/sphinxcontrib-docbookrestapi/sphinxcontrib-docbookrestapi-%{version}.tar.gz
# PATCH-FIX-UPSTREAM [email protected] --
https://review.openstack.org/#/c/84132/
Patch0: 0001-Properly-declare-namespace-package.patch
-Patch1: 0001-Fix-the-code-to-work-with-Python2.6.patch
+BuildRequires: openstack-suse-macros
BuildRequires: python-devel
BuildRequires: python-pbr
Requires: python-Sphinx
@@ -45,17 +45,16 @@
%prep
%setup -q -n sphinxcontrib-docbookrestapi-%{version}
%patch0 -p1
-%patch1 -p1
%build
-python setup.py build
+%{__python2} setup.py build
%install
-python setup.py install --prefix=%{_prefix} --root=%{buildroot}
+%{__python2} setup.py install --prefix=%{_prefix} --root=%{buildroot}
%files
%defattr(-,root,root,-)
%doc AUTHORS LICENSE ChangeLog README.rst
-%{python_sitelib}/*
+%{python2_sitelib}/*
%changelog
++++++ _service ++++++
--- /var/tmp/diff_new_pack.M4K4Qy/_old 2015-10-30 13:43:57.000000000 +0100
+++ /var/tmp/diff_new_pack.M4K4Qy/_new 2015-10-30 13:43:57.000000000 +0100
@@ -1,16 +1,12 @@
<services>
- <service mode="disabled" name="tar_scm">
- <param
name="url">git://github.com/stackforge/sphinxcontrib-docbookrestapi.git</param>
- <param name="scm">git</param>
- <param name="package-meta">.git</param>
- <param name="versionformat">@PARENT_TAG@+git.%ct.%h</param>
- <param name="revision">master</param>
+ <service mode="disabled" name="download_files">
<param name="changesgenerate">enable</param>
</service>
- <service mode="disabled" name="python_sdist">
- <param name="basename">sphinxcontrib-docbookrestapi-*.tar</param>
+ <service mode="disabled" name="set_version">
+ <param name="basename">sphinxcontrib-docbookrestapi</param>
+ </service>
+ <service mode="disabled" name="python_requires">
</service>
-
<service name="refresh_patches" mode="disabled">
<param name="changesgenerate">enable</param>
</service>
++++++ sphinxcontrib-docbookrestapi-0.1.tar.gz ->
sphinxcontrib-docbookrestapi-0.2.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/sphinxcontrib-docbookrestapi-0.1/.testr.conf
new/sphinxcontrib-docbookrestapi-0.2.1/.testr.conf
--- old/sphinxcontrib-docbookrestapi-0.1/.testr.conf 1970-01-01
01:00:00.000000000 +0100
+++ new/sphinxcontrib-docbookrestapi-0.2.1/.testr.conf 2014-05-05
17:20:24.000000000 +0200
@@ -0,0 +1,4 @@
+[DEFAULT]
+test_command=${PYTHON:-python} -m subunit.run discover
sphinxcontrib/docbookrestapi/tests $LISTOPT $IDOPTION
+test_id_option=--load-list $IDFILE
+test_list_option=--list
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/sphinxcontrib-docbookrestapi-0.1/AUTHORS
new/sphinxcontrib-docbookrestapi-0.2.1/AUTHORS
--- old/sphinxcontrib-docbookrestapi-0.1/AUTHORS 2013-12-03
17:34:28.000000000 +0100
+++ new/sphinxcontrib-docbookrestapi-0.2.1/AUTHORS 2014-05-05
17:20:45.000000000 +0200
@@ -1 +1 @@
-Cyril Roelandt <[email protected]>
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/sphinxcontrib-docbookrestapi-0.1/ChangeLog
new/sphinxcontrib-docbookrestapi-0.2.1/ChangeLog
--- old/sphinxcontrib-docbookrestapi-0.1/ChangeLog 2013-12-03
17:34:28.000000000 +0100
+++ new/sphinxcontrib-docbookrestapi-0.2.1/ChangeLog 2014-05-05
17:20:45.000000000 +0200
@@ -1,128 +1,50 @@
-commit ee217854eb3488464b4ad833d1d370e8e335036c
-Author: Cyril Roelandt <[email protected]>
-Date: Mon Nov 18 14:17:48 2013 +0100
+CHANGES
+=======
- Allow complex types for parameters
-
- Tools like Ceilometer need to have "Alarm" as a type, instead of something
as
- simple as "string" or "int".
-
- Change-Id: I16af1e077ee4641f52a2607f6269e1dd633b4b54
+0.2.1
+-----
-commit 220cd4907d6bc27256b42ecfae604900d4670840
-Merge: e1d097d fae50a8
-Author: Jenkins <[email protected]>
-Date: Fri Nov 15 19:26:59 2013 +0000
+* Bump to 0.2.1
+* add venv to tox.ini
- Merge "Fix the generate_id function with PUT methods"
-
-commit fae50a847140fd69a031548be641c10bfbcfaf64
-Author: Cyril Roelandt <[email protected]>
-Date: Fri Nov 15 20:20:08 2013 +0100
-
- Fix the generate_id function with PUT methods
-
- Now handle methods such as /v2/alarms/alarm_id/state.
-
- Change-Id: I15cdc6a65f38fee7e4ad6559741144fdf43eb1f6
-
-commit e1d097d9150233d00d39300e6ea250231a0af28a
-Author: Cyril Roelandt <[email protected]>
-Date: Fri Nov 15 20:07:29 2013 +0100
-
- Add .gitreview file
-
- Change-Id: I054681c9c23747827a5b1708e7ddd37f1d12266b
-
-commit 819e98a84e39b3734ad08d7a62779354dd7194fa
-Author: Cyril Roelandt <[email protected]>
-Date: Wed Oct 16 20:28:16 2013 +0000
-
- Wrap lines in the generated WADL file
-
-commit 16c1a9c0625d5c8a2a54f71161ac17c26d286a90
-Author: Cyril Roelandt <[email protected]>
-Date: Wed Oct 16 20:16:51 2013 +0000
-
- Generated human-readable method ids and titles
-
-commit 86a69a01c03ac97e9506f07da5dbe5a2a5fbf86b
-Author: Cyril Roelandt <[email protected]>
-Date: Thu Oct 10 10:56:46 2013 +0000
-
- Use '<para role="shortdoc">...</para>'
-
- Inside the 'wadl:doc', this is what should be used to write the
description of
- the method, instead of a simple 'p' element.
-
-commit 8698122d4f3c33174c1db63a4986ef472289a31f
-Author: Cyril Roelandt <[email protected]>
-Date: Thu Oct 10 10:52:50 2013 +0000
-
- Make the 'wadl:doc' element appear first
-
- Inside 'method' elements, the 'wadl:doc' element should appear before the
- 'request' and 'response' elements.
-
-commit 0b6dce2be73a6c0c76ae81bcacd2d68287e03536
-Author: Cyril Roelandt <[email protected]>
-Date: Mon Oct 7 13:23:01 2013 +0000
-
- Fix PEP8-related warnings
-
- Add a tox.ini (mostly stolen from ceilometer), so that one can run 'tox
- -epep8'.
-
-commit 1f88543554ff64b5e5465dc2dd93d5c11e29fa2d
-Author: Cyril Roelandt <[email protected]>
-Date: Mon Oct 7 12:11:41 2013 +0000
-
- Remove the version hack in setup.py
-
-commit 7d446b37a3fc604aa7f3cfb385cb3c537b752844
-Author: Cyril Roelandt <[email protected]>
-Date: Mon Oct 7 12:00:17 2013 +0000
-
- Indent the generated WADL file
-
- Also, remove the lxml import that was never needed.
-
-commit 552b8c94046d4e7d2e07dbc3f699d95fbc1e869a
-Author: Cyril Roelandt <[email protected]>
-Date: Mon Oct 7 10:36:09 2013 +0000
-
- Only parse the intended files
-
- Files meant to be parsed by sphinxcontrib-docbookrestapi should now have a
- comment that reads 'docbookrestapi' before the first section of the RST,
- otherwise they'll be ignored.
-
-commit 3753d6bfdec29b98d28d2420ca983c075fffc596
-Author: Cyril Roelandt <[email protected]>
-Date: Tue Oct 1 12:41:19 2013 +0000
-
- Move code to sphinxcontrib/docbookrestapi.
-
-commit 3a7d7976793246a6a7654dd213a0ff26a1b595f5
-Author: Cyril Roelandt <[email protected]>
-Date: Fri Sep 27 13:22:04 2013 +0000
-
- MyNodeVisitor: call SparseNodeVisitor.__init__()
-
-commit 79720726fd756278f926a736b1d84028e3d0e973
-Author: Cyril Roelandt <[email protected]>
-Date: Fri Sep 27 12:12:33 2013 +0000
-
- sphinxcontrib/setup.py: Add license header.
-
-commit 3111e93bee6609d7e174d395374518f5651f7755
-Author: Cyril Roelandt <[email protected]>
-Date: Fri Sep 27 12:12:09 2013 +0000
-
- Add missing shebangs.
-
-commit 2df0486705dc610909527c2e2a495cddd83c86d1
-Author: Cyril Roelandt <[email protected]>
-Date: Thu Sep 26 14:59:01 2013 +0000
-
- Initial commit.
\ No newline at end of file
+0.2
+---
+
+* Bump to 0.2
+* Add the Python 3 classifiers in setup.cfg
+* Declare sphinxcontrib.docbookrestapi package
+* Properly declare namespace package
+* Properly document the enumeration type
+* Allow foo_name as well as foo_id in paths
+* Remove 'xmlns' attribute of 'param' elements
+* Use 'para' elements instead of 'p' ones
+* Add the top-level comment that is now mandatory in WADL files
+* Add an XML declaration in the output
+* Use 'wadl:doc' instead of 'doc' and fix its attributes
+* Add a mandatory 'id' attribute to 'resource' elements
+* Removes whitespaces at the end of self-closing tags
+* Sync with global requirements
+* Add tests
+* Python 3 compatibility
+* Fix the code to work with Python2.6
+* tox.ini: clean the pep8 target
+
+0.1
+---
+
+* Allow complex types for parameters
+* Fix the generate_id function with PUT methods
+* Add .gitreview file
+* Wrap lines in the generated WADL file
+* Generated human-readable method ids and titles
+* Use '<para role="shortdoc">...</para>'
+* Make the 'wadl:doc' element appear first
+* Fix PEP8-related warnings
+* Remove the version hack in setup.py
+* Indent the generated WADL file
+* Only parse the intended files
+* Move code to sphinxcontrib/docbookrestapi
+* MyNodeVisitor: call SparseNodeVisitor.__init__()
+* sphinxcontrib/setup.py: Add license header
+* Add missing shebangs
+* Initial commit
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/sphinxcontrib-docbookrestapi-0.1/PKG-INFO
new/sphinxcontrib-docbookrestapi-0.2.1/PKG-INFO
--- old/sphinxcontrib-docbookrestapi-0.1/PKG-INFO 2013-12-03
17:34:28.000000000 +0100
+++ new/sphinxcontrib-docbookrestapi-0.2.1/PKG-INFO 2014-05-05
17:20:45.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: sphinxcontrib-docbookrestapi
-Version: 0.1
+Version: 0.2.1
Summary: Extension to Sphinx for generating REST API documentation for
http://api.openstack.org/
Home-page: UNKNOWN
Author: Cyril Roelandt
@@ -24,4 +24,6 @@
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
Classifier: Topic :: Software Development :: Documentation
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/sphinxcontrib-docbookrestapi-0.1/requirements.txt
new/sphinxcontrib-docbookrestapi-0.2.1/requirements.txt
--- old/sphinxcontrib-docbookrestapi-0.1/requirements.txt 2013-12-03
12:48:06.000000000 +0100
+++ new/sphinxcontrib-docbookrestapi-0.2.1/requirements.txt 2014-05-05
17:20:24.000000000 +0200
@@ -1 +1,3 @@
-pytidylib>=0.2.1
+docutils==0.9.1
+pytidylib6
+sphinx>=1.1.2,<1.2
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/sphinxcontrib-docbookrestapi-0.1/setup.cfg
new/sphinxcontrib-docbookrestapi-0.2.1/setup.cfg
--- old/sphinxcontrib-docbookrestapi-0.1/setup.cfg 2013-12-03
17:34:28.000000000 +0100
+++ new/sphinxcontrib-docbookrestapi-0.2.1/setup.cfg 2014-05-05
17:20:45.000000000 +0200
@@ -14,16 +14,19 @@
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 2.7
+ Programming Language :: Python :: 3
+ Programming Language :: Python :: 3.3
Topic :: Software Development :: Documentation
keywords =
documentation
docbook
sphinx
-version = 0.1
+version = 0.2.1
[files]
packages =
sphinxcontrib
+ sphinxcontrib.docbookrestapi
namespace_packages =
sphinxcontrib
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/sphinxcontrib-docbookrestapi-0.1/sphinxcontrib/__init__.py
new/sphinxcontrib-docbookrestapi-0.2.1/sphinxcontrib/__init__.py
--- old/sphinxcontrib-docbookrestapi-0.1/sphinxcontrib/__init__.py
2013-11-15 19:47:04.000000000 +0100
+++ new/sphinxcontrib-docbookrestapi-0.2.1/sphinxcontrib/__init__.py
2014-05-05 17:20:24.000000000 +0200
@@ -0,0 +1,17 @@
+# Copyright (C) 2013 eNovance SAS <[email protected]>
+#
+# Author: Cyril Roelandt <[email protected]>
+#
+# 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__('pkg_resources').declare_namespace(__name__)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/sphinxcontrib-docbookrestapi-0.1/sphinxcontrib/docbookrestapi/docbook.py
new/sphinxcontrib-docbookrestapi-0.2.1/sphinxcontrib/docbookrestapi/docbook.py
---
old/sphinxcontrib-docbookrestapi-0.1/sphinxcontrib/docbookrestapi/docbook.py
2013-12-03 17:32:08.000000000 +0100
+++
new/sphinxcontrib-docbookrestapi-0.2.1/sphinxcontrib/docbookrestapi/docbook.py
2014-05-05 17:20:24.000000000 +0200
@@ -15,6 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+from datetime import date
from docutils.nodes import SparseNodeVisitor, StopTraversal
import json
import os
@@ -30,7 +31,7 @@
path = path.replace('(', '')
path = path.replace(')', '')
elems = path.split('/')
- elems = filter(lambda x: x, elems) # Remove empty strings
+ elems = list(filter(lambda x: x, elems)) # Remove empty strings
elems = elems[1:] # Remove "vx" (v1, v2...)
n_elems = len(elems)
@@ -42,15 +43,22 @@
elif method == 'get':
if elems[-1].endswith('_id'):
name += "show" + elems[-1][0:-3].capitalize()
+ elif elems[-1].endswith('_name'):
+ name += "show" + elems[-1][0:-5].capitalize()
elif n_elems > 2:
if elems[-3][:-1] + '_id' == elems[-2]:
name += 'show' + elems[-3][:-1].capitalize()
name += elems[-1].capitalize()
+ elif elems[-3][:-1] + '_name' == elems[-2]:
+ name += 'show' + elems[-3][:-1].capitalize()
+ name += elems[-1].capitalize()
else:
name += "list" + elems[-1].capitalize()
elif method == 'post':
if elems[-1].endswith('_id'):
name += "create" + elems[-1][0:-3].capitalize()
+ elif elems[-1].endswith('_name'):
+ name += "create" + elems[-1][0:-5].capitalize()
else:
name += "create" + elems[-1][:-1].capitalize()
elif method == 'put':
@@ -82,6 +90,37 @@
return ' '.join(words).capitalize()
+def clean_up_xml(xml_str):
+ # When using UTF-8, tidy does not add an encoding attribute. Do it
+ # ourselves. See
+ # http://tidy.cvs.sourceforge.net/viewvc/tidy/tidy/src/lexer.c?
+ # revision=1.194&view=markup
+ xml_str = xml_str.replace('?>', ' encoding="UTF-8"?>', 1)
+
+ # tidy automatically inserts a whitespace at the end of a self-closing tag.
+ # See line 1347 at:
+ # http://tidy.cvs.sourceforge.net/viewvc/tidy/tidy/src/pprint.c?
+ # revision=1.119&view=markup
+
+ xml_str = xml_str.replace(' />', '/>')
+
+ # Add this comment right after the <?...?> line. Not sure how to do this
+ # using ElementTree.Comment(), since there is no parent element here.
+ # XXX(cyril): The starting year may not be the right one for every project.
+ xml_str = xml_str.replace('?>\n', '''?>
+<!-- (C) 2012-%d OpenStack Foundation, All Rights Reserved -->
+<!--*******************************************************-->
+<!-- Import Common XML Entities -->
+<!-- -->
+<!-- You can resolve the entites with xmllint -->
+<!-- -->
+<!-- xmllint -noent os-compute-2.wadl -->
+<!--*******************************************************-->
+''' % date.today().year, 1)
+
+ return xml_str
+
+
class MyNodeVisitor(SparseNodeVisitor):
def __init__(self, document):
SparseNodeVisitor.__init__(self, document)
@@ -130,7 +169,12 @@
def build_resources(root, d, path=''):
for k, v in d.iteritems():
- tmp = ET.SubElement(root, 'resource', {'path': k})
+ tmp = ET.SubElement(root, 'resource', {
+ # NOTE(cyril): sometimes, id and path might differ. This
+ # should be good enough, though.
+ 'id': k.replace('{', '').replace('}', ''),
+ 'path': k,
+ })
if path + '/' + k + '/' in self.paths:
for method in self.paths[path + '/' + k + '/']:
ET.SubElement(tmp, 'method', {'href': '#' + method})
@@ -145,16 +189,17 @@
# Finally, write the output.
with open(output_file, 'w+') as f:
options = {
- 'add-xml-decl': False,
+ 'add-xml-decl': True,
'indent': True,
'indent-spaces': 4,
'input-xml': True,
+ 'output-encoding': 'utf8',
'output-xml': True,
'wrap': 70
}
xml_str = tidylib.tidy_document(ET.tostring(self.root),
options=options)[0]
- f.write(xml_str)
+ f.write(clean_up_xml(xml_str))
# If we're inside a bullet list, all the "paragraph" elements will be
# parameters description, so we need to know whether we currently are in a
@@ -189,12 +234,12 @@
self.in_method_definition = False
def visit_desc(self, node):
- attrs = {k: v for (k, v) in node.attlist()}
+ attrs = dict(node.attlist())
if attrs['domain'] == 'http':
self.in_method_definition = True
def visit_desc_signature(self, node):
- attrs = {k: v for (k, v) in node.attlist()}
+ attrs = dict(node.attlist())
if 'method' in attrs and 'path' in attrs:
method_id = generate_id(attrs['path'], attrs['method'])
self.current_method = ET.Element('method', {
@@ -206,7 +251,7 @@
self.paths.setdefault(path, []).append(method_id)
self.current_wadl_doc = ET.SubElement(
self.current_method, 'wadl:doc', {
- 'xmlns': 'http://www.w3.org/1999/xhtml',
+ 'xmlns': 'http://docbook.org/ns/docbook',
'xml:lang': 'EN',
'title': generate_title_from_id(method_id)
}
@@ -241,12 +286,20 @@
text = node.astext()
dashes_index = text.find('--')
param_name = text[0:text.find(' ')]
- param_type = text[text.find(' ') + 1: dashes_index - 1]
+ param_type = text[text.find(' ') + 1: dashes_index - 2]
param_descr = text[dashes_index + 3:]
param_type = param_type[1:] # Remove '('
+ # Sometimes (especially when using enumerations), only some values
+ # may be allowed. If so, they should be listed in the
+ # documentation; store them here, and insert them in the code when
+ # creating the required elements.
+ valid_values = None
# There are probably more types.
- if param_type.startswith("int"):
+ if param_type.startswith("Enum"):
+ valid_values = param_type[5:-1].split(', ')
+ param_type = 'xsd:dict'
+ elif param_type.startswith("int"):
param_type = 'xsd:int'
elif param_type.startswith("list"):
param_type = 'xsd:list'
@@ -256,16 +309,28 @@
param_type = param_type[:-1] # Remove ')'
tmp = ET.SubElement(self.current_request, 'param', {
- 'xmlns': 'http://wadl.dev.java.net/2009/02',
'name': param_name,
'type': param_type,
'required': 'false', # XXX Can we get the right value ?
'style': 'query' # XXX Can we get the right value ?
})
- tmp = ET.SubElement(tmp, 'doc')
- ET.SubElement(tmp, 'p', {
- 'xmlns': 'http://www.w3.org/1999/xhtml'
- }).text = param_descr
+ tmp = ET.SubElement(tmp, 'wadl:doc', {
+ 'xml:lang': 'EN',
+ 'xmlns': 'http://docbook.org/ns/docbook'
+ })
+ tmp = ET.SubElement(tmp, 'para')
+ tmp.text = param_descr
+ if valid_values:
+ tmp.text += ' Valid values are '
+ for i, value in enumerate(valid_values):
+ code = ET.SubElement(tmp, 'code')
+ code.text = value
+ if i + 1 != len(valid_values):
+ code.tail = ', '
+ if i + 2 == len(valid_values):
+ code.tail += 'or '
+ else:
+ code.tail = '.'
elif self.in_request or self.in_response:
self.visit_term(node)
@@ -286,7 +351,7 @@
tmp = ET.SubElement(parent, 'representation', {
'mediaType': 'application/json'
})
- tmp = ET.SubElement(tmp, 'doc', {'xml:lang': 'EN'})
+ tmp = ET.SubElement(tmp, 'wadl:doc', {'xml:lang': 'EN'})
json_text = json.loads(''.join(body))
json_text = json.dumps(json_text, indent=4, sort_keys=True)
ET.SubElement(tmp, 'xsdxt:code').text = json_text
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/sphinxcontrib-docbookrestapi-0.1/sphinxcontrib/docbookrestapi/tests/test_utils.py
new/sphinxcontrib-docbookrestapi-0.2.1/sphinxcontrib/docbookrestapi/tests/test_utils.py
---
old/sphinxcontrib-docbookrestapi-0.1/sphinxcontrib/docbookrestapi/tests/test_utils.py
1970-01-01 01:00:00.000000000 +0100
+++
new/sphinxcontrib-docbookrestapi-0.2.1/sphinxcontrib/docbookrestapi/tests/test_utils.py
2014-05-05 17:20:24.000000000 +0200
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+# Copyright (C) 2013 eNovance SAS <[email protected]>
+#
+# Author: Cyril Roelandt <[email protected]>
+#
+# 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 unittest
+
+from sphinxcontrib.docbookrestapi.docbook import clean_up_xml, generate_id
+
+
+class TestUtils(unittest.TestCase):
+ def test_generate_id(self):
+ test_cases = [
+ # (path, method, expected_result)
+ ('/v2/foos', 'get', 'listFoos'),
+
+ ('/v2/foos/foo_id', 'delete', 'deleteFoo'),
+ ('/v2/foos/foo_id', 'get', 'showFoo'),
+ ('/v2/foos/foo_id', 'post', 'createFoo'),
+ ('/v2/foos/foo_id', 'put', 'updateFoo'),
+
+ ('/v2/foos/foo_id/bar', 'get', 'showFooBar'),
+ ('/v2/foos/foo_id/bar', 'put', 'updateFooBar'),
+
+ ('/v2/foos/foo_name', 'get', 'showFoo'),
+ ('/v2/foos/foo_name', 'post', 'createFoo'),
+
+ ('/v2/foos/foo_name/bar', 'get', 'showFooBar'),
+ ]
+
+ for (path, method, result) in test_cases:
+ self.assertEqual(generate_id(path, method), result)
+
+ def test_clean_up_xml_encoding(self):
+ # Make sure the right encoding is added.
+ self.assertEqual(
+ clean_up_xml('<?xml version="1.0"?>'),
+ '<?xml version="1.0" encoding="UTF-8"?>'
+ )
+
+ def test_clean_up_xml(self):
+ # Make sure the whitespace at the end of a self-closing tag is removed.
+ bad_xml = '''
+<root>
+ <selfclosingtag />
+</root>'''
+ good_xml = '''
+<root>
+ <selfclosingtag/>
+</root>'''
+ self.assertEqual(clean_up_xml(bad_xml), good_xml)
+ self.assertEqual(clean_up_xml(good_xml), good_xml)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/sphinxcontrib-docbookrestapi-0.1/sphinxcontrib_docbookrestapi.egg-info/PKG-INFO
new/sphinxcontrib-docbookrestapi-0.2.1/sphinxcontrib_docbookrestapi.egg-info/PKG-INFO
---
old/sphinxcontrib-docbookrestapi-0.1/sphinxcontrib_docbookrestapi.egg-info/PKG-INFO
2013-12-03 17:34:28.000000000 +0100
+++
new/sphinxcontrib-docbookrestapi-0.2.1/sphinxcontrib_docbookrestapi.egg-info/PKG-INFO
2014-05-05 17:20:45.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: sphinxcontrib-docbookrestapi
-Version: 0.1
+Version: 0.2.1
Summary: Extension to Sphinx for generating REST API documentation for
http://api.openstack.org/
Home-page: UNKNOWN
Author: Cyril Roelandt
@@ -24,4 +24,6 @@
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
Classifier: Topic :: Software Development :: Documentation
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/sphinxcontrib-docbookrestapi-0.1/sphinxcontrib_docbookrestapi.egg-info/SOURCES.txt
new/sphinxcontrib-docbookrestapi-0.2.1/sphinxcontrib_docbookrestapi.egg-info/SOURCES.txt
---
old/sphinxcontrib-docbookrestapi-0.1/sphinxcontrib_docbookrestapi.egg-info/SOURCES.txt
2013-12-03 17:34:28.000000000 +0100
+++
new/sphinxcontrib-docbookrestapi-0.2.1/sphinxcontrib_docbookrestapi.egg-info/SOURCES.txt
2014-05-05 17:20:45.000000000 +0200
@@ -1,3 +1,4 @@
+.testr.conf
AUTHORS
ChangeLog
LICENSE
@@ -5,12 +6,13 @@
requirements.txt
setup.cfg
setup.py
+test-requirements.txt
tox.ini
sphinxcontrib/__init__.py
sphinxcontrib/docbookrestapi/__init__.py
sphinxcontrib/docbookrestapi/docbook.py
sphinxcontrib/docbookrestapi/setup.py
-sphinxcontrib/docbookrestapi/tests/__init__.py
+sphinxcontrib/docbookrestapi/tests/test_utils.py
sphinxcontrib_docbookrestapi.egg-info/PKG-INFO
sphinxcontrib_docbookrestapi.egg-info/SOURCES.txt
sphinxcontrib_docbookrestapi.egg-info/dependency_links.txt
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/sphinxcontrib-docbookrestapi-0.1/sphinxcontrib_docbookrestapi.egg-info/requires.txt
new/sphinxcontrib-docbookrestapi-0.2.1/sphinxcontrib_docbookrestapi.egg-info/requires.txt
---
old/sphinxcontrib-docbookrestapi-0.1/sphinxcontrib_docbookrestapi.egg-info/requires.txt
2013-12-03 17:34:28.000000000 +0100
+++
new/sphinxcontrib-docbookrestapi-0.2.1/sphinxcontrib_docbookrestapi.egg-info/requires.txt
2014-05-05 17:20:45.000000000 +0200
@@ -1 +1,3 @@
-pytidylib>=0.2.1
\ No newline at end of file
+docutils==0.9.1
+pytidylib6
+sphinx>=1.1.2,<1.2
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/sphinxcontrib-docbookrestapi-0.1/test-requirements.txt
new/sphinxcontrib-docbookrestapi-0.2.1/test-requirements.txt
--- old/sphinxcontrib-docbookrestapi-0.1/test-requirements.txt 1970-01-01
01:00:00.000000000 +0100
+++ new/sphinxcontrib-docbookrestapi-0.2.1/test-requirements.txt
2014-05-05 17:20:24.000000000 +0200
@@ -0,0 +1,2 @@
+discover
+testrepository>=0.0.17
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/sphinxcontrib-docbookrestapi-0.1/tox.ini
new/sphinxcontrib-docbookrestapi-0.2.1/tox.ini
--- old/sphinxcontrib-docbookrestapi-0.1/tox.ini 2013-12-03
17:32:08.000000000 +0100
+++ new/sphinxcontrib-docbookrestapi-0.2.1/tox.ini 2014-05-05
17:20:24.000000000 +0200
@@ -1,18 +1,18 @@
[tox]
minversion = 1.6
skipsdist = True
-envlist = pep8
+envlist = pep8,py26,py27,py33
-#[testenv]
+[testenv]
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
install_command = pip install -U {opts} {packages}
usedevelop = True
-setenv = VIRTUAL_ENV={envdir}
- LANG=en_US.UTF-8
- LANGUAGE=en_US:en
- LC_ALL=C
- EVENTLET_NO_GREENDNS=yes
+commands =
+ python setup.py testr --slowest --testr-args='{posargs}'
+
+[testenv:venv]
+commands = {posargs}
[testenv:pep8]
# Install bounded pep8/pyflakes first, then let flake8 install
@@ -25,7 +25,5 @@
[flake8]
-#ignore = H301,H306,H506
-builtins = _
-exclude=.venv,.git,.tox,dist,doc,./ceilometer/openstack/common,*lib/python*,*egg,tools,nova_tests,build
+exclude=.venv,.git,.tox,*egg,build
show-source = True