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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
.. highlight:: rest
|
||||
x.. highlight:: rest
|
||||
|
||||
Paragraph-level markup
|
||||
----------------------
|
||||
|
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