diff options
| author | Georg Brandl <georg@python.org> | 2009-01-10 21:23:39 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2009-01-10 21:23:39 +0100 |
| commit | ac92e5497ec6704b661ca3e7539ce2799fda2ef4 (patch) | |
| tree | c092aa25daf519398c0d6cc84f85a568cf26440e /sphinx/ext | |
| parent | 19c1cf1417e05c065cd73a51f8385f8ffe912281 (diff) | |
| download | sphinx-ac92e5497ec6704b661ca3e7539ce2799fda2ef4.tar.gz | |
Reformat to EOL80.
Diffstat (limited to 'sphinx/ext')
| -rw-r--r-- | sphinx/ext/autodoc.py | 112 | ||||
| -rw-r--r-- | sphinx/ext/coverage.py | 28 | ||||
| -rw-r--r-- | sphinx/ext/doctest.py | 9 | ||||
| -rw-r--r-- | sphinx/ext/ifconfig.py | 4 | ||||
| -rw-r--r-- | sphinx/ext/jsmath.py | 3 | ||||
| -rw-r--r-- | sphinx/ext/pngmath.py | 23 | ||||
| -rw-r--r-- | sphinx/ext/refcounting.py | 6 | ||||
| -rw-r--r-- | sphinx/ext/todo.py | 4 |
8 files changed, 109 insertions, 80 deletions
diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index d0512f2b..c005e36a 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -54,7 +54,7 @@ def get_method_type(obj): (isinstance(obj, MethodType) and obj.im_self is not None): return 'classmethod' elif isinstance(obj, FunctionType) or \ - (isinstance(obj, BuiltinFunctionType) and obj.__self__ is not None): + (isinstance(obj, BuiltinFunctionType) and obj.__self__ is not None): return 'staticmethod' else: return 'method' @@ -193,7 +193,8 @@ class RstGenerator(object): docstrings.append(obj.__doc__) # skip some lines in module docstrings if configured (deprecated!) - if what == 'module' and self.env.config.automodule_skip_lines and docstrings: + if what == 'module' and self.env.config.automodule_skip_lines \ + and docstrings: docstrings[0] = '\n'.join(docstrings[0].splitlines() [self.env.config.automodule_skip_lines:]) @@ -212,7 +213,8 @@ class RstGenerator(object): docstrings.append(initdocstring) # the default is only the class docstring - # make sure we have Unicode docstrings, then sanitize and split into lines + # make sure we have Unicode docstrings, then sanitize and split + # into lines return [prepare_docstring(force_decode(docstring, encoding)) for docstring in docstrings] @@ -233,8 +235,9 @@ class RstGenerator(object): Returns a tuple of: the full name, the module name, a path of names to get via getattr, the signature and return annotation. """ - # first, parse the definition -- auto directives for classes and functions - # can contain a signature which is then used instead of an autogenerated one + # first, parse the definition -- auto directives for classes and + # functions can contain a signature which is then used instead of + # an autogenerated one try: mod, path, base, args, retann = py_ext_sig_re.match(name).groups() except: @@ -261,8 +264,8 @@ class RstGenerator(object): if path: mod = path.rstrip('.') else: - # if documenting a toplevel object without explicit module, it can - # be contained in another auto directive ... + # if documenting a toplevel object without explicit module, + # it can be contained in another auto directive ... if hasattr(self.env, 'autodoc_current_module'): mod = self.env.autodoc_current_module # ... or in the scope of a module directive @@ -276,8 +279,9 @@ class RstGenerator(object): mod_cls = path.rstrip('.') else: mod_cls = None - # if documenting a class-level object without path, there must be a - # current class, either from a parent auto directive ... + # if documenting a class-level object without path, + # there must be a current class, either from a parent + # auto directive ... if hasattr(self.env, 'autodoc_current_class'): mod_cls = self.env.autodoc_current_class # ... or from a class directive @@ -313,7 +317,8 @@ class RstGenerator(object): args = None getargs = True if what == 'class': - # for classes, the relevant signature is the __init__ method's + # for classes, the relevant signature is the + # __init__ method's obj = getattr(obj, '__init__', None) # classes without __init__ method, default __init__ or # __init__ written in C? @@ -334,8 +339,9 @@ class RstGenerator(object): args = None err = e - result = self.env.app.emit_firstresult('autodoc-process-signature', what, - name, obj, self.options, args, retann) + result = self.env.app.emit_firstresult( + 'autodoc-process-signature', what, name, obj, + self.options, args, retann) if result: args, retann = result @@ -347,22 +353,24 @@ class RstGenerator(object): else: return '' - def generate(self, what, name, members, add_content, indent=u'', check_module=False, - no_docstring=False): + def generate(self, what, name, members, add_content, indent=u'', + check_module=False, no_docstring=False): """ Generate reST for the object in self.result. """ mod, objpath, args, retann = self.resolve_name(what, name) if not mod: # need a module to import - self.warn('don\'t know which module to import for autodocumenting %r ' - '(try placing a "module" or "currentmodule" directive in the ' - 'document, or giving an explicit module name)' % name) + self.warn('don\'t know which module to import for autodocumenting ' + '%r (try placing a "module" or "currentmodule" directive ' + 'in the document, or giving an explicit module name)' + % name) return # fully-qualified name fullname = mod + (objpath and '.' + '.'.join(objpath) or '') - # the name to put into the generated directive -- doesn't contain the module + # the name to put into the generated directive -- doesn't contain + # the module name_in_directive = '.'.join(objpath) or mod # now, import the module and get object to document @@ -372,8 +380,8 @@ class RstGenerator(object): for part in objpath: todoc = getattr(todoc, part) except (ImportError, AttributeError), err: - self.warn('autodoc can\'t import/find %s %r, it reported error: "%s", ' - 'please check your spelling and sys.path' % + self.warn('autodoc can\'t import/find %s %r, it reported error: ' + '"%s", please check your spelling and sys.path' % (what, str(fullname), err)) return @@ -388,7 +396,7 @@ class RstGenerator(object): else: self.filename_set.add(analyzer.srcname) - # check __module__ of object if wanted (for members not given explicitly) + # check __module__ of object for members not given explicitly if check_module: if hasattr(todoc, '__module__'): if todoc.__module__ != mod: @@ -417,16 +425,16 @@ class RstGenerator(object): if what == 'module': # Add some module-specific options if self.options.synopsis: - self.result.append(indent + u' :synopsis: ' + self.options.synopsis, - '<autodoc>') + self.result.append(indent + u' :synopsis: ' + + self.options.synopsis, '<autodoc>') if self.options.platform: - self.result.append(indent + u' :platform: ' + self.options.platform, - '<autodoc>') + self.result.append(indent + u' :platform: ' + + self.options.platform, '<autodoc>') if self.options.deprecated: self.result.append(indent + u' :deprecated:', '<autodoc>') else: - # Be explicit about the module, this is necessary since .. class:: doesn't - # support a prepended module name + # Be explicit about the module, this is necessary since .. class:: + # doesn't support a prepended module name self.result.append(indent + u' :module: %s' % mod, '<autodoc>') if self.options.noindex: self.result.append(indent + u' :noindex:', '<autodoc>') @@ -439,7 +447,8 @@ class RstGenerator(object): u':class:`%s`' % b.__name__ or u':class:`%s.%s`' % (b.__module__, b.__name__) for b in todoc.__bases__] - self.result.append(indent + _(u' Bases: %s') % ', '.join(bases), + self.result.append(indent + _(u' Bases: %s') % + ', '.join(bases), '<autodoc>') self.result.append(u'', '<autodoc>') @@ -513,7 +522,8 @@ class RstGenerator(object): # base classes all_members = inspect.getmembers(todoc) else: - # __dict__ contains only the members directly defined in the class + # __dict__ contains only the members directly defined + # in the class all_members = sorted(todoc.__dict__.iteritems()) else: all_members = [(mname, getattr(todoc, mname)) for mname in members] @@ -524,7 +534,8 @@ class RstGenerator(object): for (membername, member) in all_members: # if isattr is True, the member is documented as an attribute isattr = False - # if content is not None, no extra content from docstrings will be added + # if content is not None, no extra content from docstrings + # will be added content = None if want_all_members and membername.startswith('_'): @@ -536,15 +547,18 @@ class RstGenerator(object): skip = False isattr = True else: - # ignore undocumented members if :undoc-members: is not given + # ignore undocumented members if :undoc-members: + # is not given doc = getattr(member, '__doc__', None) skip = not self.options.undoc_members and not doc - # give the user a chance to decide whether this member should be skipped + # give the user a chance to decide whether this member + # should be skipped if self.env.app: # let extensions preprocess docstrings skip_user = self.env.app.emit_firstresult( - 'autodoc-skip-member', what, membername, member, skip, self.options) + 'autodoc-skip-member', what, membername, member, + skip, self.options) if skip_user is not None: skip = skip_user if skip: @@ -560,8 +574,9 @@ class RstGenerator(object): if member.__name__ != membername: # assume it's aliased memberwhat = 'data' - content = ViewList([_('alias of :class:`%s`') % member.__name__], - source='') + content = ViewList( + [_('alias of :class:`%s`') % member.__name__], + source='') elif issubclass(member, base_exception): memberwhat = 'exception' else: @@ -577,8 +592,9 @@ class RstGenerator(object): if member.__name__ != membername: # assume it's aliased memberwhat = 'attribute' - content = ViewList([_('alias of :class:`%s`') % member.__name__], - source='') + content = ViewList( + [_('alias of :class:`%s`') % member.__name__], + source='') else: memberwhat = 'class' elif isdescriptor(member): @@ -586,8 +602,8 @@ class RstGenerator(object): else: continue - # give explicitly separated module name, so that members of inner classes - # can be documented + # give explicitly separated module name, so that members + # of inner classes can be documented full_membername = mod + '::' + '.'.join(objpath + [membername]) self.generate(memberwhat, full_membername, ['__all__'], add_content=content, no_docstring=bool(content), @@ -653,13 +669,17 @@ def members_option(arg): def setup(app): - mod_options = {'members': members_option, 'undoc-members': directives.flag, - 'noindex': directives.flag, 'inherited-members': directives.flag, - 'show-inheritance': directives.flag, 'synopsis': lambda x: x, - 'platform': lambda x: x, 'deprecated': directives.flag} - cls_options = {'members': members_option, 'undoc-members': directives.flag, - 'noindex': directives.flag, 'inherited-members': directives.flag, - 'show-inheritance': directives.flag} + mod_options = { + 'members': members_option, 'undoc-members': directives.flag, + 'noindex': directives.flag, 'inherited-members': directives.flag, + 'show-inheritance': directives.flag, 'synopsis': lambda x: x, + 'platform': lambda x: x, 'deprecated': directives.flag + } + cls_options = { + 'members': members_option, 'undoc-members': directives.flag, + 'noindex': directives.flag, 'inherited-members': directives.flag, + 'show-inheritance': directives.flag + } app.add_directive('automodule', automodule_directive, 1, (1, 0, 1), **mod_options) app.add_directive('autoclass', autoclass_directive, diff --git a/sphinx/ext/coverage.py b/sphinx/ext/coverage.py index a3dc5889..964e58ee 100644 --- a/sphinx/ext/coverage.py +++ b/sphinx/ext/coverage.py @@ -53,17 +53,17 @@ class CoverageBuilder(Builder): self.c_ignorexps = {} for (name, exps) in self.config.coverage_ignore_c_items.iteritems(): - self.c_ignorexps[name] = compile_regex_list('coverage_ignore_c_items', - exps, self.warn) - self.mod_ignorexps = compile_regex_list('coverage_ignore_modules', - self.config.coverage_ignore_modules, - self.warn) - self.cls_ignorexps = compile_regex_list('coverage_ignore_classes', - self.config.coverage_ignore_classes, - self.warn) - self.fun_ignorexps = compile_regex_list('coverage_ignore_functions', - self.config.coverage_ignore_functions, - self.warn) + self.c_ignorexps[name] = compile_regex_list( + 'coverage_ignore_c_items', exps, self.warn) + self.mod_ignorexps = compile_regex_list( + 'coverage_ignore_modules', self.config.coverage_ignore_modules, + self.warn) + self.cls_ignorexps = compile_regex_list( + 'coverage_ignore_classes', self.config.coverage_ignore_classes, + self.warn) + self.fun_ignorexps = compile_regex_list( + 'coverage_ignore_functions', self.config.coverage_ignore_functions, + self.warn) def get_outdated_docs(self): return 'coverage overview' @@ -128,7 +128,8 @@ class CoverageBuilder(Builder): try: mod = __import__(mod_name, fromlist=['foo']) except ImportError, err: - self.warn('module %s could not be imported: %s' % (mod_name, err)) + self.warn('module %s could not be imported: %s' % + (mod_name, err)) self.py_undoc[mod_name] = {'error': err} continue @@ -168,7 +169,8 @@ class CoverageBuilder(Builder): attrs = [] - for attr_name, attr in inspect.getmembers(obj, inspect.ismethod): + for attr_name, attr in inspect.getmembers( + obj, inspect.ismethod): if attr_name[0] == '_': # starts with an underscore, ignore it continue diff --git a/sphinx/ext/doctest.py b/sphinx/ext/doctest.py index d6697f98..d2aacaa4 100644 --- a/sphinx/ext/doctest.py +++ b/sphinx/ext/doctest.py @@ -262,13 +262,15 @@ Doctest summary for group in groups.itervalues(): group.add_code(code) if self.config.doctest_global_setup: - code = TestCode(self.config.doctest_global_setup, 'testsetup', lineno=0) + code = TestCode(self.config.doctest_global_setup, + 'testsetup', lineno=0) for group in groups.itervalues(): group.add_code(code, prepend=True) if not groups: return - self._out('\nDocument: %s\n----------%s\n' % (docname, '-'*len(docname))) + self._out('\nDocument: %s\n----------%s\n' % + (docname, '-'*len(docname))) for group in groups.itervalues(): self.test_group(group, self.env.doc2path(docname, base=None)) # Separately count results from setup code @@ -287,7 +289,8 @@ Doctest summary ns = {} examples = [] for setup in group.setup: - examples.append(doctest.Example(setup.code, '', lineno=setup.lineno)) + examples.append(doctest.Example(setup.code, '', + lineno=setup.lineno)) if examples: # simulate a doctest with the setup code setup_doctest = doctest.DocTest(examples, {}, diff --git a/sphinx/ext/ifconfig.py b/sphinx/ext/ifconfig.py index f622ec49..af3975b8 100644 --- a/sphinx/ext/ifconfig.py +++ b/sphinx/ext/ifconfig.py @@ -13,8 +13,8 @@ This stuff is only included in the built docs for unstable versions. The argument for ``ifconfig`` is a plain Python expression, evaluated in the - namespace of the project configuration (that is, all variables from ``conf.py`` - are available.) + namespace of the project configuration (that is, all variables from + ``conf.py`` are available.) :copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. diff --git a/sphinx/ext/jsmath.py b/sphinx/ext/jsmath.py index 1bea3304..e51af455 100644 --- a/sphinx/ext/jsmath.py +++ b/sphinx/ext/jsmath.py @@ -32,7 +32,8 @@ def html_visit_displaymath(self, node): if i == 0: # necessary to e.g. set the id property correctly if node['number']: - self.body.append('<span class="eqno">(%s)</span>' % node['number']) + self.body.append('<span class="eqno">(%s)</span>' % + node['number']) self.body.append(self.starttag(node, 'div', CLASS='math')) else: # but only once! diff --git a/sphinx/ext/pngmath.py b/sphinx/ext/pngmath.py index dc1d2ee8..61df53a5 100644 --- a/sphinx/ext/pngmath.py +++ b/sphinx/ext/pngmath.py @@ -117,9 +117,9 @@ def render_math(self, math): if err.errno != 2: # No such file or directory raise if not hasattr(self.builder, '_mathpng_warned_latex'): - self.builder.warn('LaTeX command %r cannot be run (needed for math ' - 'display), check the pngmath_latex setting' % - self.builder.config.pngmath_latex) + self.builder.warn('LaTeX command %r cannot be run (needed for ' + 'math display), check the pngmath_latex ' + 'setting' % self.builder.config.pngmath_latex) self.builder._mathpng_warned_latex = True return relfn, None finally: @@ -127,8 +127,8 @@ def render_math(self, math): stdout, stderr = p.communicate() if p.returncode != 0: - raise MathExtError('latex exited with error:\n[stderr]\n%s\n[stdout]\n%s' - % (stderr, stdout)) + raise MathExtError('latex exited with error:\n[stderr]\n%s\n' + '[stdout]\n%s' % (stderr, stdout)) ensuredir(path.dirname(outfn)) # use some standard dvipng arguments @@ -146,15 +146,15 @@ def render_math(self, math): if err.errno != 2: # No such file or directory raise if not hasattr(self.builder, '_mathpng_warned_dvipng'): - self.builder.warn('dvipng command %r cannot be run (needed for math ' - 'display), check the pngmath_dvipng setting' % - self.builder.config.pngmath_dvipng) + self.builder.warn('dvipng command %r cannot be run (needed for ' + 'math display), check the pngmath_dvipng setting' + % self.builder.config.pngmath_dvipng) self.builder._mathpng_warned_dvipng = True return relfn, None stdout, stderr = p.communicate() if p.returncode != 0: - raise MathExtError('dvipng exited with error:\n[stderr]\n%s\n[stdout]\n%s' - % (stderr, stdout)) + raise MathExtError('dvipng exited with error:\n[stderr]\n%s\n' + '[stdout]\n%s' % (stderr, stdout)) depth = None if use_preview: for line in stdout.splitlines(): @@ -187,7 +187,8 @@ def html_visit_math(self, node): raise nodes.SkipNode self.body.append('<img class="math" src="%s" alt="%s" %s/>' % (fname, self.encode(node['latex']).strip(), - depth and 'style="vertical-align: %dpx" ' % (-depth) or '')) + depth and 'style="vertical-align: %dpx" ' % + (-depth) or '')) raise nodes.SkipNode def html_visit_displaymath(self, node): diff --git a/sphinx/ext/refcounting.py b/sphinx/ext/refcounting.py index c31d6627..cad9d7f1 100644 --- a/sphinx/ext/refcounting.py +++ b/sphinx/ext/refcounting.py @@ -55,7 +55,8 @@ class Refcounts(dict): refcount = None else: refcount = int(refcount) - # Update the entry with the new parameter or the result information. + # Update the entry with the new parameter or the result + # information. if arg: entry.args.append((arg, type, refcount)) else: @@ -81,7 +82,8 @@ class Refcounts(dict): if entry.result_refs is None: rc += "Always NULL." else: - rc += (entry.result_refs and "New" or "Borrowed") + " reference." + rc += (entry.result_refs and "New" or "Borrowed") + \ + " reference." node.insert(0, refcount(rc, rc)) diff --git a/sphinx/ext/todo.py b/sphinx/ext/todo.py index dac90660..b7a8d500 100644 --- a/sphinx/ext/todo.py +++ b/sphinx/ext/todo.py @@ -72,8 +72,8 @@ def process_todo_nodes(app, doctree, fromdocname): para = nodes.paragraph() filename = env.doc2path(todo_info['docname'], base=None) description = ( - _('(The original entry is located in %s, line %d and can be found ') % - (filename, todo_info['lineno'])) + _('(The original entry is located in %s, line %d and ' + 'can be found ') % (filename, todo_info['lineno'])) para += nodes.Text(description, description) # Create a reference |
