mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix more line length and trailing whitespace.
This commit is contained in:
parent
b068e91803
commit
aedbdd953d
4
Makefile
4
Makefile
@ -7,7 +7,9 @@ export PYTHONPATH = $(shell echo "$$PYTHONPATH"):./sphinx
|
||||
all: clean-pyc check test
|
||||
|
||||
check:
|
||||
@$(PYTHON) utils/check_sources.py -i sphinx/style/jquery.js sphinx
|
||||
@$(PYTHON) utils/check_sources.py -i sphinx/style/jquery.js \
|
||||
-i sphinx/pycode/pgen2 -i sphinx/util/smartypants.py \
|
||||
-i doc/_build -i ez_setup.py -i tests/path.py .
|
||||
|
||||
clean: clean-pyc clean-patchfiles
|
||||
|
||||
|
2
doc/_templates/index.html
vendored
2
doc/_templates/index.html
vendored
@ -81,5 +81,5 @@
|
||||
</p>
|
||||
<p>The code can be found in a Mercurial repository, at
|
||||
<tt>http://bitbucket.org/birkenfeld/sphinx/</tt>.</p>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
@ -29,7 +29,7 @@ The builder's "name" must be given to the **-b** command-line option of
|
||||
also generates HTML Help support files that allow the Microsoft HTML Help
|
||||
Workshop to compile them into a CHM file.
|
||||
|
||||
Its name is ``htmlhelp``.
|
||||
Its name is ``htmlhelp``.
|
||||
|
||||
.. module:: sphinx.builders.latex
|
||||
.. class:: LaTeXBuilder
|
||||
@ -85,7 +85,7 @@ The builder's "name" must be given to the **-b** command-line option of
|
||||
.. _PHP serialization: http://pypi.python.org/pypi/phpserialize
|
||||
|
||||
.. attribute:: implementation
|
||||
|
||||
|
||||
A module that implements `dump()`, `load()`, `dumps()` and `loads()`
|
||||
functions that conform to the functions with the same names from the
|
||||
pickle module. Known modules implementing this interface are
|
||||
|
@ -55,19 +55,19 @@ tables of contents. The ``toctree`` directive is the central element.
|
||||
``strings`` and so forth, and it knows that they are children of the shown
|
||||
document, the library index. From this information it generates "next
|
||||
chapter", "previous chapter" and "parent chapter" links.
|
||||
|
||||
|
||||
Document titles in the :dir:`toctree` will be automatically read from the
|
||||
title of the referenced document. If that isn't what you want, you can give
|
||||
the specify an explicit title and target using a similar syntax to reST
|
||||
hyperlinks (and Sphinx's :ref:`cross-referencing syntax <xref-syntax>`). This
|
||||
looks like::
|
||||
|
||||
|
||||
.. toctree::
|
||||
|
||||
|
||||
intro
|
||||
All about strings <strings>
|
||||
datatypes
|
||||
|
||||
|
||||
The second line above will link to the ``strings`` document, but will use the
|
||||
title "All about strings" instead of the title of the ``strings`` document.
|
||||
|
||||
@ -97,7 +97,7 @@ tables of contents. The ``toctree`` directive is the central element.
|
||||
This will still notify Sphinx of the document hierarchy, but not insert links
|
||||
into the document at the location of the directive -- this makes sense if you
|
||||
intend to insert these links yourself, in a different style.
|
||||
|
||||
|
||||
In the end, all documents in the :term:`source directory` (or subdirectories)
|
||||
must occur in some ``toctree`` directive; Sphinx will emit a warning if it
|
||||
finds a file that is not included, because that means that this file will not
|
||||
|
@ -59,7 +59,7 @@ html_use_opensearch = 'http://sphinx.pocoo.org'
|
||||
htmlhelp_basename = 'Sphinxdoc'
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, document class [howto/manual]).
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [('contents', 'sphinx.tex', 'Sphinx Documentation',
|
||||
'Georg Brandl', 'manual', 1)]
|
||||
|
||||
@ -125,5 +125,6 @@ def setup(app):
|
||||
app.add_description_unit('directive', 'dir', 'pair: %s; directive',
|
||||
parse_directive)
|
||||
app.add_description_unit('role', 'role', 'pair: %s; role', parse_role)
|
||||
app.add_description_unit('confval', 'confval', 'pair: %s; configuration value')
|
||||
app.add_description_unit('confval', 'confval',
|
||||
'pair: %s; configuration value')
|
||||
app.add_description_unit('event', 'event', 'pair: %s; event', parse_event)
|
||||
|
@ -76,7 +76,7 @@ General configuration
|
||||
|
||||
.. versionadded:: 0.5
|
||||
Previously, Sphinx accepted only UTF-8 encoded sources.
|
||||
|
||||
|
||||
.. confval:: master_doc
|
||||
|
||||
The document name of the "master" document, that is, the document that
|
||||
@ -166,7 +166,7 @@ General configuration
|
||||
|
||||
Project information
|
||||
-------------------
|
||||
|
||||
|
||||
.. confval:: project
|
||||
|
||||
The documented project's name.
|
||||
@ -233,7 +233,7 @@ Project information
|
||||
:ref:`code-examples` for more details.
|
||||
|
||||
.. versionadded:: 0.5
|
||||
|
||||
|
||||
.. confval:: pygments_style
|
||||
|
||||
The style name to use for Pygments highlighting of source code. Default is
|
||||
@ -341,7 +341,7 @@ that use Sphinx' HTMLWriter class.
|
||||
|
||||
.. versionadded:: 0.6
|
||||
Previously, this was always activated.
|
||||
|
||||
|
||||
.. confval:: html_sidebars
|
||||
|
||||
Custom sidebar templates, must be a dictionary that maps document names to
|
||||
@ -439,7 +439,7 @@ that use Sphinx' HTMLWriter class.
|
||||
support different web server setups).
|
||||
|
||||
.. versionadded:: 0.6
|
||||
|
||||
|
||||
.. confval:: html_translator_class
|
||||
|
||||
A string with the fully-qualified name of a HTML Translator class, that is, a
|
||||
@ -527,7 +527,7 @@ These options influence LaTeX output.
|
||||
avoid interpretation as escape sequences.
|
||||
|
||||
* Keys that you may want to override include:
|
||||
|
||||
|
||||
``'papersize'``
|
||||
Paper size option of the document class (``'a4paper'`` or
|
||||
``'letterpaper'``), default ``'letterpaper'``.
|
||||
@ -551,9 +551,9 @@ These options influence LaTeX output.
|
||||
Additional preamble content, default empty.
|
||||
``'footer'```
|
||||
Additional footer content (before the indices), default empty.
|
||||
|
||||
|
||||
* Keys that don't need be overridden unless in special cases are:
|
||||
|
||||
|
||||
``'inputenc'``
|
||||
"inputenc" package inclusion, default
|
||||
``'\\usepackage[utf8]{inputenc}'``.
|
||||
@ -570,9 +570,9 @@ These options influence LaTeX output.
|
||||
"printindex" call, the last thing in the file, default
|
||||
``'\\printindex'``. Override if you want to generate the index
|
||||
differently or append some content after the index.
|
||||
|
||||
|
||||
* Keys that are set by other options and therefore should not be overridden are:
|
||||
|
||||
|
||||
``'docclass'``
|
||||
``'classoptions'``
|
||||
``'title'``
|
||||
@ -585,7 +585,7 @@ These options influence LaTeX output.
|
||||
``'makemodindex'``
|
||||
``'shorthandoff'``
|
||||
``'printmodindex'``
|
||||
|
||||
|
||||
.. confval:: latex_preamble
|
||||
|
||||
Additional LaTeX markup for the preamble.
|
||||
|
@ -14,7 +14,7 @@ Sphinx documentation contents
|
||||
config
|
||||
templating
|
||||
extensions
|
||||
|
||||
|
||||
glossary
|
||||
changes
|
||||
examples
|
||||
|
@ -45,12 +45,12 @@ the following public API:
|
||||
:exc:`docutils.nodes.SkipNode`. Example::
|
||||
|
||||
class math(docutils.nodes.Element)
|
||||
|
||||
|
||||
def visit_math_html(self, node):
|
||||
self.body.append(self.starttag(node, 'math'))
|
||||
def depart_math_html(self, node):
|
||||
self.body.append('</math>')
|
||||
|
||||
|
||||
app.add_node(math, html=(visit_math_html, depart_math_html))
|
||||
|
||||
Obviously, translators for which you don't specify visitor methods will choke
|
||||
@ -174,7 +174,7 @@ the following public API:
|
||||
highlight code blocks with the given language *alias*.
|
||||
|
||||
.. versionadded:: 0.6
|
||||
|
||||
|
||||
.. method:: Sphinx.connect(event, callback)
|
||||
|
||||
Register *callback* to be called when *event* is emitted. For details on
|
||||
@ -237,7 +237,7 @@ registered event handlers.
|
||||
since the module declarations could have been removed from the file.
|
||||
|
||||
.. versionadded:: 0.5
|
||||
|
||||
|
||||
.. event:: source-read (app, docname, source)
|
||||
|
||||
Emitted when a source file has been read. The *source* argument is a list
|
||||
@ -249,7 +249,7 @@ registered event handlers.
|
||||
``:math:`...```.
|
||||
|
||||
.. versionadded:: 0.5
|
||||
|
||||
|
||||
.. event:: doctree-read (app, doctree)
|
||||
|
||||
Emitted when a doctree has been parsed and read by the environment, and is
|
||||
@ -271,7 +271,7 @@ registered event handlers.
|
||||
future reference and should be a child of the returned reference node.
|
||||
|
||||
.. versionadded:: 0.5
|
||||
|
||||
|
||||
.. event:: doctree-resolved (app, doctree, docname)
|
||||
|
||||
Emitted when a doctree has been "resolved" by the environment, that is, all
|
||||
@ -287,7 +287,7 @@ registered event handlers.
|
||||
completed, that is, the environment and all doctrees are now up-to-date.
|
||||
|
||||
.. versionadded:: 0.5
|
||||
|
||||
|
||||
.. event:: page-context (app, pagename, templatename, context, doctree)
|
||||
|
||||
Emitted when the HTML builder has created a context dictionary to render a
|
||||
@ -318,7 +318,7 @@ registered event handlers.
|
||||
cleanup actions depending on the exception status.
|
||||
|
||||
.. versionadded:: 0.5
|
||||
|
||||
|
||||
|
||||
.. _template-bridge:
|
||||
|
||||
|
@ -61,7 +61,7 @@ directive.
|
||||
Boil the noodle *time* minutes.
|
||||
|
||||
**Options and advanced usage**
|
||||
|
||||
|
||||
* If you want to automatically document members, there's a ``members``
|
||||
option::
|
||||
|
||||
|
@ -131,7 +131,7 @@ completely equivalent. ::
|
||||
|
||||
Test-Output example:
|
||||
|
||||
.. testcode::
|
||||
.. testcode::
|
||||
|
||||
parrot.voom(3000)
|
||||
|
||||
@ -156,7 +156,7 @@ There are also these config values for customizing the doctest extension:
|
||||
e.g. import modules you will always need in your doctests.
|
||||
|
||||
.. versionadded:: 0.6
|
||||
|
||||
|
||||
.. confval:: doctest_test_doctest_blocks
|
||||
|
||||
If this is a nonempty string (the default is ``'default'``), standard reST
|
||||
@ -187,7 +187,7 @@ There are also these config values for customizing the doctest extension:
|
||||
>>> print 1
|
||||
1
|
||||
|
||||
Some more documentation text.
|
||||
Some more documentation text.
|
||||
|
||||
This feature makes it easy for you to test doctests in docstrings included
|
||||
with the :mod:`~sphinx.ext.autodoc` extension without marking them up with a
|
||||
|
@ -49,7 +49,7 @@ linking:
|
||||
This will download the corresponding :file:`objects.inv` file from the
|
||||
Internet and generate links to the pages under the given URI. The downloaded
|
||||
inventory is cached in the Sphinx environment, so it must be redownloaded
|
||||
whenever you do a full rebuild.
|
||||
whenever you do a full rebuild.
|
||||
|
||||
A second example, showing the meaning of a non-``None`` value::
|
||||
|
||||
|
@ -90,7 +90,7 @@ further translation is necessary when building LaTeX output.
|
||||
|
||||
Euler's identity, equation :eq:`euler`, was elected one of the most
|
||||
beautiful mathematical formulas.
|
||||
|
||||
|
||||
|
||||
:mod:`sphinx.ext.pngmath` -- Render math as PNG images
|
||||
------------------------------------------------------
|
||||
@ -133,7 +133,7 @@ There are various config values you can set to influence how the images are buil
|
||||
list.
|
||||
|
||||
.. versionadded:: 0.5.1
|
||||
|
||||
|
||||
.. confval:: pngmath_latex_preamble
|
||||
|
||||
Additional LaTeX code to put into the preamble of the short LaTeX files that
|
||||
@ -145,7 +145,7 @@ There are various config values you can set to influence how the images are buil
|
||||
Additional arguments to give to dvipng, as a list. The default value is
|
||||
``['-gamma 1.5', '-D 110']`` which makes the image a bit darker and larger
|
||||
then it is by default.
|
||||
|
||||
|
||||
An arguments you might want to add here is e.g. ``'-bg Transparent'``,
|
||||
which produces PNGs with a transparent background. This is not enabled by
|
||||
default because some Internet Explorer versions don't like transparent PNGs.
|
||||
|
@ -21,9 +21,9 @@ There are two additional directives when using this extension:
|
||||
This directive is replaced by a list of all todo directives in the whole
|
||||
documentation, if :confval:`todo_include_todos` is true.
|
||||
|
||||
|
||||
|
||||
There is also an additional config value:
|
||||
|
||||
|
||||
.. confval:: todo_include_todos
|
||||
|
||||
If this is ``True``, :dir:`todo` and :dir:`todolist` produce output, else
|
||||
|
@ -158,7 +158,7 @@ Let's start with the node classes::
|
||||
|
||||
def visit_todo_node(self, node):
|
||||
self.visit_admonition(node)
|
||||
|
||||
|
||||
def depart_todo_node(self, node):
|
||||
self.depart_admonition(node)
|
||||
|
||||
@ -190,14 +190,14 @@ The ``todo`` directive function looks like this::
|
||||
def todo_directive(name, arguments, options, content, lineno,
|
||||
content_offset, block_text, state, state_machine):
|
||||
env = state.document.settings.env
|
||||
|
||||
|
||||
targetid = "todo-%s" % env.index_num
|
||||
env.index_num += 1
|
||||
targetnode = nodes.target('', '', ids=[targetid])
|
||||
|
||||
|
||||
ad = make_admonition(todo, name, [_('Todo')], options, content, lineno,
|
||||
content_offset, block_text, state, state_machine)
|
||||
|
||||
|
||||
if not hasattr(env, 'todo_all_todos'):
|
||||
env.todo_all_todos = []
|
||||
env.todo_all_todos.append({
|
||||
@ -206,7 +206,7 @@ The ``todo`` directive function looks like this::
|
||||
'todo': ad[0].deepcopy(),
|
||||
'target': targetnode,
|
||||
})
|
||||
|
||||
|
||||
return [targetnode] + ad
|
||||
|
||||
Several important things are covered here. First, as you can see, you can refer
|
||||
@ -264,18 +264,18 @@ emitted at the end of phase 3 and allows custom resolving to be done::
|
||||
if not app.config.todo_include_todos:
|
||||
for node in doctree.traverse(todo_node):
|
||||
node.parent.remove(node)
|
||||
|
||||
|
||||
# Replace all todolist nodes with a list of the collected todos.
|
||||
# Augment each todo with a backlink to the original location.
|
||||
env = app.builder.env
|
||||
|
||||
|
||||
for node in doctree.traverse(todolist):
|
||||
if not app.config.todo_include_todos:
|
||||
node.replace_self([])
|
||||
continue
|
||||
|
||||
|
||||
content = []
|
||||
|
||||
|
||||
for todo_info in env.todo_all_todos:
|
||||
para = nodes.paragraph()
|
||||
filename = env.doc2path(todo_info['docname'], base=None)
|
||||
@ -283,7 +283,7 @@ emitted at the end of phase 3 and allows custom resolving to be done::
|
||||
_('(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
|
||||
newnode = nodes.reference('', '')
|
||||
innernode = nodes.emphasis(_('here'), _('here'))
|
||||
@ -294,11 +294,11 @@ emitted at the end of phase 3 and allows custom resolving to be done::
|
||||
newnode.append(innernode)
|
||||
para += newnode
|
||||
para += nodes.Text('.)', '.)')
|
||||
|
||||
|
||||
# Insert into the todolist
|
||||
content.append(todo_info['todo'])
|
||||
content.append(para)
|
||||
|
||||
|
||||
node.replace_self(content)
|
||||
|
||||
It is a bit more involved. If our new "todo_include_todos" config value is
|
||||
|
@ -109,7 +109,7 @@ The :program:`sphinx-build` script has several more options:
|
||||
Don't look for a configuration file; only take options via the ``-D`` option.
|
||||
|
||||
.. versionadded:: 0.5
|
||||
|
||||
|
||||
**-D** *setting=value*
|
||||
Override a configuration value set in the :file:`conf.py` file. The value
|
||||
must be a string or dictionary value. For the latter, supply the setting
|
||||
|
@ -101,7 +101,7 @@ Includes
|
||||
The directive also supports the ``linenos`` flag option to switch on line
|
||||
numbers, and a ``language`` option to select a language different from the
|
||||
current file's standard language. Example with options::
|
||||
|
||||
|
||||
.. literalinclude:: example.rb
|
||||
:language: ruby
|
||||
:linenos:
|
||||
|
@ -260,7 +260,7 @@ explained by an example::
|
||||
.. function:: format_exception(etype, value, tb[, limit=None])
|
||||
|
||||
Format the exception with a traceback.
|
||||
|
||||
|
||||
:param etype: exception type
|
||||
:param value: exception value
|
||||
:param tb: traceback object
|
||||
|
@ -1,4 +1,4 @@
|
||||
.. highlight:: rest
|
||||
x.. highlight:: rest
|
||||
|
||||
Paragraph-level markup
|
||||
----------------------
|
||||
@ -85,9 +85,9 @@ units as well as normal text:
|
||||
|
||||
This directive creates a paragraph heading that is not used to create a
|
||||
table of contents node.
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
|
||||
If the *title* of the rubric is "Footnotes", this rubric is ignored by
|
||||
the LaTeX writer, since it is assumed to only contain footnote
|
||||
definitions and therefore would create an empty heading.
|
||||
@ -239,7 +239,7 @@ the definition of the symbol. There is this directive:
|
||||
Note that no further reST parsing is done in the production, so that you
|
||||
don't have to escape ``*`` or ``|`` characters.
|
||||
|
||||
.. XXX describe optional first parameter
|
||||
.. XXX describe optional first parameter
|
||||
|
||||
The following is an example taken from the Python Reference Manual::
|
||||
|
||||
|
@ -282,7 +282,7 @@ markup blocks, like this::
|
||||
See the `reST reference for substitutions
|
||||
<http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#substitution-definitions>`_
|
||||
for details.
|
||||
|
||||
|
||||
If you want to use some substitutions for all documents, put them into a
|
||||
separate file and include it into all documents you want to use them in, using
|
||||
the :dir:`include` directive. Be sure to give the include file a file name
|
||||
@ -301,7 +301,7 @@ footnotes above) is regarded as a comment. For example::
|
||||
.. This is a comment.
|
||||
|
||||
You can indent text after a comment start to form multiline comments::
|
||||
|
||||
|
||||
..
|
||||
This whole indented block
|
||||
is a comment.
|
||||
@ -329,5 +329,5 @@ There are some problems one commonly runs into while authoring reST documents:
|
||||
|
||||
* **No nested inline markup:** Something like ``*see :func:`foo`*`` is not
|
||||
possible.
|
||||
|
||||
|
||||
.. XXX more?
|
||||
|
3
setup.py
3
setup.py
@ -98,7 +98,8 @@ else:
|
||||
else:
|
||||
for locale in os.listdir(self.directory):
|
||||
po_file = os.path.join(self.directory, locale,
|
||||
'LC_MESSAGES', self.domain + '.po')
|
||||
'LC_MESSAGES',
|
||||
self.domain + '.po')
|
||||
if os.path.exists(po_file):
|
||||
po_files.append((locale, po_file))
|
||||
js_files.append(os.path.join(self.directory, locale,
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
Theming support for HTML builders.
|
||||
|
||||
:copyright: 2007-2009 by the Sphinx team, see AUTHORS.
|
||||
:copyright: Copyright 2007-2009 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
|
@ -5,9 +5,6 @@
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its containing dir.
|
||||
#
|
||||
# The contents of this file are pickled, so don't put values in the namespace
|
||||
# that aren't pickleable (module imports are okay, they're removed automatically).
|
||||
#
|
||||
# All configuration values have a default value; values that are commented out
|
||||
# serve to show the default value.
|
||||
|
||||
@ -57,8 +54,8 @@ today_fmt = '%B %d, %Y'
|
||||
# List of documents that shouldn't be included in the build.
|
||||
#unused_docs = []
|
||||
|
||||
# List of directories, relative to source directories, that shouldn't be searched
|
||||
# for source files.
|
||||
# List of directories, relative to source directories, that shouldn't be
|
||||
# searched for source files.
|
||||
exclude_trees = ['_build']
|
||||
|
||||
keep_warnings = True
|
||||
@ -150,7 +147,7 @@ htmlhelp_basename = 'SphinxTestsdoc'
|
||||
#latex_font_size = '10pt'
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title, author, document class [howto/manual]).
|
||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
||||
latex_documents = [
|
||||
('contents', 'SphinxTests.tex', 'Sphinx Tests Documentation',
|
||||
'Georg Brandl', 'manual'),
|
||||
|
@ -131,7 +131,8 @@ def test_format_signature():
|
||||
# test for functions
|
||||
def f(a, b, c=1, **d):
|
||||
pass
|
||||
assert gen.format_signature('function', 'f', f, None, None) == '(a, b, c=1, **d)'
|
||||
assert gen.format_signature('function', 'f', f, None, None) == \
|
||||
'(a, b, c=1, **d)'
|
||||
assert gen.format_signature('function', 'f', f, 'a, b, c, d', None) == \
|
||||
'(a, b, c, d)'
|
||||
assert gen.format_signature('function', 'f', f, None, 'None') == \
|
||||
@ -151,7 +152,8 @@ def test_format_signature():
|
||||
class G(F, object):
|
||||
pass
|
||||
for C in (F, G):
|
||||
assert gen.format_signature('class', 'C', C, None, None) == '(a, b=None)'
|
||||
assert gen.format_signature('class', 'C', C, None, None) == \
|
||||
'(a, b=None)'
|
||||
assert gen.format_signature('class', 'C', D, 'a, b', 'X') == '(a, b) -> X'
|
||||
|
||||
# test for methods
|
||||
@ -160,12 +162,16 @@ def test_format_signature():
|
||||
pass
|
||||
def foo2(b, *c):
|
||||
pass
|
||||
assert gen.format_signature('method', 'H.foo', H.foo1, None, None) == '(b, *c)'
|
||||
assert gen.format_signature('method', 'H.foo', H.foo1, 'a', None) == '(a)'
|
||||
assert gen.format_signature('method', 'H.foo', H.foo2, None, None) == '(b, *c)'
|
||||
assert gen.format_signature('method', 'H.foo', H.foo1, None, None) == \
|
||||
'(b, *c)'
|
||||
assert gen.format_signature('method', 'H.foo', H.foo1, 'a', None) == \
|
||||
'(a)'
|
||||
assert gen.format_signature('method', 'H.foo', H.foo2, None, None) == \
|
||||
'(b, *c)'
|
||||
|
||||
# test exception handling
|
||||
raises(RuntimeError, gen.format_signature, 'function', 'int', int, None, None)
|
||||
raises(RuntimeError, gen.format_signature,
|
||||
'function', 'int', int, None, None)
|
||||
|
||||
# test processing by event handler
|
||||
assert gen.format_signature('method', 'bar', H.foo1, None, None) == '42'
|
||||
@ -248,7 +254,8 @@ def test_docstring_processing():
|
||||
# docstring processing by event handler
|
||||
assert process('class', 'bar', E) == ['Init docstring', '', '42', '']
|
||||
|
||||
lid = app.connect('autodoc-process-docstring', cut_lines(1, 1, ['function']))
|
||||
lid = app.connect('autodoc-process-docstring',
|
||||
cut_lines(1, 1, ['function']))
|
||||
def f():
|
||||
"""
|
||||
first line
|
||||
@ -289,7 +296,8 @@ def test_generate():
|
||||
del processed_docstrings[:]
|
||||
del processed_signatures[:]
|
||||
assert_works(*args)
|
||||
assert set(processed_docstrings) | set(processed_signatures) == set(items)
|
||||
assert set(processed_docstrings) | set(processed_signatures) == \
|
||||
set(items)
|
||||
|
||||
def assert_result_contains(item, *args):
|
||||
gen.generate(*args)
|
||||
@ -313,8 +321,10 @@ def test_generate():
|
||||
assert_result_contains(' Function.', 'method', 'Class.meth', [], None)
|
||||
add_content = ViewList()
|
||||
add_content.append('Content.', '', 0)
|
||||
assert_result_contains(' Function.', 'method', 'Class.meth', [], add_content)
|
||||
assert_result_contains(' Content.', 'method', 'Class.meth', [], add_content)
|
||||
assert_result_contains(' Function.', 'method',
|
||||
'Class.meth', [], add_content)
|
||||
assert_result_contains(' Content.', 'method',
|
||||
'Class.meth', [], add_content)
|
||||
|
||||
# test check_module
|
||||
gen.generate('function', 'raises', None, None, check_module=True)
|
||||
@ -342,20 +352,23 @@ def test_generate():
|
||||
assert_processes(should, 'class', 'Class', ['__all__'], None)
|
||||
|
||||
# test module flags
|
||||
assert_result_contains('.. module:: test_autodoc', 'module',
|
||||
'test_autodoc', [], None)
|
||||
assert_result_contains('.. module:: test_autodoc',
|
||||
'module', 'test_autodoc', [], None)
|
||||
options.synopsis = 'Synopsis'
|
||||
assert_result_contains(' :synopsis: Synopsis', 'module', 'test_autodoc', [], None)
|
||||
assert_result_contains(' :synopsis: Synopsis',
|
||||
'module', 'test_autodoc', [], None)
|
||||
options.deprecated = True
|
||||
assert_result_contains(' :deprecated:', 'module', 'test_autodoc', [], None)
|
||||
assert_result_contains(' :deprecated:',
|
||||
'module', 'test_autodoc', [], None)
|
||||
options.platform = 'Platform'
|
||||
assert_result_contains(' :platform: Platform', 'module', 'test_autodoc', [], None)
|
||||
assert_result_contains(' :platform: Platform',
|
||||
'module', 'test_autodoc', [], None)
|
||||
# test if __all__ is respected for modules
|
||||
assert_result_contains('.. class:: Class', 'module', 'test_autodoc',
|
||||
['__all__'], None)
|
||||
assert_result_contains('.. class:: Class',
|
||||
'module', 'test_autodoc', ['__all__'], None)
|
||||
try:
|
||||
assert_result_contains('.. exception:: CustomEx', 'module', 'test_autodoc',
|
||||
['__all__'], None)
|
||||
assert_result_contains('.. exception:: CustomEx',
|
||||
'module', 'test_autodoc', ['__all__'], None)
|
||||
except AssertionError:
|
||||
pass
|
||||
else:
|
||||
@ -378,8 +391,10 @@ def test_generate():
|
||||
|
||||
# test generation for C modules (which have no source file)
|
||||
gen.env.currmodule = 'time'
|
||||
assert_processes([('function', 'time.asctime')], 'function', 'asctime', [], None)
|
||||
assert_processes([('function', 'time.asctime')], 'function', 'asctime', [], None)
|
||||
assert_processes([('function', 'time.asctime')],
|
||||
'function', 'asctime', [], None)
|
||||
assert_processes([('function', 'time.asctime')],
|
||||
'function', 'asctime', [], None)
|
||||
|
||||
|
||||
# --- generate fodder ------------
|
||||
|
@ -30,9 +30,10 @@ latex_warnfile = StringIO()
|
||||
|
||||
ENV_WARNINGS = """\
|
||||
WARNING: %(root)s/images.txt:9: Image file not readable: foo.png
|
||||
WARNING: %(root)s/images.txt:23: Nonlocal image URI found: http://www.python.org/logo.png
|
||||
WARNING: %(root)s/includes.txt:: (WARNING/2) Encoding 'utf-8' used for reading included \
|
||||
file u'wrongenc.inc' seems to be wrong, try giving an :encoding: option
|
||||
WARNING: %(root)s/images.txt:23: Nonlocal image URI found: \
|
||||
http://www.python.org/logo.png
|
||||
WARNING: %(root)s/includes.txt:: (WARNING/2) Encoding 'utf-8' used for reading \
|
||||
included file u'wrongenc.inc' seems to be wrong, try giving an :encoding: option
|
||||
WARNING: %(root)s/includes.txt:56: Download file not readable: nonexisting.png
|
||||
"""
|
||||
|
||||
@ -172,12 +173,15 @@ def test_latex(app):
|
||||
return True
|
||||
|
||||
if kpsetest('article.sty') is None:
|
||||
print >>sys.stderr, 'info: not running latex, it doesn\'t seem to be installed'
|
||||
print >>sys.stderr, \
|
||||
'info: not running latex, it doesn\'t seem to be installed'
|
||||
return
|
||||
for filename in ['fancyhdr.sty', 'fancybox.sty', 'titlesec.sty', 'amsmath.sty',
|
||||
'framed.sty', 'color.sty', 'fancyvrb.sty', 'threeparttable.sty']:
|
||||
for filename in ['fancyhdr.sty', 'fancybox.sty', 'titlesec.sty',
|
||||
'amsmath.sty', 'framed.sty', 'color.sty', 'fancyvrb.sty',
|
||||
'threeparttable.sty']:
|
||||
if not kpsetest(filename):
|
||||
print >>sys.stderr, 'info: not running latex, the %s package doesn\'t ' \
|
||||
print >>sys.stderr, \
|
||||
'info: not running latex, the %s package doesn\'t ' \
|
||||
'seem to be installed' % filename
|
||||
return
|
||||
|
||||
@ -186,8 +190,8 @@ def test_latex(app):
|
||||
os.chdir(app.outdir)
|
||||
try:
|
||||
try:
|
||||
p = Popen(['pdflatex', '--interaction=nonstopmode', 'SphinxTests.tex'],
|
||||
stdout=PIPE, stderr=PIPE)
|
||||
p = Popen(['pdflatex', '--interaction=nonstopmode',
|
||||
'SphinxTests.tex'], stdout=PIPE, stderr=PIPE)
|
||||
except OSError, err:
|
||||
pass # most likely pdflatex was not found
|
||||
else:
|
||||
|
@ -54,7 +54,8 @@ def test_images():
|
||||
app._warning.reset()
|
||||
htmlbuilder = StandaloneHTMLBuilder(app, env)
|
||||
htmlbuilder.post_process_images(tree)
|
||||
assert "no matching candidate for image URI u'foo.*'" in app._warning.content[-1]
|
||||
assert "no matching candidate for image URI u'foo.*'" in \
|
||||
app._warning.content[-1]
|
||||
assert set(htmlbuilder.images.keys()) == set(['subdir/img.png', 'img.png',
|
||||
'subdir/simg.png'])
|
||||
assert set(htmlbuilder.images.values()) == set(['img.png', 'img1.png',
|
||||
@ -63,8 +64,10 @@ def test_images():
|
||||
app._warning.reset()
|
||||
latexbuilder = LaTeXBuilder(app, env)
|
||||
latexbuilder.post_process_images(tree)
|
||||
assert "no matching candidate for image URI u'foo.*'" in app._warning.content[-1]
|
||||
assert set(latexbuilder.images.keys()) == set(['subdir/img.png', 'subdir/simg.png',
|
||||
assert "no matching candidate for image URI u'foo.*'" in \
|
||||
app._warning.content[-1]
|
||||
assert set(latexbuilder.images.keys()) == set(['subdir/img.png',
|
||||
'subdir/simg.png',
|
||||
'img.png', 'img.pdf'])
|
||||
assert set(latexbuilder.images.values()) == set(['img.pdf', 'img.png',
|
||||
'img1.png', 'simg.png'])
|
||||
|
@ -25,7 +25,8 @@ def setup_module():
|
||||
global app, settings, parser
|
||||
texescape.init() # otherwise done by the latex builder
|
||||
app = TestApp(cleanenv=True)
|
||||
optparser = frontend.OptionParser(components=(rst.Parser, HTMLWriter, LaTeXWriter))
|
||||
optparser = frontend.OptionParser(
|
||||
components=(rst.Parser, HTMLWriter, LaTeXWriter))
|
||||
settings = optparser.get_default_values()
|
||||
settings.env = app.builder.env
|
||||
parser = rst.Parser()
|
||||
@ -85,7 +86,8 @@ def test_inline():
|
||||
# interpolation of braces in samp and file roles (HTML only)
|
||||
verify(':samp:`a{b}c`',
|
||||
'<p><tt class="docutils literal"><span class="pre">a</span>'
|
||||
'<em><span class="pre">b</span></em><span class="pre">c</span></tt></p>',
|
||||
'<em><span class="pre">b</span></em>'
|
||||
'<span class="pre">c</span></tt></p>',
|
||||
'\\samp{abc}')
|
||||
|
||||
# interpolation of arrows in menuselection
|
||||
|
@ -97,7 +97,8 @@ class TestApp(application.Sphinx):
|
||||
"""
|
||||
|
||||
def __init__(self, srcdir=None, confdir=None, outdir=None, doctreedir=None,
|
||||
buildername='html', confoverrides=None, status=None, warning=None,
|
||||
buildername='html', confoverrides=None,
|
||||
status=None, warning=None,
|
||||
freshenv=None, confname='conf.py', cleanenv=False):
|
||||
|
||||
application.CONFIG_FILENAME = confname
|
||||
|
@ -30,7 +30,7 @@ def checker(*suffixes, **kwds):
|
||||
|
||||
|
||||
name_mail_re = r'[\w ]+(<.*?>)?'
|
||||
copyright_re = re.compile(r'^ :copyright: Copyright 200\d(-200\d)?'
|
||||
copyright_re = re.compile(r'^ :copyright: Copyright 200\d(-200\d)? '
|
||||
r'by %s(, %s)*[,.]$' %
|
||||
(name_mail_re, name_mail_re))
|
||||
license_re = re.compile(r" :license: (.*?).\n")
|
||||
@ -142,7 +142,7 @@ def check_fileheader(fn, lines):
|
||||
yield 0, "no correct copyright info"
|
||||
|
||||
|
||||
@checker('.py', '.html')
|
||||
@checker('.py', '.html', '.rst')
|
||||
def check_whitespace_and_spelling(fn, lines):
|
||||
for lno, line in enumerate(lines):
|
||||
if "\t" in line:
|
||||
@ -154,7 +154,7 @@ def check_whitespace_and_spelling(fn, lines):
|
||||
yield lno+1, '"%s" used' % word
|
||||
|
||||
|
||||
bad_tags = ('<b>', '<i>', '<u>', '<s>', '<strike>'
|
||||
bad_tags = ('<u>', '<s>', '<strike>'
|
||||
'<center>', '<big>', '<small>', '<font')
|
||||
|
||||
@checker('.html')
|
||||
|
@ -8,7 +8,8 @@
|
||||
-d (--dryrun) Dry run. Analyze, but don't make any changes to files.
|
||||
-r (--recurse) Recurse. Search for all .py files in subdirectories too.
|
||||
-B (--no-backup) Don't write .bak backup files.
|
||||
-v (--verbose) Verbose. Print informative msgs; else only names of changed files.
|
||||
-v (--verbose) Verbose. Print informative msgs; else only names of \
|
||||
changed files.
|
||||
-h (--help) Help. Print this usage information and exit.
|
||||
|
||||
Change Python (.py) files to use 4-space indents and no hard tab characters.
|
||||
@ -118,7 +119,8 @@ def check(file):
|
||||
if dryrun:
|
||||
print "But this is a dry run, so leaving it alone."
|
||||
else:
|
||||
print "reindented", file, (dryrun and "(dry run => not really)" or "")
|
||||
print "reindented", file, \
|
||||
(dryrun and "(dry run => not really)" or "")
|
||||
if not dryrun:
|
||||
if not no_backup:
|
||||
bak = file + ".bak"
|
||||
|
Loading…
Reference in New Issue
Block a user