summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2015-03-08 16:28:23 +0100
committerGeorg Brandl <georg@python.org>2015-03-08 16:28:23 +0100
commit18b6843696a9f9b46f98a77a4e62825c193ae73a (patch)
tree5c7e2d6fad4777dc7e56126bcb06723742cea631
parent8bc5823724e58bc75d165adc77fb78525d0256f2 (diff)
downloadsphinx-git-18b6843696a9f9b46f98a77a4e62825c193ae73a.tar.gz
pep8 fixes
-rw-r--r--sphinx/apidoc.py8
-rw-r--r--sphinx/application.py9
-rw-r--r--sphinx/cmdline.py1
-rw-r--r--sphinx/config.py21
-rw-r--r--sphinx/environment.py14
-rw-r--r--sphinx/highlighting.py4
-rw-r--r--sphinx/jinja2glue.py9
-rw-r--r--sphinx/quickstart.py6
-rw-r--r--sphinx/transforms.py2
9 files changed, 40 insertions, 34 deletions
diff --git a/sphinx/apidoc.py b/sphinx/apidoc.py
index 807b03fca..ad5b8d04a 100644
--- a/sphinx/apidoc.py
+++ b/sphinx/apidoc.py
@@ -112,8 +112,8 @@ def create_package_file(root, master_package, subroot, py_files, opts, subs):
text += '\n'
submods = [path.splitext(sub)[0] for sub in py_files
- if not shall_skip(path.join(root, sub), opts)
- and sub != INITPY]
+ if not shall_skip(path.join(root, sub), opts) and
+ sub != INITPY]
if submods:
text += format_heading(2, 'Submodules')
if opts.separatemodules:
@@ -212,8 +212,8 @@ def recurse_tree(rootpath, excludes, opts):
exclude_prefixes = ('.',)
else:
exclude_prefixes = ('.', '_')
- subs[:] = sorted(sub for sub in subs if not sub.startswith(exclude_prefixes)
- and not is_excluded(path.join(root, sub), excludes))
+ subs[:] = sorted(sub for sub in subs if not sub.startswith(exclude_prefixes) and
+ not is_excluded(path.join(root, sub), excludes))
if is_pkg:
# we are in a package with something to document
diff --git a/sphinx/application.py b/sphinx/application.py
index 2dab2453e..326edb6d1 100644
--- a/sphinx/application.py
+++ b/sphinx/application.py
@@ -263,8 +263,8 @@ class Sphinx(object):
self.builder.compile_update_catalogs()
self.builder.build_update()
- status = (self.statuscode == 0
- and 'succeeded' or 'finished with problems')
+ status = (self.statuscode == 0 and
+ 'succeeded' or 'finished with problems')
if self._warncount:
self.info(bold('build %s, %s warning%s.' %
(status, self._warncount,
@@ -487,8 +487,9 @@ class Sphinx(object):
def emit(self, event, *args):
try:
self.debug2('[app] emitting event: %r%s', event, repr(args)[:100])
- except Exception: # not every object likes to be repr()'d (think
- # random stuff coming via autodoc)
+ except Exception:
+ # not every object likes to be repr()'d (think
+ # random stuff coming via autodoc)
pass
results = []
if event in self._listeners:
diff --git a/sphinx/cmdline.py b/sphinx/cmdline.py
index d05d8157f..c602cceac 100644
--- a/sphinx/cmdline.py
+++ b/sphinx/cmdline.py
@@ -10,7 +10,6 @@
"""
from __future__ import print_function
-import os
import sys
import optparse
import traceback
diff --git a/sphinx/config.py b/sphinx/config.py
index ec6680027..ac3358dda 100644
--- a/sphinx/config.py
+++ b/sphinx/config.py
@@ -88,7 +88,7 @@ class Config(object):
html_theme_path = ([], 'html'),
html_theme_options = ({}, 'html'),
html_title = (lambda self: l_('%s %s documentation') %
- (self.project, self.release),
+ (self.project, self.release),
'html'),
html_short_title = (lambda self: self.html_title, 'html'),
html_style = (None, 'html'),
@@ -139,9 +139,9 @@ class Config(object):
applehelp_dev_region = ('en-us', 'applehelp'),
applehelp_bundle_version = ('1', 'applehelp'),
applehelp_icon = (None, 'applehelp'),
- applehelp_kb_product = (lambda self: '%s-%s' \
- % (make_filename(self.project), self.release),
- 'applehelp'),
+ applehelp_kb_product = (lambda self: '%s-%s' %
+ (make_filename(self.project), self.release),
+ 'applehelp'),
applehelp_kb_url = (None, 'applehelp'),
applehelp_remote_url = (None, 'applehelp'),
applehelp_index_anchors = (False, 'applehelp'),
@@ -257,7 +257,7 @@ class Config(object):
self.overrides = overrides
self.values = Config.config_values.copy()
config = {}
- if 'extensions' in overrides: #XXX do we need this?
+ if 'extensions' in overrides: # XXX do we need this?
if isinstance(overrides['extensions'], string_types):
config['extensions'] = overrides.pop('extensions').split(',')
else:
@@ -298,13 +298,13 @@ class Config(object):
current = self[name]
if type(current) is type(default):
continue
- common_bases = (set(type(current).__bases__ + (type(current),))
- & set(type(default).__bases__))
+ common_bases = (set(type(current).__bases__ + (type(current),)) &
+ set(type(default).__bases__))
common_bases.discard(object)
if common_bases:
continue # at least we share a non-trivial base class
- warn("the config value %r has type `%s', defaults to `%s.'"
- % (name, type(current).__name__, type(default).__name__))
+ warn("the config value %r has type `%s', defaults to `%s.'" %
+ (name, type(current).__name__, type(default).__name__))
def check_unicode(self, warn):
# check all string values for non-ASCII characters in bytestrings,
@@ -313,8 +313,7 @@ class Config(object):
if isinstance(value, binary_type) and nonascii_re.search(value):
warn('the config value %r is set to a string with non-ASCII '
'characters; this can lead to Unicode errors occurring. '
- 'Please use Unicode strings, e.g. %r.' % (name, u'Content')
- )
+ 'Please use Unicode strings, e.g. %r.' % (name, u'Content'))
def init_values(self, warn):
config = self._raw_config
diff --git a/sphinx/environment.py b/sphinx/environment.py
index 661513041..cd238c03b 100644
--- a/sphinx/environment.py
+++ b/sphinx/environment.py
@@ -266,7 +266,7 @@ class BuildEnvironment:
self.files_to_rebuild = {} # docname -> set of files
# (containing its TOCs) to rebuild too
self.glob_toctrees = set() # docnames that have :glob: toctrees
- self.numbered_toctrees = set() # docnames that have :numbered: toctrees
+ self.numbered_toctrees = set() # docnames that have :numbered: toctrees
# domain-specific inventories, here to be pickled
self.domaindata = {} # domainname -> domain-specific dict
@@ -349,7 +349,7 @@ class BuildEnvironment:
fnset.discard(docname)
if not fnset:
del self.files_to_rebuild[subfn]
- for key, (fn, _) in list(self.citations.items()):
+ for key, (fn, _ignore) in list(self.citations.items()):
if fn == docname:
del self.citations[key]
for version, changes in self.versionchanges.items():
@@ -1316,7 +1316,7 @@ class BuildEnvironment:
else:
# cull sub-entries whose parents aren't 'current'
if (collapse and depth > 1 and
- 'iscurrent' not in subnode.parent):
+ 'iscurrent' not in subnode.parent):
subnode.parent.remove(subnode)
else:
# recurse on visible children
@@ -1473,8 +1473,8 @@ class BuildEnvironment:
toplevel[1][:] = subtrees
# resolve all sub-toctrees
for subtocnode in toc.traverse(addnodes.toctree):
- if not (subtocnode.get('hidden', False)
- and not includehidden):
+ if not (subtocnode.get('hidden', False) and
+ not includehidden):
i = subtocnode.parent.index(subtocnode) + 1
for item in _entries_from_toctree(
subtocnode, [refdoc] + parents,
@@ -1939,8 +1939,8 @@ class BuildEnvironment:
else:
# get all other symbols under one heading
return _('Symbols')
- return [(key, list(group))
- for (key, group) in groupby(newlist, keyfunc2)]
+ return [(key_, list(group))
+ for (key_, group) in groupby(newlist, keyfunc2)]
def collect_relations(self):
relations = {}
diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py
index 22f53a45b..57a841899 100644
--- a/sphinx/highlighting.py
+++ b/sphinx/highlighting.py
@@ -77,7 +77,7 @@ class PygmentsBridge(object):
else:
style = get_style_by_name(stylename)
self.trim_doctest_flags = trim_doctest_flags
- self.formatter_args = {'style' : style}
+ self.formatter_args = {'style': style}
if dest == 'html':
self.formatter = self.html_formatter
else:
@@ -114,7 +114,7 @@ class PygmentsBridge(object):
src = src.replace("...", mark)
# lines beginning with "..." are probably placeholders for suite
- src = re.sub(r"(?m)^(\s*)" + mark + "(.)", r"\1"+ mark + r"# \2", src)
+ src = re.sub(r"(?m)^(\s*)" + mark + "(.)", r"\1" + mark + r"# \2", src)
if PY2 and isinstance(src, text_type):
# Non-ASCII chars will only occur in string literals
diff --git a/sphinx/jinja2glue.py b/sphinx/jinja2glue.py
index b3f3228fb..c8a7165fc 100644
--- a/sphinx/jinja2glue.py
+++ b/sphinx/jinja2glue.py
@@ -14,7 +14,7 @@ from pprint import pformat
from six import string_types
from jinja2 import FileSystemLoader, BaseLoader, TemplateNotFound, \
- contextfunction
+ contextfunction
from jinja2.utils import open_if_exists
from jinja2.sandbox import SandboxedEnvironment
@@ -27,12 +27,14 @@ def _tobool(val):
return val.lower() in ('true', '1', 'yes', 'on')
return bool(val)
+
def _toint(val):
try:
return int(val)
except ValueError:
return 0
+
def accesskey(context, key):
"""Helper to output each access key only once."""
if '_accesskeys' not in context:
@@ -42,11 +44,14 @@ def accesskey(context, key):
return 'accesskey="%s"' % key
return ''
+
class idgen(object):
def __init__(self):
self.id = 0
+
def current(self):
return self.id
+
def __next__(self):
self.id += 1
return self.id
@@ -71,6 +76,7 @@ class SphinxFileSystemLoader(FileSystemLoader):
f.close()
mtime = path.getmtime(filename)
+
def uptodate():
try:
return path.getmtime(filename) == mtime
@@ -80,7 +86,6 @@ class SphinxFileSystemLoader(FileSystemLoader):
raise TemplateNotFound(template)
-
class BuiltinTemplateLoader(TemplateBridge, BaseLoader):
"""
Interfaces the rendering environment of jinja2 for use in Sphinx.
diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py
index 8f4e0ed52..64bbfc34e 100644
--- a/sphinx/quickstart.py
+++ b/sphinx/quickstart.py
@@ -18,8 +18,6 @@ import time
from os import path
from io import open
-TERM_ENCODING = getattr(sys.stdin, 'encoding', None)
-
# try to import readline, unix specific enhancement
try:
import readline
@@ -41,6 +39,8 @@ from sphinx.util.console import purple, bold, red, turquoise, \
nocolor, color_terminal
from sphinx.util import texescape
+TERM_ENCODING = getattr(sys.stdin, 'encoding', None)
+
# function to get input from terminal -- overridden by the test suite
term_input = input
@@ -57,7 +57,7 @@ DEFAULT_VALUE = {
'ext_todo': False,
'makefile': True,
'batchfile': True,
- }
+}
EXTENSIONS = ('autodoc', 'doctest', 'intersphinx', 'todo', 'coverage',
'pngmath', 'mathjax', 'ifconfig', 'viewcode')
diff --git a/sphinx/transforms.py b/sphinx/transforms.py
index 3f775517e..789bf5d39 100644
--- a/sphinx/transforms.py
+++ b/sphinx/transforms.py
@@ -166,6 +166,8 @@ TRANSLATABLE_NODES = {
'index': addnodes.index,
'image': nodes.image,
}
+
+
class ExtraTranslatableNodes(Transform):
"""
make nodes translatable