mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
more pep8 fixes
This commit is contained in:
parent
d0efb42a41
commit
ba9dcaac51
@ -7,7 +7,6 @@
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
from six import string_types
|
||||
from six.moves import range
|
||||
from docutils import nodes
|
||||
from docutils.parsers.rst import Directive, directives
|
||||
@ -224,7 +223,8 @@ class VersionChange(Directive):
|
||||
classes=['versionmodified']))
|
||||
else:
|
||||
para = nodes.paragraph('', '',
|
||||
nodes.inline('', '%s.' % text, classes=['versionmodified']))
|
||||
nodes.inline('', '%s.' % text,
|
||||
classes=['versionmodified']))
|
||||
node.append(para)
|
||||
env = self.state.document.settings.env
|
||||
# XXX should record node.source as well
|
||||
@ -359,10 +359,10 @@ class Only(Directive):
|
||||
self.state.nested_parse(self.content, self.content_offset,
|
||||
node, match_titles=1)
|
||||
title_styles = self.state.memo.title_styles
|
||||
if (not surrounding_title_styles
|
||||
or not title_styles
|
||||
or title_styles[0] not in surrounding_title_styles
|
||||
or not self.state.parent):
|
||||
if (not surrounding_title_styles or
|
||||
not title_styles or
|
||||
title_styles[0] not in surrounding_title_styles or
|
||||
not self.state.parent):
|
||||
# No nested sections so no special handling needed.
|
||||
return [node]
|
||||
# Calculate the depths of the current and nested sections.
|
||||
|
@ -172,6 +172,7 @@ class Domain(object):
|
||||
if name not in self.roles:
|
||||
return None
|
||||
fullname = '%s:%s' % (self.name, name)
|
||||
|
||||
def role_adapter(typ, rawtext, text, lineno, inliner,
|
||||
options={}, content=[]):
|
||||
return self.roles[name](fullname, rawtext, text, lineno,
|
||||
@ -189,6 +190,7 @@ class Domain(object):
|
||||
return None
|
||||
fullname = '%s:%s' % (self.name, name)
|
||||
BaseDirective = self.directives[name]
|
||||
|
||||
class DirectiveAdapter(BaseDirective):
|
||||
def run(self):
|
||||
self.name = fullname
|
||||
|
@ -78,7 +78,7 @@ class CObject(ObjectDescription):
|
||||
for part in [_f for _f in wsplit_re.split(ctype) if _f]:
|
||||
tnode = nodes.Text(part, part)
|
||||
if part[0] in string.ascii_letters+'_' and \
|
||||
part not in self.stopwords:
|
||||
part not in self.stopwords:
|
||||
pnode = addnodes.pending_xref(
|
||||
'', refdomain='c', reftype='type', reftarget=part,
|
||||
modname=None, classname=None)
|
||||
@ -145,7 +145,7 @@ class CObject(ObjectDescription):
|
||||
return fullname
|
||||
|
||||
paramlist = addnodes.desc_parameterlist()
|
||||
arglist = arglist.replace('`', '').replace('\\ ', '') # remove markup
|
||||
arglist = arglist.replace('`', '').replace('\\ ', '') # remove markup
|
||||
# this messes up function pointer types, but not too badly ;)
|
||||
for arg in self._parse_arglist(arglist):
|
||||
arg = arg.strip()
|
||||
@ -223,7 +223,7 @@ class CObject(ObjectDescription):
|
||||
class CXRefRole(XRefRole):
|
||||
def process_link(self, env, refnode, has_explicit_title, title, target):
|
||||
if not has_explicit_title:
|
||||
target = target.lstrip('~') # only has a meaning for the title
|
||||
target = target.lstrip('~') # only has a meaning for the title
|
||||
# if the first character is a tilde, don't display the module/class
|
||||
# parts of the contents
|
||||
if title[0:1] == '~':
|
||||
@ -254,7 +254,7 @@ class CDomain(Domain):
|
||||
'var': CObject,
|
||||
}
|
||||
roles = {
|
||||
'func' : CXRefRole(fix_parens=True),
|
||||
'func': CXRefRole(fix_parens=True),
|
||||
'member': CXRefRole(),
|
||||
'macro': CXRefRole(),
|
||||
'data': CXRefRole(),
|
||||
@ -265,7 +265,7 @@ class CDomain(Domain):
|
||||
}
|
||||
|
||||
def clear_doc(self, docname):
|
||||
for fullname, (fn, _) in list(self.data['objects'].items()):
|
||||
for fullname, (fn, _l) in list(self.data['objects'].items()):
|
||||
if fn == docname:
|
||||
del self.data['objects'][fullname]
|
||||
|
||||
|
@ -183,7 +183,7 @@ class JavaScriptDomain(Domain):
|
||||
}
|
||||
|
||||
def clear_doc(self, docname):
|
||||
for fullname, (fn, _) in list(self.data['objects'].items()):
|
||||
for fullname, (fn, _l) in list(self.data['objects'].items()):
|
||||
if fn == docname:
|
||||
del self.data['objects'][fullname]
|
||||
|
||||
@ -233,4 +233,4 @@ class JavaScriptDomain(Domain):
|
||||
def get_objects(self):
|
||||
for refname, (docname, type) in list(self.data['objects'].items()):
|
||||
yield refname, refname, type, docname, \
|
||||
refname.replace('$', '_S_'), 1
|
||||
refname.replace('$', '_S_'), 1
|
||||
|
@ -492,8 +492,8 @@ class PyXRefRole(XRefRole):
|
||||
refnode['py:module'] = env.ref_context.get('py:module')
|
||||
refnode['py:class'] = env.ref_context.get('py:class')
|
||||
if not has_explicit_title:
|
||||
title = title.lstrip('.') # only has a meaning for the target
|
||||
target = target.lstrip('~') # only has a meaning for the title
|
||||
title = title.lstrip('.') # only has a meaning for the target
|
||||
target = target.lstrip('~') # only has a meaning for the title
|
||||
# if the first character is a tilde, don't display the module/class
|
||||
# parts of the contents
|
||||
if title[0:1] == '~':
|
||||
@ -629,10 +629,10 @@ class PythonDomain(Domain):
|
||||
]
|
||||
|
||||
def clear_doc(self, docname):
|
||||
for fullname, (fn, _) in list(self.data['objects'].items()):
|
||||
for fullname, (fn, _l) in list(self.data['objects'].items()):
|
||||
if fn == docname:
|
||||
del self.data['objects'][fullname]
|
||||
for modname, (fn, _, _, _) in list(self.data['modules'].items()):
|
||||
for modname, (fn, _x, _x, _x) in list(self.data['modules'].items()):
|
||||
if fn == docname:
|
||||
del self.data['modules'][modname]
|
||||
|
||||
@ -680,8 +680,8 @@ class PythonDomain(Domain):
|
||||
# "fuzzy" searching mode
|
||||
searchname = '.' + name
|
||||
matches = [(oname, objects[oname]) for oname in objects
|
||||
if oname.endswith(searchname)
|
||||
and objects[oname][1] in objtypes]
|
||||
if oname.endswith(searchname) and
|
||||
objects[oname][1] in objtypes]
|
||||
else:
|
||||
# NOTE: searching for exact match, object type is not considered
|
||||
if name in objects:
|
||||
@ -694,15 +694,15 @@ class PythonDomain(Domain):
|
||||
elif modname and modname + '.' + name in objects:
|
||||
newname = modname + '.' + name
|
||||
elif modname and classname and \
|
||||
modname + '.' + classname + '.' + name in objects:
|
||||
modname + '.' + classname + '.' + name in objects:
|
||||
newname = modname + '.' + classname + '.' + name
|
||||
# special case: builtin exceptions have module "exceptions" set
|
||||
elif type == 'exc' and '.' not in name and \
|
||||
'exceptions.' + name in objects:
|
||||
'exceptions.' + name in objects:
|
||||
newname = 'exceptions.' + name
|
||||
# special case: object methods
|
||||
elif type in ('func', 'meth') and '.' not in name and \
|
||||
'object.' + name in objects:
|
||||
'object.' + name in objects:
|
||||
newname = 'object.' + name
|
||||
if newname is not None:
|
||||
matches.append((newname, objects[newname]))
|
||||
|
@ -498,16 +498,16 @@ class StandardDomain(Domain):
|
||||
}
|
||||
|
||||
def clear_doc(self, docname):
|
||||
for key, (fn, _) in list(self.data['progoptions'].items()):
|
||||
for key, (fn, _l) in list(self.data['progoptions'].items()):
|
||||
if fn == docname:
|
||||
del self.data['progoptions'][key]
|
||||
for key, (fn, _) in list(self.data['objects'].items()):
|
||||
for key, (fn, _l) in list(self.data['objects'].items()):
|
||||
if fn == docname:
|
||||
del self.data['objects'][key]
|
||||
for key, (fn, _, _) in list(self.data['labels'].items()):
|
||||
for key, (fn, _l, _l) in list(self.data['labels'].items()):
|
||||
if fn == docname:
|
||||
del self.data['labels'][key]
|
||||
for key, (fn, _) in list(self.data['anonlabels'].items()):
|
||||
for key, (fn, _l) in list(self.data['anonlabels'].items()):
|
||||
if fn == docname:
|
||||
del self.data['anonlabels'][key]
|
||||
|
||||
|
@ -138,16 +138,18 @@ class _TranslationProxy(UserString, object):
|
||||
except:
|
||||
return '<%s broken>' % self.__class__.__name__
|
||||
|
||||
|
||||
def mygettext(string):
|
||||
"""Used instead of _ when creating TranslationProxies, because _ is
|
||||
not bound yet at that time.
|
||||
"""
|
||||
return _(string)
|
||||
|
||||
|
||||
def lazy_gettext(string):
|
||||
"""A lazy version of `gettext`."""
|
||||
#if isinstance(string, _TranslationProxy):
|
||||
# return string
|
||||
# if isinstance(string, _TranslationProxy):
|
||||
# return string
|
||||
return _TranslationProxy(mygettext, string)
|
||||
|
||||
l_ = lazy_gettext
|
||||
@ -209,7 +211,7 @@ def init(locale_dirs, language, catalog='sphinx'):
|
||||
for dir_ in locale_dirs:
|
||||
try:
|
||||
trans = gettext.translation(catalog, localedir=dir_,
|
||||
languages=[language])
|
||||
languages=[language])
|
||||
if translator is None:
|
||||
translator = trans
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user