fix trailing space and long line

This commit is contained in:
Takayuki Shimizukawa 2014-10-09 23:53:33 +09:00
parent 95ada28440
commit da651089e7
12 changed files with 75 additions and 30 deletions

View File

@ -7,7 +7,22 @@ DONT_CHECK = -i build -i dist -i sphinx/style/jquery.js \
-i sphinx/pycode/pgen2 -i sphinx/util/smartypants.py \ -i sphinx/pycode/pgen2 -i sphinx/util/smartypants.py \
-i .ropeproject -i doc/_build -i tests/path.py \ -i .ropeproject -i doc/_build -i tests/path.py \
-i tests/coverage.py -i env -i utils/convert.py \ -i tests/coverage.py -i env -i utils/convert.py \
-i sphinx/search/ja.py \ -i sphinx/search/da.py \
-i sphinx/search/de.py \
-i sphinx/search/en.py \
-i sphinx/search/es.py \
-i sphinx/search/fi.py \
-i sphinx/search/fr.py \
-i sphinx/search/hu.py \
-i sphinx/search/it.py \
-i sphinx/search/ja.py \
-i sphinx/search/nl.py \
-i sphinx/search/no.py \
-i sphinx/search/pt.py \
-i sphinx/search/ro.py \
-i sphinx/search/ru.py \
-i sphinx/search/sv.py \
-i sphinx/search/tr.py \
-i utils/reindent3.py -i utils/check_sources3.py -i .tox -i utils/reindent3.py -i utils/check_sources3.py -i .tox
all: clean-pyc clean-backupfiles check test all: clean-pyc clean-backupfiles check test

View File

@ -526,7 +526,7 @@ The following directives are available. All declarations can start with a visibi
.. rst:directive:: .. cpp:class:: class speicifer .. rst:directive:: .. cpp:class:: class speicifer
Describe a class/struct, possibly with specification of inheritance, e.g.,:: Describe a class/struct, possibly with specification of inheritance, e.g.,::
.. cpp:class:: SomeName::SomeClass : public MyBase, MyOtherBase .. cpp:class:: SomeName::SomeClass : public MyBase, MyOtherBase
.. rst:directive:: .. cpp:function:: (member-)function prototype .. rst:directive:: .. cpp:function:: (member-)function prototype

View File

@ -83,7 +83,7 @@ package.
Register an event called *name*. This is needed to be able to emit it. Register an event called *name*. This is needed to be able to emit it.
.. method:: Sphinx.set_translator(name, translator_class) .. method:: Sphinx.set_translator(name, translator_class)
Register or override a Docutils translator class. This is used to register Register or override a Docutils translator class. This is used to register
a custom output translator or to replace a builtin translator. a custom output translator or to replace a builtin translator.
This allows extensions to use custom translator and define custom This allows extensions to use custom translator and define custom

View File

@ -1103,14 +1103,16 @@ class TexinfoTranslator(nodes.NodeVisitor):
def visit_caption(self, node): def visit_caption(self, node):
if (isinstance(node.parent, nodes.figure) or if (isinstance(node.parent, nodes.figure) or
(isinstance(node.parent, nodes.container) and node.parent.get('literal_block'))): (isinstance(node.parent, nodes.container) and
node.parent.get('literal_block'))):
self.body.append('\n@caption{') self.body.append('\n@caption{')
else: else:
self.builder.warn('caption not inside a figure.', self.builder.warn('caption not inside a figure.',
(self.curfilestack[-1], node.line)) (self.curfilestack[-1], node.line))
def depart_caption(self, node): def depart_caption(self, node):
if (isinstance(node.parent, nodes.figure) or if (isinstance(node.parent, nodes.figure) or
(isinstance(node.parent, nodes.container) and node.parent.get('literal_block'))): (isinstance(node.parent, nodes.container) and
node.parent.get('literal_block'))):
self.body.append('}\n') self.body.append('}\n')
def visit_image(self, node): def visit_image(self, node):

View File

@ -2,6 +2,6 @@
.. autosummary:: .. autosummary::
:nosignatures: :nosignatures:
:toctree: :toctree:
dummy_module dummy_module
sphinx sphinx

View File

@ -46,7 +46,7 @@ Referring to :func:`nothing <>`.
.. object:: long(parameter, \ .. object:: long(parameter, \
list) list)
another one another one
.. class:: TimeInt .. class:: TimeInt

View File

@ -58,7 +58,8 @@ def test_html_with_set_translator_for_html_(app, status, warning):
@with_app('html', testroot='api-set-translator', @with_app('html', testroot='api-set-translator',
confoverrides={'html_translator_class': 'ext.ExtHTMLTranslator'}) confoverrides={'html_translator_class': 'ext.ExtHTMLTranslator'})
def test_html_with_set_translator_for_html_and_html_translator_class(app, status, warning): def test_html_with_set_translator_for_html_and_html_translator_class(
app, status, warning):
# use set_translator() and html_translator_class. # use set_translator() and html_translator_class.
# set_translator() is given priority over html_translator_clas. # set_translator() is given priority over html_translator_clas.
translator_class = app.builder.translator_class translator_class = app.builder.translator_class

View File

@ -434,21 +434,25 @@ def test_docstring_property_processing():
return results, docstrings return results, docstrings
directive.env.config.autodoc_docstring_signature = False directive.env.config.autodoc_docstring_signature = False
results, docstrings = genarate_docstring('attribute', 'test_autodoc.DocstringSig.prop1') results, docstrings = \
genarate_docstring('attribute', 'test_autodoc.DocstringSig.prop1')
assert '.. py:attribute:: DocstringSig.prop1' in results assert '.. py:attribute:: DocstringSig.prop1' in results
assert 'First line of docstring' in docstrings assert 'First line of docstring' in docstrings
assert 'DocstringSig.prop1(self)' in docstrings assert 'DocstringSig.prop1(self)' in docstrings
results, docstrings = genarate_docstring('attribute', 'test_autodoc.DocstringSig.prop2') results, docstrings = \
genarate_docstring('attribute', 'test_autodoc.DocstringSig.prop2')
assert '.. py:attribute:: DocstringSig.prop2' in results assert '.. py:attribute:: DocstringSig.prop2' in results
assert 'First line of docstring' in docstrings assert 'First line of docstring' in docstrings
assert 'Second line of docstring' in docstrings assert 'Second line of docstring' in docstrings
directive.env.config.autodoc_docstring_signature = True directive.env.config.autodoc_docstring_signature = True
results, docstrings = genarate_docstring('attribute', 'test_autodoc.DocstringSig.prop1') results, docstrings = \
genarate_docstring('attribute', 'test_autodoc.DocstringSig.prop1')
assert '.. py:attribute:: DocstringSig.prop1' in results assert '.. py:attribute:: DocstringSig.prop1' in results
assert 'First line of docstring' in docstrings assert 'First line of docstring' in docstrings
assert 'DocstringSig.prop1(self)' not in docstrings assert 'DocstringSig.prop1(self)' not in docstrings
results, docstrings = genarate_docstring('attribute', 'test_autodoc.DocstringSig.prop2') results, docstrings = \
genarate_docstring('attribute', 'test_autodoc.DocstringSig.prop2')
assert '.. py:attribute:: DocstringSig.prop2' in results assert '.. py:attribute:: DocstringSig.prop2' in results
assert 'First line of docstring' in docstrings assert 'First line of docstring' in docstrings
assert 'Second line of docstring' in docstrings assert 'Second line of docstring' in docstrings

View File

@ -76,13 +76,21 @@ def test_build_all():
def test_circular_toctree(app, status, warning): def test_circular_toctree(app, status, warning):
app.builder.build_all() app.builder.build_all()
warnings = warning.getvalue() warnings = warning.getvalue()
assert 'circular toctree references detected, ignoring: sub <- contents <- sub' in warnings assert (
assert 'circular toctree references detected, ignoring: contents <- sub <- contents' in warnings 'circular toctree references detected, ignoring: '
'sub <- contents <- sub') in warnings
assert (
'circular toctree references detected, ignoring: '
'contents <- sub <- contents') in warnings
@with_app(buildername='text', testroot='numbered-circular') @with_app(buildername='text', testroot='numbered-circular')
def test_numbered_circular_toctree(app, status, warning): def test_numbered_circular_toctree(app, status, warning):
app.builder.build_all() app.builder.build_all()
warnings = warning.getvalue() warnings = warning.getvalue()
assert 'circular toctree references detected, ignoring: sub <- contents <- sub' in warnings assert (
assert 'circular toctree references detected, ignoring: contents <- sub <- contents' in warnings 'circular toctree references detected, ignoring: '
'sub <- contents <- sub') in warnings
assert (
'circular toctree references detected, ignoring: '
'contents <- sub <- contents') in warnings

View File

@ -66,8 +66,9 @@ def test_all(app, status, warning):
print(stderr) print(stderr)
assert False, 'msgfmt exited with return code %s' % \ assert False, 'msgfmt exited with return code %s' % \
p.returncode p.returncode
yield assert_true, (app.outdir / 'en' / 'LC_MESSAGES' / 'test_root.mo').isfile(), \ yield (assert_true,
'msgfmt failed' (app.outdir / 'en' / 'LC_MESSAGES' / 'test_root.mo').isfile(),
'msgfmt failed')
finally: finally:
os.chdir(cwd) os.chdir(cwd)

View File

@ -141,7 +141,8 @@ HTML_XPATH = {
(".//a[@href='http://www.python.org/dev/peps/pep-0008']" (".//a[@href='http://www.python.org/dev/peps/pep-0008']"
"[@class='pep reference external']/strong", 'PEP 8'), "[@class='pep reference external']/strong", 'PEP 8'),
(".//a[@href='http://www.python.org/dev/peps/pep-0008']" (".//a[@href='http://www.python.org/dev/peps/pep-0008']"
"[@class='pep reference external']/strong", 'Python Enhancement Proposal #8'), "[@class='pep reference external']/strong",
'Python Enhancement Proposal #8'),
(".//a[@href='http://tools.ietf.org/html/rfc1.html']" (".//a[@href='http://tools.ietf.org/html/rfc1.html']"
"[@class='rfc reference external']/strong", 'RFC 1'), "[@class='rfc reference external']/strong", 'RFC 1'),
(".//a[@href='http://tools.ietf.org/html/rfc1.html']" (".//a[@href='http://tools.ietf.org/html/rfc1.html']"

View File

@ -27,7 +27,8 @@ def parse(name, string):
def check(name, input, output=None): def check(name, input, output=None):
# first a simple check of the AST # first a simple check of the AST
if output == None: output = input if output is None:
output = input
ast = parse(name, input) ast = parse(name, input)
res = text_type(ast) res = text_type(ast)
if res != output: if res != output:
@ -36,7 +37,8 @@ def check(name, input, output=None):
print("Expected: ", output) print("Expected: ", output)
raise DefinitionError("") raise DefinitionError("")
ast.describe_signature([], 'lastIsName', None) ast.describe_signature([], 'lastIsName', None)
ast.prefixedName = ast.name # otherwise the get_id fails, it would be set in handle_signarue ast.prefixedName = ast.name # otherwise the get_id fails, it would be set
# in handle_signarue
ast.get_id() ast.get_id()
#print ".. %s:: %s" % (name, input) #print ".. %s:: %s" % (name, input)
@ -49,7 +51,7 @@ def test_type_definitions():
check("type", "bool *volatile const b") check("type", "bool *volatile const b")
check("type", "bool *volatile const *b") check("type", "bool *volatile const *b")
check("type", "bool &b") check("type", "bool &b")
check("type", "bool b[]") check("type", "bool b[]")
check("type", "std::pair<int, int> coord") check("type", "std::pair<int, int> coord")
check("type", "long long int foo") check("type", "long long int foo")
check("type", 'std::vector<std::pair<std::string, long long>> module::blah') check("type", 'std::vector<std::pair<std::string, long long>> module::blah')
@ -57,12 +59,20 @@ def test_type_definitions():
check("type", "std::function<R(A1, A2, A3)> F") check("type", "std::function<R(A1, A2, A3)> F")
check("type", "std::function<R(A1, A2, A3, As...)> F") check("type", "std::function<R(A1, A2, A3, As...)> F")
check("type", "MyContainer::const_iterator") check("type", "MyContainer::const_iterator")
check("type", "public MyContainer::const_iterator", "MyContainer::const_iterator") check("type",
"public MyContainer::const_iterator",
check('member', ' const std::string & name = 42', 'const std::string &name = 42') "MyContainer::const_iterator")
check('member',
' const std::string & name = 42',
'const std::string &name = 42')
check('member', ' const std::string & name', 'const std::string &name') check('member', ' const std::string & name', 'const std::string &name')
check('member', ' const std::string & name [ n ]', 'const std::string &name[n]') check('member',
check('member', 'const std::vector< unsigned int, long> &name', 'const std::vector<unsigned int, long> &name') ' const std::string & name [ n ]',
'const std::string &name[n]')
check('member',
'const std::vector< unsigned int, long> &name',
'const std::vector<unsigned int, long> &name')
check('member', 'module::myclass foo[n]') check('member', 'module::myclass foo[n]')
check('function', 'operator bool() const') check('function', 'operator bool() const')
@ -76,8 +86,10 @@ def test_type_definitions():
check('function', 'int foo(const unsigned int j)') check('function', 'int foo(const unsigned int j)')
check('function', 'int foo(const int *const ptr)') check('function', 'int foo(const int *const ptr)')
check('function', 'module::myclass::operator std::vector<std::string>()') check('function', 'module::myclass::operator std::vector<std::string>()')
check('function', 'void operator()(const boost::array<VertexID, 2> &v) const') check('function',
check('function', 'void operator()(const boost::array<VertexID, 2, "foo, bar"> &v) const') 'void operator()(const boost::array<VertexID, 2> &v) const')
check('function',
'void operator()(const boost::array<VertexID, 2, "foo, bar"> &v) const')
check('function', 'MyClass::MyClass(MyClass::MyClass&&)') check('function', 'MyClass::MyClass(MyClass::MyClass&&)')
check('function', 'constexpr int get_value()') check('function', 'constexpr int get_value()')
check('function', 'static constexpr int get_value()') check('function', 'static constexpr int get_value()')
@ -101,7 +113,8 @@ def test_type_definitions():
x = 'std::vector<std::pair<std::string, int>> &module::test(register ' \ x = 'std::vector<std::pair<std::string, int>> &module::test(register ' \
'foo, bar[n], std::string baz = "foobar, blah, bleh") const = 0' 'foo, bar[n], std::string baz = "foobar, blah, bleh") const = 0'
check('function', x) check('function', x)
check('function', 'int foo(Foo f = Foo(double(), std::make_pair(int(2), double(3.4))))') check('function',
'int foo(Foo f = Foo(double(), std::make_pair(int(2), double(3.4))))')
check('function', 'int foo(A a = x(a))') check('function', 'int foo(A a = x(a))')
raises(DefinitionError, parse, 'function', 'int foo(B b=x(a)') raises(DefinitionError, parse, 'function', 'int foo(B b=x(a)')
raises(DefinitionError, parse, 'function', 'int foo)C c=x(a))') raises(DefinitionError, parse, 'function', 'int foo)C c=x(a))')