From 72d30dae0a27b52a910059534e158b9f85407266 Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Fri, 1 Aug 2014 15:12:33 +0200 Subject: [PATCH] Make build environment workable * Add files needed to build documentation. They are copied from the cookiecutter repository. * Replace setup.py and add setup.cfg * Add tox.ini * Add requirements.txt and test-requirements.txt * Fix hacking issue H307 (like imports should be grouped together) Change-Id: I325bb07233853611e8f0952a554a30dba2b7dfe7 Co-Authored-By: Joshua Harlow --- doc/source/conf.py | 72 +++++++++++++++++++++++++++++++ doc/source/contributing.rst | 4 ++ doc/source/index.rst | 20 +++++++++ doc/source/installation.rst | 12 ++++++ doc/source/readme.rst | 1 + doc/source/usage.rst | 7 +++ doc8/parser.py | 5 +-- requirements.txt | 5 +++ setup.cfg | 35 +++++++++++++++ setup.py | 86 ++++++++++--------------------------- test-requirements.txt | 4 ++ tox.ini | 30 +++++++++++++ 12 files changed, 215 insertions(+), 66 deletions(-) create mode 100755 doc/source/conf.py create mode 100644 doc/source/contributing.rst create mode 100644 doc/source/index.rst create mode 100644 doc/source/installation.rst create mode 100644 doc/source/readme.rst create mode 100644 doc/source/usage.rst create mode 100644 requirements.txt create mode 100644 test-requirements.txt create mode 100644 tox.ini diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100755 index 0000000..c02b645 --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,72 @@ +# 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 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', + #'sphinx.ext.intersphinx', + 'oslosphinx' +] + +# autodoc generation is a bit aggressive and a nuisance when doing heavy +# text edit cycles. +# execute "export SPHINX_DEBUG=1" in your terminal to disable + +# The suffix of source filenames. +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'doc8' +copyright = u'2013, OpenStack Foundation' + +# 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 = True + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# -- Options for HTML output -------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +# html_theme_path = ["."] +# html_theme = '_theme' +# html_static_path = ['static'] + +# Output file base name for HTML help builder. +htmlhelp_basename = '%sdoc' % project + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass +# [howto/manual]). +latex_documents = [ + ('index', + '%s.tex' % project, + u'%s Documentation' % project, + u'OpenStack Foundation', 'manual'), +] # Example configuration for intersphinx: refer to the Python standard library. +#intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/doc/source/contributing.rst b/doc/source/contributing.rst new file mode 100644 index 0000000..1728a61 --- /dev/null +++ b/doc/source/contributing.rst @@ -0,0 +1,4 @@ +============ +Contributing +============ +.. include:: ../../CONTRIBUTING.rst diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 0000000..4628227 --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,20 @@ +Welcome to doc8's documentation! +================================ + +Contents: + +.. toctree:: + :maxdepth: 2 + + readme + installation + usage + contributing + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/doc/source/installation.rst b/doc/source/installation.rst new file mode 100644 index 0000000..34667d0 --- /dev/null +++ b/doc/source/installation.rst @@ -0,0 +1,12 @@ +============ +Installation +============ + +At the command line:: + + $ pip install doc8 + +Or, if you have virtualenvwrapper installed:: + + $ mkvirtualenv doc8 + $ pip install doc8 diff --git a/doc/source/readme.rst b/doc/source/readme.rst new file mode 100644 index 0000000..a6210d3 --- /dev/null +++ b/doc/source/readme.rst @@ -0,0 +1 @@ +.. include:: ../../README.rst diff --git a/doc/source/usage.rst b/doc/source/usage.rst new file mode 100644 index 0000000..cfd5e53 --- /dev/null +++ b/doc/source/usage.rst @@ -0,0 +1,7 @@ +===== +Usage +===== + +To use doc8 in a project:: + + import doc8 diff --git a/doc8/parser.py b/doc8/parser.py index 825d309..045b566 100644 --- a/doc8/parser.py +++ b/doc8/parser.py @@ -19,14 +19,13 @@ import errno import os -import restructuredtext_lint as rl -import six - from docutils import core from docutils import frontend from docutils import nodes as docutils_nodes from docutils import parsers as docutils_parser from docutils import utils +import restructuredtext_lint as rl +import six class ParsedFile(object): diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1d7be4d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +argparse +docutils +restructuredtext-lint>=0.7 +six +stevedore diff --git a/setup.cfg b/setup.cfg index 5e40900..060926d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,37 @@ +[metadata] +name = doc8 +version = 0.3.4 +summary = Style checker for Sphinx (or other) RST documentation +description-file = + README.rst +author = OpenStack +author-email = openstack-dev@lists.openstack.org +home-page = http://git.openstack.org/cgit/stackforge/doc8 +classifier = + Intended Audience :: Information Technology + Intended Audience :: System Administrators + Intended Audience :: Developers + Development Status :: 4 - Beta + Topic :: Utilities + License :: OSI Approved :: Apache Software License + Operating System :: POSIX :: Linux + Programming Language :: Python + Programming Language :: Python :: 2 + Programming Language :: Python :: 2.6 + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.2 + Programming Language :: Python :: 3.3 + Programming Language :: Python :: 3.4 + +[entry_points] +console_scripts = + doc8 = doc8.main:main + +[build_sphinx] +all_files = 1 +build-dir = doc/build +source-dir = doc/source + [wheel] universal = 1 diff --git a/setup.py b/setup.py index 0a982ea..7363757 100755 --- a/setup.py +++ b/setup.py @@ -1,70 +1,30 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- - -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright (C) 2014 Yahoo! Inc. All Rights Reserved. +# 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 +# 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 +# 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. +# 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 os +# THIS FILE IS MANAGED BY THE GLOBAL REQUIREMENTS REPO - DO NOT EDIT +import setuptools -from setuptools import find_packages -from setuptools import setup +# In python < 2.7.4, a lazy loading of package `pbr` will break +# setuptools if some other modules registered functions in `atexit`. +# solution from: http://bugs.python.org/issue15881#msg170215 +try: + import multiprocessing # noqa +except ImportError: + pass - -def _path(fn): - return os.path.join(os.path.dirname(__file__), fn) - - -def _readme(): - with open(_path("README.rst"), "r") as handle: - return handle.read() - - -setup( - name='doc8', - version='0.3.4', - description='style checker for sphinx (or other) rst documentation.', - url='http://git.openstack.org/cgit/stackforge/doc8', - license="ASL 2.0", - install_requires=[ - 'argparse', - 'docutils', - 'restructuredtext-lint>=0.7', - 'six', - 'stevedore', - ], - entry_points={ - 'console_scripts': [ - 'doc8 = doc8.main:main', - ], - }, - packages=find_packages(), - classifiers=[ - "Development Status :: 4 - Beta", - "Topic :: Utilities", - "License :: OSI Approved :: Apache Software License", - "Operating System :: POSIX :: Linux", - "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.6", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.2", - "Programming Language :: Python :: 3.3", - "Programming Language :: Python :: 3.4", - ], - keywords="rst docs style checking", - long_description=_readme(), -) +setuptools.setup( + setup_requires=['pbr'], + pbr=True) diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..64251c7 --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,4 @@ +hacking>=0.9.2,<0.10 +nose +oslosphinx +sphinx>=1.1.2,!=1.2.0,<1.3 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..c86627a --- /dev/null +++ b/tox.ini @@ -0,0 +1,30 @@ +[tox] +minversion = 1.6 +skipsdist = True +envlist = py26,py27,pep8 + +[testenv] +setenv = VIRTUAL_ENV={envdir} +usedevelop = True +install_command = pip install {opts} {packages} +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt +commands = nosetests {posargs} + +[testenv:pep8] +commands = flake8 {posargs} + +[tox:jenkins] +downloadcache = ~/cache/pip + +[testenv:venv] +commands = {posargs} + +[testenv:docs] +commands = python setup.py build_sphinx + +[flake8] +ignore = H302,F401 +builtins = _ +show-source = True +exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build