Add py files in doc directories to pep8 check
Change-Id: Idb4f8864ab51f5e4ee2eef7745d40d5d8b5e57ce
This commit is contained in:
parent
c63ba779ae
commit
16809b37a7
@ -21,8 +21,7 @@ from docutils.parsers import rst
|
||||
from rally.cli import cliutils
|
||||
from rally.cli import main
|
||||
from rally.cli import manage
|
||||
from utils import (category, subcategory, hint, make_definition, note,
|
||||
paragraph, parse_text, warning)
|
||||
import utils
|
||||
|
||||
|
||||
class Parser(object):
|
||||
@ -73,7 +72,8 @@ DEFAULT_UUIDS_CMD = {
|
||||
|
||||
def compose_note_about_default_uuids(argument, dest):
|
||||
# TODO(andreykurilin): add references to commands
|
||||
return note("The default value for the ``%(arg)s`` argument is taken from "
|
||||
return utils.note(
|
||||
"The default value for the ``%(arg)s`` argument is taken from "
|
||||
"the Rally environment. Usually, the default value is equal to"
|
||||
" the UUID of the last successful run of ``%(cmd)s``, if the "
|
||||
"``--no-use`` argument was not used." % {
|
||||
@ -82,13 +82,14 @@ def compose_note_about_default_uuids(argument, dest):
|
||||
|
||||
|
||||
def compose_use_cmd_hint_msg(cmd):
|
||||
return hint("You can set the default value by executing ``%(cmd)s <uuid>``"
|
||||
return utils.hint(
|
||||
"You can set the default value by executing ``%(cmd)s <uuid>``"
|
||||
" (ref__).\n\n __ #%(ref)s" % {"cmd": cmd,
|
||||
"ref": cmd.replace(" ", "-")})
|
||||
|
||||
|
||||
def make_arguments_section(category_name, cmd_name, arguments, defaults):
|
||||
elements = [paragraph("**Command arguments**:")]
|
||||
elements = [utils.paragraph("**Command arguments**:")]
|
||||
for args, kwargs in arguments:
|
||||
# for future changes...
|
||||
# :param args: a single command argument which can represented by
|
||||
@ -138,7 +139,8 @@ def make_arguments_section(category_name, cmd_name, arguments, defaults):
|
||||
if metavar:
|
||||
args = ["%s %s" % (arg, metavar) for arg in args]
|
||||
|
||||
elements.extend(make_definition(", ".join(args), ref, description))
|
||||
elements.extend(utils.make_definition(", ".join(args),
|
||||
ref, description))
|
||||
return elements
|
||||
|
||||
|
||||
@ -154,8 +156,8 @@ def make_command_section(category_name, name, parser):
|
||||
# NOTE(andreykurilin): there is only one category in rally-manage, so
|
||||
# let's just hardcode it.
|
||||
cmd = "rally-manage" if category_name == "db" else "rally"
|
||||
section = subcategory("%s %s %s" % (cmd, category_name, name))
|
||||
section.extend(parse_text(parser["description"]))
|
||||
section = utils.subcategory("%s %s %s" % (cmd, category_name, name))
|
||||
section.extend(utils.parse_text(parser["description"]))
|
||||
if parser["parser"].arguments:
|
||||
defaults = get_defaults(parser["parser"].defaults["action_fn"])
|
||||
section.extend(make_arguments_section(
|
||||
@ -164,7 +166,7 @@ def make_command_section(category_name, name, parser):
|
||||
|
||||
|
||||
def make_category_section(name, parser):
|
||||
category_obj = category("Category: %s" % name)
|
||||
category_obj = utils.category("Category: %s" % name)
|
||||
# NOTE(andreykurilin): we are re-using `_add_command_parsers` method from
|
||||
# `rally.cli.cliutils`, but, since it was designed to print help message,
|
||||
# generated description for categories contains specification for all
|
||||
@ -177,9 +179,9 @@ def make_category_section(name, parser):
|
||||
if description.startswith("[Deprecated"):
|
||||
i = description.find("]")
|
||||
msg = description[1:i]
|
||||
description = description[i+1:].strip()
|
||||
category_obj.append(warning(msg))
|
||||
category_obj.extend(parse_text(description))
|
||||
description = description[i + 1:].strip()
|
||||
category_obj.append(utils.warning(msg))
|
||||
category_obj.extend(utils.parse_text(description))
|
||||
|
||||
for command in sorted(parser.subparser.parsers.keys()):
|
||||
subparser = parser.subparser.parsers[command]
|
||||
@ -196,14 +198,14 @@ class CLIReferenceDirective(rst.Directive):
|
||||
categories = copy.copy(main.categories)
|
||||
categories["db"] = manage.DBCommands
|
||||
if "group" in self.options:
|
||||
categories = {k: v for k,v in categories.items()
|
||||
categories = {k: v for k, v in categories.items()
|
||||
if k == self.options["group"]}
|
||||
cliutils._add_command_parsers(categories, parser)
|
||||
|
||||
content = []
|
||||
for category in sorted(categories.keys()):
|
||||
for cg in sorted(categories.keys()):
|
||||
content.append(make_category_section(
|
||||
category, parser.parsers[category]["parser"]))
|
||||
cg, parser.parsers[cg]["parser"]))
|
||||
return content
|
||||
|
||||
|
||||
|
@ -21,27 +21,26 @@ from oslo_utils import importutils
|
||||
|
||||
def include_var(name, rawtext, text, lineno, inliner, options=None,
|
||||
content=None):
|
||||
"""
|
||||
|
||||
"""include variable
|
||||
|
||||
:param name: The local name of the interpreted role, the role name
|
||||
actually used in the document.
|
||||
:param rawtext: A string containing the enitre interpreted text input,
|
||||
including the role and markup. Return it as a problematic node
|
||||
linked to a system message if a problem is encountered.
|
||||
including the role and markup. Return it as a problematic
|
||||
node linked to a system message if a problem is
|
||||
encountered.
|
||||
:param text: The interpreted text content.
|
||||
:param lineno: The line number where the interpreted text begins.
|
||||
:param inliner: The docutils.parsers.rst.states.Inliner object that
|
||||
called include_var. It contains the several attributes useful for
|
||||
error reporting and document tree access.
|
||||
called include_var. It contains the several attributes
|
||||
useful for error reporting and document tree access.
|
||||
:param options: A dictionary of directive options for customization
|
||||
(from the "role" directive), to be interpreted by the role function.
|
||||
Used for additional attributes for the generated elements and other
|
||||
functionality.
|
||||
(from the 'role' directive), to be interpreted by the
|
||||
role function. Used for additional attributes for the
|
||||
generated elements and other functionality.
|
||||
:param content: A list of strings, the directive content for
|
||||
customization (from the "role" directive). To be interpreted by the
|
||||
role function.
|
||||
|
||||
customization (from the 'role' directive). To be
|
||||
interpreted by the role function.
|
||||
:return:
|
||||
"""
|
||||
obj = importutils.import_class(text)
|
||||
|
@ -21,8 +21,7 @@ import re
|
||||
from rally.common.plugin import discover
|
||||
from rally.common.plugin import plugin
|
||||
from rally import plugins
|
||||
from utils import category, subcategory, section, paragraph, parse_text, \
|
||||
make_definitions, note
|
||||
import utils
|
||||
|
||||
|
||||
JSON_SCHEMA_TYPES_MAP = {"boolean": "bool",
|
||||
@ -210,7 +209,7 @@ class PluginsReferenceDirective(rst.Directive):
|
||||
if "type" in item:
|
||||
iname += " (%s)" % item["type"]
|
||||
terms.append((iname, [item["doc"]]))
|
||||
return make_definitions(title=title,
|
||||
return utils.make_definitions(title=title,
|
||||
ref_prefix=ref_prefix,
|
||||
terms=terms,
|
||||
descriptions=description)
|
||||
@ -219,17 +218,17 @@ class PluginsReferenceDirective(rst.Directive):
|
||||
section_name = plugin_cls.get_name()
|
||||
if base_name:
|
||||
section_name += " [%s]" % base_name
|
||||
section_obj = section(section_name)
|
||||
section_obj = utils.section(section_name)
|
||||
|
||||
info = plugin_cls.get_info()
|
||||
if info["title"]:
|
||||
section_obj.append(paragraph(info["title"]))
|
||||
section_obj.append(utils.paragraph(info["title"]))
|
||||
|
||||
if info["description"]:
|
||||
section_obj.extend(parse_text(info["description"]))
|
||||
section_obj.extend(utils.parse_text(info["description"]))
|
||||
|
||||
if info["namespace"]:
|
||||
section_obj.append(paragraph(
|
||||
section_obj.append(utils.paragraph(
|
||||
"**Namespace**: %s" % info["namespace"]))
|
||||
|
||||
if base_name:
|
||||
@ -242,7 +241,7 @@ class PluginsReferenceDirective(rst.Directive):
|
||||
ref_prefix))
|
||||
|
||||
if info["returns"]:
|
||||
section_obj.extend(parse_text(
|
||||
section_obj.extend(utils.parse_text(
|
||||
"**Returns**:\n%s" % info["returns"]))
|
||||
|
||||
if info["schema"]:
|
||||
@ -259,7 +258,8 @@ class PluginsReferenceDirective(rst.Directive):
|
||||
description=["*Dictionary is expected. Keys should "
|
||||
"follow pattern(s) described bellow.*"]))
|
||||
elif "oneOf" in schema:
|
||||
section_obj.append(note("One of the following groups of "
|
||||
section_obj.append(utils.note(
|
||||
"One of the following groups of "
|
||||
"parameters should be provided."))
|
||||
for i, oneOf in enumerate(schema["oneOf"], 1):
|
||||
description = None
|
||||
@ -279,7 +279,7 @@ class PluginsReferenceDirective(rst.Directive):
|
||||
|
||||
filename = info["module"].replace(".", "/")
|
||||
ref = "https://github.com/openstack/rally/blob/master/%s.py" % filename
|
||||
section_obj.extend(parse_text("**Module**:\n`%s`__\n\n__ %s"
|
||||
section_obj.extend(utils.parse_text("**Module**:\n`%s`__\n\n__ %s"
|
||||
% (info["module"], ref)))
|
||||
return section_obj
|
||||
|
||||
@ -287,7 +287,7 @@ class PluginsReferenceDirective(rst.Directive):
|
||||
if base_name:
|
||||
title = ("%ss" % base_name if base_name[-1] != "y"
|
||||
else "%sies" % base_name[:-1])
|
||||
subcategory_obj = subcategory(title)
|
||||
subcategory_obj = utils.subcategory(title)
|
||||
else:
|
||||
subcategory_obj = []
|
||||
for p in sorted(base_cls.get_all(), key=lambda o: o.get_name()):
|
||||
@ -301,7 +301,7 @@ class PluginsReferenceDirective(rst.Directive):
|
||||
@staticmethod
|
||||
def _parse_class_name(cls):
|
||||
name = ""
|
||||
for word in re.split(r'([A-Z][a-z]*)', cls.__name__):
|
||||
for word in re.split(r"([A-Z][a-z]*)", cls.__name__):
|
||||
if word:
|
||||
if len(word) > 1 and name:
|
||||
name += " "
|
||||
@ -345,7 +345,7 @@ class PluginsReferenceDirective(rst.Directive):
|
||||
if base_name in IGNORED_BASES:
|
||||
continue
|
||||
if category_name not in categories:
|
||||
categories[category_name] = category(category_name)
|
||||
categories[category_name] = utils.category(category_name)
|
||||
category_of_base = categories[category_name]
|
||||
category_of_base.append(self._make_plugin_base_section(base_cls,
|
||||
base_name))
|
||||
|
@ -18,8 +18,8 @@ Docutils is awful library. Let's apply some hacks and aliases to simplify usage
|
||||
|
||||
from docutils import frontend
|
||||
from docutils import nodes
|
||||
from docutils import utils
|
||||
from docutils.parsers import rst
|
||||
from docutils import utils
|
||||
import string
|
||||
|
||||
import six
|
||||
@ -27,7 +27,8 @@ import six
|
||||
|
||||
def parse_text(text):
|
||||
parser = rst.Parser()
|
||||
settings = frontend.OptionParser(components=(rst.Parser,)).get_default_values()
|
||||
settings = frontend.OptionParser(
|
||||
components=(rst.Parser,)).get_default_values()
|
||||
document = utils.new_document(text, settings)
|
||||
parser.parse(text, document)
|
||||
return document.children
|
||||
|
@ -21,7 +21,7 @@
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import datetime
|
||||
import datetime as dt
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
@ -31,20 +31,20 @@ import rally.common.version
|
||||
# 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.extend([
|
||||
# sys.path.extend([
|
||||
# os.path.abspath("../.."),
|
||||
# os.path.abspath("../"),
|
||||
# os.path.abspath("./")
|
||||
#])
|
||||
# ])
|
||||
|
||||
sys.path.insert(0, os.path.abspath('../../'))
|
||||
sys.path.insert(0, os.path.abspath('../'))
|
||||
sys.path.insert(0, os.path.abspath('./'))
|
||||
sys.path.insert(0, os.path.abspath("../../"))
|
||||
sys.path.insert(0, os.path.abspath("../"))
|
||||
sys.path.insert(0, os.path.abspath("./"))
|
||||
|
||||
|
||||
# -- General configuration ----------------------------------------------------
|
||||
|
||||
on_rtd = os.environ.get('READTHEDOCS') == 'True'
|
||||
on_rtd = os.environ.get("READTHEDOCS") == "True"
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
# needs_sphinx = "1.0"
|
||||
@ -79,7 +79,7 @@ master_doc = "index"
|
||||
|
||||
# General information about the project.
|
||||
project = u"Rally"
|
||||
copyright = u"%d, OpenStack Foundation" % datetime.datetime.now().year
|
||||
copyright = u"%d, OpenStack Foundation" % dt.datetime.now().year
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
@ -147,7 +147,7 @@ else:
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
if not on_rtd:
|
||||
import oslosphinx
|
||||
theme_dir = os.path.join(os.path.dirname(oslosphinx.__file__), 'theme')
|
||||
theme_dir = os.path.join(os.path.dirname(oslosphinx.__file__), "theme")
|
||||
html_theme_path = [theme_dir, "_templates"]
|
||||
else:
|
||||
html_theme_path = []
|
||||
@ -188,7 +188,7 @@ html_last_updated_fmt = subprocess.Popen(
|
||||
html_use_smartypants = False
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
html_sidebars = {'**': ['searchbox.html', 'globaltoc.html']}
|
||||
html_sidebars = {"**": ["searchbox.html", "globaltoc.html"]}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
@ -227,14 +227,12 @@ htmlhelp_basename = "%sdoc" % project
|
||||
# -- 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": "",
|
||||
# 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
|
||||
@ -287,7 +285,8 @@ latex_documents = [
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
("index", "Rally", u"Rally Documentation",
|
||||
u"Rally Team", "Rally", "Testing framework and tool for all kinds of tests",
|
||||
u"Rally Team", "Rally",
|
||||
"Testing framework and tool for all kinds of tests",
|
||||
"Development"),
|
||||
]
|
||||
|
||||
|
@ -13,13 +13,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rally import plugins
|
||||
from rally.common.plugin import discover
|
||||
from rally.common.plugin import info
|
||||
from rally.common.plugin import plugin
|
||||
from rally.deployment import engine
|
||||
from rally.deployment.serverprovider import provider
|
||||
from rally.task import sla
|
||||
from rally import plugins
|
||||
from tests.unit import test
|
||||
|
||||
EXCEPTIONS_DOCSTR = "missed_docstrings.txt"
|
||||
@ -28,7 +24,6 @@ EXCEPTIONS_FORMAT = "wrong_format.txt"
|
||||
|
||||
class DocstringsTestCase(test.TestCase):
|
||||
|
||||
|
||||
def setUp(self):
|
||||
super(DocstringsTestCase, self).setUp()
|
||||
plugins.load()
|
||||
|
@ -69,7 +69,7 @@ class TestFormat(testtools.TestCase):
|
||||
docs_dir = os.path.join(os.path.dirname(__file__), os.pardir,
|
||||
os.pardir, os.pardir, "doc")
|
||||
for root, dirnames, filenames in os.walk(docs_dir):
|
||||
for filename in fnmatch.filter(filenames, '*.rst'):
|
||||
for filename in fnmatch.filter(filenames, "*.rst"):
|
||||
files.append(os.path.join(root, filename))
|
||||
|
||||
for filename in files:
|
||||
|
@ -74,7 +74,7 @@ class TitlesTestCase(test.TestCase):
|
||||
self.assertTrue(
|
||||
len(line) < 80,
|
||||
msg="%s:%d: Line limited to a maximum of 79 characters." %
|
||||
(tpl, i+1))
|
||||
(tpl, i + 1))
|
||||
|
||||
def _check_no_cr(self, tpl, raw):
|
||||
matches = re.findall("\r", raw)
|
||||
@ -88,7 +88,7 @@ class TitlesTestCase(test.TestCase):
|
||||
trailing_spaces = re.findall(" +$", line)
|
||||
self.assertEqual(
|
||||
len(trailing_spaces), 0,
|
||||
"Found trailing spaces on line %s of %s" % (i+1, tpl))
|
||||
"Found trailing spaces on line %s of %s" % (i + 1, tpl))
|
||||
|
||||
def test_template(self):
|
||||
with open(os.path.join(self.specs_path, "template.rst")) as f:
|
||||
|
@ -22,8 +22,8 @@ import traceback
|
||||
import yaml
|
||||
|
||||
from rally import api
|
||||
from rally.task import scenario
|
||||
from rally.task import engine
|
||||
from rally.task import scenario
|
||||
from tests.unit import test
|
||||
|
||||
|
||||
|
2
tox.ini
2
tox.ini
@ -78,7 +78,7 @@ commands = python {toxinidir}/tests/ci/sync_requirements.py {posargs}
|
||||
[flake8]
|
||||
ignore = H703,H105
|
||||
show-source = true
|
||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,tools,build,setup.py
|
||||
exclude=.venv,.git,.tox,dist,*lib/python*,*egg,tools,build,setup.py
|
||||
|
||||
[hacking]
|
||||
import_exceptions = rally.common.i18n
|
||||
|
Loading…
Reference in New Issue
Block a user