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'
|
text += '\n'
|
||||||
|
|
||||||
submods = [path.splitext(sub)[0] for sub in py_files
|
submods = [path.splitext(sub)[0] for sub in py_files
|
||||||
if not shall_skip(path.join(root, sub), opts)
|
if not shall_skip(path.join(root, sub), opts) and
|
||||||
and sub != INITPY]
|
sub != INITPY]
|
||||||
if submods:
|
if submods:
|
||||||
text += format_heading(2, 'Submodules')
|
text += format_heading(2, 'Submodules')
|
||||||
if opts.separatemodules:
|
if opts.separatemodules:
|
||||||
@ -212,8 +212,8 @@ def recurse_tree(rootpath, excludes, opts):
|
|||||||
exclude_prefixes = ('.',)
|
exclude_prefixes = ('.',)
|
||||||
else:
|
else:
|
||||||
exclude_prefixes = ('.', '_')
|
exclude_prefixes = ('.', '_')
|
||||||
subs[:] = sorted(sub for sub in subs if not sub.startswith(exclude_prefixes)
|
subs[:] = sorted(sub for sub in subs if not sub.startswith(exclude_prefixes) and
|
||||||
and not is_excluded(path.join(root, sub), excludes))
|
not is_excluded(path.join(root, sub), excludes))
|
||||||
|
|
||||||
if is_pkg:
|
if is_pkg:
|
||||||
# we are in a package with something to document
|
# we are in a package with something to document
|
||||||
|
@ -263,8 +263,8 @@ class Sphinx(object):
|
|||||||
self.builder.compile_update_catalogs()
|
self.builder.compile_update_catalogs()
|
||||||
self.builder.build_update()
|
self.builder.build_update()
|
||||||
|
|
||||||
status = (self.statuscode == 0
|
status = (self.statuscode == 0 and
|
||||||
and 'succeeded' or 'finished with problems')
|
'succeeded' or 'finished with problems')
|
||||||
if self._warncount:
|
if self._warncount:
|
||||||
self.info(bold('build %s, %s warning%s.' %
|
self.info(bold('build %s, %s warning%s.' %
|
||||||
(status, self._warncount,
|
(status, self._warncount,
|
||||||
@ -487,7 +487,8 @@ class Sphinx(object):
|
|||||||
def emit(self, event, *args):
|
def emit(self, event, *args):
|
||||||
try:
|
try:
|
||||||
self.debug2('[app] emitting event: %r%s', event, repr(args)[:100])
|
self.debug2('[app] emitting event: %r%s', event, repr(args)[:100])
|
||||||
except Exception: # not every object likes to be repr()'d (think
|
except Exception:
|
||||||
|
# not every object likes to be repr()'d (think
|
||||||
# random stuff coming via autodoc)
|
# random stuff coming via autodoc)
|
||||||
pass
|
pass
|
||||||
results = []
|
results = []
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
"""
|
"""
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import optparse
|
import optparse
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -139,8 +139,8 @@ class Config(object):
|
|||||||
applehelp_dev_region = ('en-us', 'applehelp'),
|
applehelp_dev_region = ('en-us', 'applehelp'),
|
||||||
applehelp_bundle_version = ('1', 'applehelp'),
|
applehelp_bundle_version = ('1', 'applehelp'),
|
||||||
applehelp_icon = (None, 'applehelp'),
|
applehelp_icon = (None, 'applehelp'),
|
||||||
applehelp_kb_product = (lambda self: '%s-%s' \
|
applehelp_kb_product = (lambda self: '%s-%s' %
|
||||||
% (make_filename(self.project), self.release),
|
(make_filename(self.project), self.release),
|
||||||
'applehelp'),
|
'applehelp'),
|
||||||
applehelp_kb_url = (None, 'applehelp'),
|
applehelp_kb_url = (None, 'applehelp'),
|
||||||
applehelp_remote_url = (None, 'applehelp'),
|
applehelp_remote_url = (None, 'applehelp'),
|
||||||
@ -257,7 +257,7 @@ class Config(object):
|
|||||||
self.overrides = overrides
|
self.overrides = overrides
|
||||||
self.values = Config.config_values.copy()
|
self.values = Config.config_values.copy()
|
||||||
config = {}
|
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):
|
if isinstance(overrides['extensions'], string_types):
|
||||||
config['extensions'] = overrides.pop('extensions').split(',')
|
config['extensions'] = overrides.pop('extensions').split(',')
|
||||||
else:
|
else:
|
||||||
@ -298,13 +298,13 @@ class Config(object):
|
|||||||
current = self[name]
|
current = self[name]
|
||||||
if type(current) is type(default):
|
if type(current) is type(default):
|
||||||
continue
|
continue
|
||||||
common_bases = (set(type(current).__bases__ + (type(current),))
|
common_bases = (set(type(current).__bases__ + (type(current),)) &
|
||||||
& set(type(default).__bases__))
|
set(type(default).__bases__))
|
||||||
common_bases.discard(object)
|
common_bases.discard(object)
|
||||||
if common_bases:
|
if common_bases:
|
||||||
continue # at least we share a non-trivial base class
|
continue # at least we share a non-trivial base class
|
||||||
warn("the config value %r has type `%s', defaults to `%s.'"
|
warn("the config value %r has type `%s', defaults to `%s.'" %
|
||||||
% (name, type(current).__name__, type(default).__name__))
|
(name, type(current).__name__, type(default).__name__))
|
||||||
|
|
||||||
def check_unicode(self, warn):
|
def check_unicode(self, warn):
|
||||||
# check all string values for non-ASCII characters in bytestrings,
|
# 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):
|
if isinstance(value, binary_type) and nonascii_re.search(value):
|
||||||
warn('the config value %r is set to a string with non-ASCII '
|
warn('the config value %r is set to a string with non-ASCII '
|
||||||
'characters; this can lead to Unicode errors occurring. '
|
'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):
|
def init_values(self, warn):
|
||||||
config = self._raw_config
|
config = self._raw_config
|
||||||
|
@ -349,7 +349,7 @@ class BuildEnvironment:
|
|||||||
fnset.discard(docname)
|
fnset.discard(docname)
|
||||||
if not fnset:
|
if not fnset:
|
||||||
del self.files_to_rebuild[subfn]
|
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:
|
if fn == docname:
|
||||||
del self.citations[key]
|
del self.citations[key]
|
||||||
for version, changes in self.versionchanges.items():
|
for version, changes in self.versionchanges.items():
|
||||||
@ -1473,8 +1473,8 @@ class BuildEnvironment:
|
|||||||
toplevel[1][:] = subtrees
|
toplevel[1][:] = subtrees
|
||||||
# resolve all sub-toctrees
|
# resolve all sub-toctrees
|
||||||
for subtocnode in toc.traverse(addnodes.toctree):
|
for subtocnode in toc.traverse(addnodes.toctree):
|
||||||
if not (subtocnode.get('hidden', False)
|
if not (subtocnode.get('hidden', False) and
|
||||||
and not includehidden):
|
not includehidden):
|
||||||
i = subtocnode.parent.index(subtocnode) + 1
|
i = subtocnode.parent.index(subtocnode) + 1
|
||||||
for item in _entries_from_toctree(
|
for item in _entries_from_toctree(
|
||||||
subtocnode, [refdoc] + parents,
|
subtocnode, [refdoc] + parents,
|
||||||
@ -1939,8 +1939,8 @@ class BuildEnvironment:
|
|||||||
else:
|
else:
|
||||||
# get all other symbols under one heading
|
# get all other symbols under one heading
|
||||||
return _('Symbols')
|
return _('Symbols')
|
||||||
return [(key, list(group))
|
return [(key_, list(group))
|
||||||
for (key, group) in groupby(newlist, keyfunc2)]
|
for (key_, group) in groupby(newlist, keyfunc2)]
|
||||||
|
|
||||||
def collect_relations(self):
|
def collect_relations(self):
|
||||||
relations = {}
|
relations = {}
|
||||||
|
@ -77,7 +77,7 @@ class PygmentsBridge(object):
|
|||||||
else:
|
else:
|
||||||
style = get_style_by_name(stylename)
|
style = get_style_by_name(stylename)
|
||||||
self.trim_doctest_flags = trim_doctest_flags
|
self.trim_doctest_flags = trim_doctest_flags
|
||||||
self.formatter_args = {'style' : style}
|
self.formatter_args = {'style': style}
|
||||||
if dest == 'html':
|
if dest == 'html':
|
||||||
self.formatter = self.html_formatter
|
self.formatter = self.html_formatter
|
||||||
else:
|
else:
|
||||||
@ -114,7 +114,7 @@ class PygmentsBridge(object):
|
|||||||
src = src.replace("...", mark)
|
src = src.replace("...", mark)
|
||||||
|
|
||||||
# lines beginning with "..." are probably placeholders for suite
|
# 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):
|
if PY2 and isinstance(src, text_type):
|
||||||
# Non-ASCII chars will only occur in string literals
|
# Non-ASCII chars will only occur in string literals
|
||||||
|
@ -27,12 +27,14 @@ def _tobool(val):
|
|||||||
return val.lower() in ('true', '1', 'yes', 'on')
|
return val.lower() in ('true', '1', 'yes', 'on')
|
||||||
return bool(val)
|
return bool(val)
|
||||||
|
|
||||||
|
|
||||||
def _toint(val):
|
def _toint(val):
|
||||||
try:
|
try:
|
||||||
return int(val)
|
return int(val)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def accesskey(context, key):
|
def accesskey(context, key):
|
||||||
"""Helper to output each access key only once."""
|
"""Helper to output each access key only once."""
|
||||||
if '_accesskeys' not in context:
|
if '_accesskeys' not in context:
|
||||||
@ -42,11 +44,14 @@ def accesskey(context, key):
|
|||||||
return 'accesskey="%s"' % key
|
return 'accesskey="%s"' % key
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
class idgen(object):
|
class idgen(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.id = 0
|
self.id = 0
|
||||||
|
|
||||||
def current(self):
|
def current(self):
|
||||||
return self.id
|
return self.id
|
||||||
|
|
||||||
def __next__(self):
|
def __next__(self):
|
||||||
self.id += 1
|
self.id += 1
|
||||||
return self.id
|
return self.id
|
||||||
@ -71,6 +76,7 @@ class SphinxFileSystemLoader(FileSystemLoader):
|
|||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
mtime = path.getmtime(filename)
|
mtime = path.getmtime(filename)
|
||||||
|
|
||||||
def uptodate():
|
def uptodate():
|
||||||
try:
|
try:
|
||||||
return path.getmtime(filename) == mtime
|
return path.getmtime(filename) == mtime
|
||||||
@ -80,7 +86,6 @@ class SphinxFileSystemLoader(FileSystemLoader):
|
|||||||
raise TemplateNotFound(template)
|
raise TemplateNotFound(template)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BuiltinTemplateLoader(TemplateBridge, BaseLoader):
|
class BuiltinTemplateLoader(TemplateBridge, BaseLoader):
|
||||||
"""
|
"""
|
||||||
Interfaces the rendering environment of jinja2 for use in Sphinx.
|
Interfaces the rendering environment of jinja2 for use in Sphinx.
|
||||||
|
@ -18,8 +18,6 @@ import time
|
|||||||
from os import path
|
from os import path
|
||||||
from io import open
|
from io import open
|
||||||
|
|
||||||
TERM_ENCODING = getattr(sys.stdin, 'encoding', None)
|
|
||||||
|
|
||||||
# try to import readline, unix specific enhancement
|
# try to import readline, unix specific enhancement
|
||||||
try:
|
try:
|
||||||
import readline
|
import readline
|
||||||
@ -41,6 +39,8 @@ from sphinx.util.console import purple, bold, red, turquoise, \
|
|||||||
nocolor, color_terminal
|
nocolor, color_terminal
|
||||||
from sphinx.util import texescape
|
from sphinx.util import texescape
|
||||||
|
|
||||||
|
TERM_ENCODING = getattr(sys.stdin, 'encoding', None)
|
||||||
|
|
||||||
# function to get input from terminal -- overridden by the test suite
|
# function to get input from terminal -- overridden by the test suite
|
||||||
term_input = input
|
term_input = input
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ DEFAULT_VALUE = {
|
|||||||
'ext_todo': False,
|
'ext_todo': False,
|
||||||
'makefile': True,
|
'makefile': True,
|
||||||
'batchfile': True,
|
'batchfile': True,
|
||||||
}
|
}
|
||||||
|
|
||||||
EXTENSIONS = ('autodoc', 'doctest', 'intersphinx', 'todo', 'coverage',
|
EXTENSIONS = ('autodoc', 'doctest', 'intersphinx', 'todo', 'coverage',
|
||||||
'pngmath', 'mathjax', 'ifconfig', 'viewcode')
|
'pngmath', 'mathjax', 'ifconfig', 'viewcode')
|
||||||
|
@ -166,6 +166,8 @@ TRANSLATABLE_NODES = {
|
|||||||
'index': addnodes.index,
|
'index': addnodes.index,
|
||||||
'image': nodes.image,
|
'image': nodes.image,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ExtraTranslatableNodes(Transform):
|
class ExtraTranslatableNodes(Transform):
|
||||||
"""
|
"""
|
||||||
make nodes translatable
|
make nodes translatable
|
||||||
|
Loading…
Reference in New Issue
Block a user