From e00144c3a0180c4bd90a771037575dc4e6528cb6 Mon Sep 17 00:00:00 2001 From: Chris Yeoh Date: Wed, 22 Oct 2014 16:16:24 +1030 Subject: [PATCH] Moves from markdown to rst Changes format of files from markdown to reStructuredText and adds the tox targets to verify the format and build the html. Also adds bits and pieces needed to finish bootstrapping the repository. Change-Id: If559c21f19d7044a0d89b29e5743bf09c9da2ac1 --- .gitignore | 10 + .gitreview | 4 + .testr.conf | 4 + LICENSE | 203 +------------ README.md | 25 -- README.rst | 14 + doc/source/conf.py | 278 ++++++++++++++++++ doc/source/guidelines | 1 + doc/source/index.rst | 31 ++ doc/source/redirect.py | 50 ++++ .../compatibility.rst | 4 +- .../discoverability.rst | 4 +- extensions.md => guidelines/extensions.rst | 4 +- http.md => guidelines/http.rst | 6 +- naming.md => guidelines/naming.rst | 6 +- .../pagination_filtering.rst | 4 +- guidelines/terms.rst | 27 ++ testing.md => guidelines/testing.rst | 0 requirements.txt | 6 + setup.cfg | 23 ++ setup.py | 22 ++ terms.md | 26 -- tests/__init__.py | 0 tests/test_titles.py | 99 +++++++ tox.ini | 19 ++ 25 files changed, 610 insertions(+), 260 deletions(-) create mode 100644 .gitignore create mode 100644 .gitreview create mode 100644 .testr.conf delete mode 100644 README.md create mode 100644 README.rst create mode 100644 doc/source/conf.py create mode 120000 doc/source/guidelines create mode 100644 doc/source/index.rst create mode 100644 doc/source/redirect.py rename compatibility.md => guidelines/compatibility.rst (80%) rename discoverability.md => guidelines/discoverability.rst (82%) rename extensions.md => guidelines/extensions.rst (84%) rename http.md => guidelines/http.rst (92%) rename naming.md => guidelines/naming.rst (93%) rename pagination_filtering.md => guidelines/pagination_filtering.rst (79%) create mode 100644 guidelines/terms.rst rename testing.md => guidelines/testing.rst (100%) create mode 100644 requirements.txt create mode 100644 setup.cfg create mode 100755 setup.py delete mode 100644 terms.md create mode 100644 tests/__init__.py create mode 100644 tests/test_titles.py create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b774adf --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +AUTHORS +ChangeLog +build +.tox +.venv +*.egg* +*.swp +*.swo +*.pyc +.testrepository \ No newline at end of file diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..652bf14 --- /dev/null +++ b/.gitreview @@ -0,0 +1,4 @@ +[gerrit] +host=review.openstack.org +port=29418 +project=openstack/api-wg.git diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 0000000..1641f86 --- /dev/null +++ b/.testr.conf @@ -0,0 +1,4 @@ +[DEFAULT] +test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 OS_TEST_TIMEOUT=60 ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/LICENSE b/LICENSE index e06d208..75a29c4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,202 +1,3 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - 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. +This work is licensed under a Creative Commons Attribution 3.0 Unported License. +http://creativecommons.org/licenses/by/3.0/legalcode diff --git a/README.md b/README.md deleted file mode 100644 index e318101..0000000 --- a/README.md +++ /dev/null @@ -1,25 +0,0 @@ -openstack-api -============= - -This repository contains documents from the OpenStack API working group, -including guidelines and proposed rules concerning API consistency, naming -conventions, and best practice recommendations. - -Interested in contributing to the API conversations? Simply clone this -repository and follow the [OpenStack code and review submission -processes](https://wiki.openstack.org/wiki/How_To_Contribute). - -Guidance --------- - -The following topics have separate doc pages that contain guidance on a -specific issue: - -* [Terms](terms.md) -* [HTTP Response Codes, Methods, and Standards](http.md) -* [Naming Conventions](naming.md) -* [API Discoverability](discoverability.md) -* [Compatibility](compatibility.md) -* [API Extensions](extensions.md) -* [Pagination and Filtering](pagination_filtering.md) -* [Testing](testing.md) diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..f42eebe --- /dev/null +++ b/README.rst @@ -0,0 +1,14 @@ +====== +README +====== + +Openstack API Working Group documents +------------------------------------- + +This repository contains documents from the OpenStack API working group, +including guidelines and proposed rules concerning API consistency, naming +conventions, and best practice recommendations. + +Interested in contributing to the API conversations? Simply clone this +repository and follow the [OpenStack code and review submission +processes](https://wiki.openstack.org/wiki/How_To_Contribute). diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100644 index 0000000..8f9e442 --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,278 @@ +# -*- coding: utf-8 -*- +# +# Tempest documentation build configuration file, created by +# sphinx-quickstart on Tue May 21 17:43:32 2013. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import datetime +import sys +import os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['redirect', + 'sphinx.ext.autodoc', + 'sphinx.ext.todo', + 'sphinx.ext.viewcode', + 'oslosphinx', + 'yasfb', + ] + +# Feed configuration for yasfb +feed_base_url = 'http://specs.openstack.org/openstack/nova-specs' +feed_author = 'OpenStack Nova Team' + +todo_include_todos = True + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'Nova Specs' +copyright = u'%s, OpenStack Nova Team' % datetime.date.today().year + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = [ + '_build', + 'specs/juno-template.rst', + 'specs/kilo-template.rst', +] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +add_module_names = False + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +modindex_common_prefix = ['nova-specs.'] + +# -- Options for man page output ---------------------------------------------- +man_pages = [] + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'nature' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +git_cmd = "git log --pretty=format:'%ad, commit %h' --date=local -n1" +html_last_updated_fmt = os.popen(git_cmd).read() + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +html_domain_indices = False + +# If false, no index is generated. +html_use_index = False + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'Nova-Specsdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('index', 'Nova-specs.tex', u'Nova Specs', + u'OpenStack Nova Team', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + +# -- Options for Texinfo output ------------------------------------------------ + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'Nova-specs', u'Nova Design Specs', + u'OpenStack Nova Team', 'nova-specs', 'Design specifications for the Nova project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + + +# -- Options for Epub output --------------------------------------------------- + +# Bibliographic Dublin Core info. +epub_title = u'Nova Specs' +epub_author = u'OpenStack Nova Team' +epub_publisher = u'OpenStack Nova Team' +epub_copyright = u'2014, OpenStack Nova Team' + +# The language of the text. It defaults to the language option +# or en if the language is not set. +#epub_language = '' + +# The scheme of the identifier. Typical schemes are ISBN or URL. +#epub_scheme = '' + +# The unique identifier of the text. This can be a ISBN number +# or the project homepage. +#epub_identifier = '' + +# A unique identification for the text. +#epub_uid = '' + +# A tuple containing the cover image and cover page html template filenames. +#epub_cover = () + +# HTML files that should be inserted before the pages created by sphinx. +# The format is a list of tuples containing the path and title. +#epub_pre_files = [] + +# HTML files shat should be inserted after the pages created by sphinx. +# The format is a list of tuples containing the path and title. +#epub_post_files = [] + +# A list of files that should not be packed into the epub file. +#epub_exclude_files = [] + +# The depth of the table of contents in toc.ncx. +#epub_tocdepth = 3 + +# Allow duplicate toc entries. +#epub_tocdup = True diff --git a/doc/source/guidelines b/doc/source/guidelines new file mode 120000 index 0000000..551737b --- /dev/null +++ b/doc/source/guidelines @@ -0,0 +1 @@ +../../guidelines \ No newline at end of file diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 0000000..0ba965e --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,31 @@ +.. api-wg documentation master file + +=========================== +Openstack API Working Group +=========================== + +This document contains the guidelines and rules for OpenStack project +APIs. + +including guidelines and proposed rules concerning API consistency, naming +conventions, and best practice recommendations. + +If you are interested in contributing to this document, the git repository is +available at http://git.openstack.org/cgit/openstack/api-wg/ + +OpenStack code and review submission processes are described here: + +https://wiki.openstack.org/wiki/How_To_Contribute + + +Guidelines +---------- + +The following topics have separate doc pages that contain guidance on a +specific issue: + +.. toctree:: + :glob: + :maxdepth: 1 + + guidelines/* diff --git a/doc/source/redirect.py b/doc/source/redirect.py new file mode 100644 index 0000000..099159f --- /dev/null +++ b/doc/source/redirect.py @@ -0,0 +1,50 @@ +# A simple sphinx plugin which creates HTML redirections from old names +# to new names. It does this by looking for files named "redirect" in +# the documentation source and using the contents to create simple HTML +# redirection pages for changed filenames. + +import os.path + +from sphinx.application import ENV_PICKLE_FILENAME +from sphinx.util.console import bold + + +def setup(app): + from sphinx.application import Sphinx + if not isinstance(app, Sphinx): + return + app.connect('build-finished', emit_redirects) + + +def process_redirect_file(app, path, ent): + parent_path = path.replace(app.builder.srcdir, app.builder.outdir) + with open(os.path.join(path, ent)) as redirects: + for line in redirects.readlines(): + from_path, to_path = line.rstrip().split(' ') + from_path = from_path.replace('.rst', '.html') + to_path = to_path.replace('.rst', '.html') + + redirected_filename = os.path.join(parent_path, from_path) + redirected_directory = os.path.dirname(redirected_filename) + if not os.path.exists(redirected_directory): + os.makedirs(redirected_directory) + with open(redirected_filename, 'w') as f: + f.write('' + % to_path) + + +def emit_redirects(app, exc): + app.builder.info(bold('scanning %s for redirects...') % app.builder.srcdir) + + def process_directory(path): + for ent in os.listdir(path): + p = os.path.join(path, ent) + if os.path.isdir(p): + process_directory(p) + elif ent == 'redirects': + app.builder.info(' found redirects at %s' % p) + process_redirect_file(app, path, ent) + + process_directory(app.builder.srcdir) + app.builder.info('...done') diff --git a/compatibility.md b/guidelines/compatibility.rst similarity index 80% rename from compatibility.md rename to guidelines/compatibility.rst index 3907d48..c80e2fd 100644 --- a/compatibility.md +++ b/guidelines/compatibility.rst @@ -1,10 +1,12 @@ +.. _compatibility: + Compatibility ============= This topic document serves to provide guidance on how to handle proposed changes to a public REST API. -See also the topic document on [API discoverability](discoverability.md). +See also the topic document on :ref:`discoverability`. Guidance -------- diff --git a/discoverability.md b/guidelines/discoverability.rst similarity index 82% rename from discoverability.md rename to guidelines/discoverability.rst index 77cbaa5..723e688 100644 --- a/discoverability.md +++ b/guidelines/discoverability.rst @@ -1,10 +1,12 @@ +.. _discoverability: + API Discoverability =================== This topic document serves to provide guidance on how to have a public REST API expose the URIs and resources to end users in a machine-readable way. -See also the topic document on [compatibility](compatibility.md). +See also the topic document on :ref:`compatibility`. Guidance -------- diff --git a/extensions.md b/guidelines/extensions.rst similarity index 84% rename from extensions.md rename to guidelines/extensions.rst index 91258a7..4574dc3 100644 --- a/extensions.md +++ b/guidelines/extensions.rst @@ -1,9 +1,11 @@ +.. _extensions: + API Extensions ============== This topic document serves to provide guidance on the topic of API extensions. -See also the topic document on [discoverability](discoverability.md). +See also the topic document on :ref:`discoverability`. Guidance -------- diff --git a/http.md b/guidelines/http.rst similarity index 92% rename from http.md rename to guidelines/http.rst index 535aa23..dd9807f 100644 --- a/http.md +++ b/guidelines/http.rst @@ -1,3 +1,5 @@ +.. _http: + HTTP Guidelines =============== @@ -29,11 +31,11 @@ Failure Codes ~~~~~~~~~~~~~ * If the call results in the OpenStack user exceeding his or her quota, the - return code should be **403 Forbidden**. Do ***not*** use **413 Request + return code should be **403 Forbidden**. Do **not** use **413 Request Entity Too Large**. * For badly formatted requests, the return code should be **400 Bad Request**. - Do ***not*** use **422 Unprocessable Entity**. + Do **not** use **422 Unprocessable Entity**. HTTP Methods ------------ diff --git a/naming.md b/guidelines/naming.rst similarity index 93% rename from naming.md rename to guidelines/naming.rst index 86c8501..83c0b57 100644 --- a/naming.md +++ b/guidelines/naming.rst @@ -7,13 +7,15 @@ OpenStack public REST APIs so that our APIs feel consistent and professional. REST API resource names ----------------------- -* A resource in a REST API is always represented as the plural of an entity that is exposed by the API. +* A resource in a REST API is always represented as the plural of an entity + that is exposed by the API. * Resource names exposed in a REST API should use all lowercase characters. * Resource names *may* include hyphens. -* Resource names should *not* include underscores or other punctuation (sole exception is the hyphen). +* Resource names should *not* include underscores or other punctuation + (sole exception is the hyphen). Fields in an API request or response body ----------------------------------------- diff --git a/pagination_filtering.md b/guidelines/pagination_filtering.rst similarity index 79% rename from pagination_filtering.md rename to guidelines/pagination_filtering.rst index eed0ca7..b85b302 100644 --- a/pagination_filtering.md +++ b/guidelines/pagination_filtering.rst @@ -1,7 +1,9 @@ Pagination and Filtering ======================== -This topic document serves to provide guidance on how to handle the pagination of large result sets and the best ways to provide filtering capabilities in a project's public REST API. +This topic document serves to provide guidance on how to handle the +pagination of large result sets and the best ways to provide filtering +capabilities in a project's public REST API. Pagination ---------- diff --git a/guidelines/terms.rst b/guidelines/terms.rst new file mode 100644 index 0000000..82d4d17 --- /dev/null +++ b/guidelines/terms.rst @@ -0,0 +1,27 @@ +Terms +===== + +As Phil Karlson [once said](http://martinfowler.com/bliki/TwoHardThings.html): + +> There are only two hard things in Computer Science: cache invalidation and +> naming things. + +Over time, various terms and synonyms for those terms generate some +controversy, and different teams end up using different words to reference the +same object or resource. This document serves to record decisions that were +made regarding certain terms, and attempts to succinctly define each term. + +* **project** vs. **tenant** + + **project** shall be used to describe the concept of a group of OpenStack + users that share a common set of quotas. The older term **tenant** should + *not* be used in OpenStack REST APIs. + +* **server** vs. **instance** + + **server** shall be used to describe a virtual machine, a + bare-metal machine, or a containerized virtual machine that is used + by OpenStack users for compute purposes. The older term + **instance** that is also by Amazon Web Services EC2 API to + describe a virtual machine, should *not* be used in OpenStack REST + APIs. diff --git a/testing.md b/guidelines/testing.rst similarity index 100% rename from testing.md rename to guidelines/testing.rst diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7df18d2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +oslosphinx +pbr>=0.6,<1.0 +sphinx>=1.1.2,<1.2 +testrepository>=0.0.18 +testtools>=0.9.34 +yasfb>=0.5.1 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..4ada295 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,23 @@ +[metadata] +name = api-wg +summary = OpenStack API Workgroup Guidelines +description-file = + README.rst +author = OpenStack +author-email = openstack-dev@lists.openstack.org +home-page = http://www.openstack.org/ +classifier = + Intended Audience :: Developers + License :: OSI Approved :: Apache Software License + Operating System :: POSIX :: Linux + +[build_sphinx] +all_files = 1 +build-dir = doc/build +source-dir = doc/source + +[pbr] +warnerrors = True + +[wheel] +universal = 1 diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..70c2b3f --- /dev/null +++ b/setup.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. +# +# 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. + +# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT +import setuptools + +setuptools.setup( + setup_requires=['pbr'], + pbr=True) diff --git a/terms.md b/terms.md deleted file mode 100644 index dad121b..0000000 --- a/terms.md +++ /dev/null @@ -1,26 +0,0 @@ -Terms -===== - -As Phil Karlson [once said](http://martinfowler.com/bliki/TwoHardThings.html): - -> There are only two hard things in Computer Science: cache invalidation and -> naming things. - -Over time, various terms and synonyms for those terms generate some -controversy, and different teams end up using different words to reference the -same object or resource. This document serves to record decisions that were -made regarding certain terms, and attempts to succinctly define each term. - -* ***project*** vs. ***tenant*** - - ***project*** shall be used to describe the concept of a group of OpenStack - users that share a common set of quotas. The older term ***tenant*** should - *not* be used in OpenStack REST APIs. - -* ***server*** vs. ***instance*** - - ***server*** shall be used to describe a virtual machine, a bare-metal machine, - or a containerized virtual machine that is used by OpenStack users for - compute purposes. The older term ***instance*** that is also by Amazon Web - Services EC2 API to describe a virtual machine, should *not* be used in - OpenStack REST APIs. diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_titles.py b/tests/test_titles.py new file mode 100644 index 0000000..f6d346f --- /dev/null +++ b/tests/test_titles.py @@ -0,0 +1,99 @@ +# 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 re + +import docutils.core +import testtools + + +class TestTitles(testtools.TestCase): + def _get_title(self, section_tree): + section = { + 'subtitles': [], + } + for node in section_tree: + if node.tagname == 'title': + section['name'] = node.rawsource + elif node.tagname == 'section': + subsection = self._get_title(node) + section['subtitles'].append(subsection['name']) + return section + + def _get_titles(self, spec): + titles = {} + for node in spec: + if node.tagname == 'section': + # Note subsection subtitles are thrown away + section = self._get_title(node) + titles[section['name']] = section['subtitles'] + return titles + + def _check_titles(self, filename, expect, actual): + missing_sections = [x for x in expect.keys() if x not in actual.keys()] + extra_sections = [x for x in actual.keys() if x not in expect.keys()] + + msgs = [] + if len(missing_sections) > 0: + msgs.append("Missing sections: %s" % missing_sections) + if len(extra_sections) > 0: + msgs.append("Extra sections: %s" % extra_sections) + + for section in expect.keys(): + missing_subsections = [x for x in expect[section] + if x not in actual[section]] + # extra subsections are allowed + if len(missing_subsections) > 0: + msgs.append("Section '%s' is missing subsections: %s" + % (section, missing_subsections)) + + if len(msgs) > 0: + self.fail("While checking '%s':\n %s" + % (filename, "\n ".join(msgs))) + + def _check_lines_wrapping(self, tpl, raw): + for i, line in enumerate(raw.split("\n")): + if "http://" in line or "https://" in line: + continue + self.assertTrue( + len(line) < 80, + msg="%s:%d: Line limited to a maximum of 79 characters." % + (tpl, i+1)) + + def _check_no_cr(self, tpl, raw): + matches = re.findall('\r', raw) + self.assertEqual( + len(matches), 0, + "Found %s literal carriage returns in file %s" % + (len(matches), tpl)) + + + def _check_trailing_spaces(self, tpl, raw): + for i, line in enumerate(raw.split("\n")): + trailing_spaces = re.findall(" +$", line) + self.assertEqual(len(trailing_spaces),0, + "Found trailing spaces on line %s of %s" % (i+1, tpl)) + + + def test_template(self): + files = glob.glob("guidelines/*") + for filename in files: + self.assertTrue(filename.endswith(".rst"), + "guideline files must use 'rst' extension.") + with open(filename) as f: + data = f.read() + + spec = docutils.core.publish_doctree(data) + self._check_lines_wrapping(filename, data) + self._check_no_cr(filename, data) + self._check_trailing_spaces(filename, data) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..0286b0c --- /dev/null +++ b/tox.ini @@ -0,0 +1,19 @@ +[tox] +# Hold back to 1.4, since that's what's in Fedora 20 repos +# and we don't need anything newer for nova-specs tests +minversion = 1.4 +envlist = docs,py27 +skipsdist = True + +[testenv] +usedevelop = True +setenv = VIRTUAL_ENV={envdir} +install_command = pip install -U {opts} {packages} +deps = -r{toxinidir}/requirements.txt +commands = python setup.py testr --slowest --testr-args='{posargs}' + +[testenv:venv] +commands = {posargs} + +[testenv:docs] +commands = python setup.py build_sphinx