mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
pep8 fixes
This commit is contained in:
parent
8bc5823724
commit
18b6843696
@ -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
|
||||
|
@ -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:
|
||||
|
@ -10,7 +10,6 @@
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import optparse
|
||||
import traceback
|
||||
|
@ -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
|
||||
|
@ -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 = {}
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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')
|
||||
|
@ -166,6 +166,8 @@ TRANSLATABLE_NODES = {
|
||||
'index': addnodes.index,
|
||||
'image': nodes.image,
|
||||
}
|
||||
|
||||
|
||||
class ExtraTranslatableNodes(Transform):
|
||||
"""
|
||||
make nodes translatable
|
||||
|
Loading…
Reference in New Issue
Block a user