diff --git a/CHANGES b/CHANGES index c15cd0b93..33b6deb84 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,20 @@ Release 1.3 (in development) ============================ +Bugs fixed +---------- + +* #1335: Fix autosummary template overloading with exclamation prefix like + ``{% extends "!autosummary/class.rst" %}`` cause infinite recursive function + call. This caused by PR#181. + +* #1337: Fix autodoc with ``autoclass_content="both"`` uses useless + ``object.__init__`` docstring when class does not have ``__init__``. + This caused by a change for #1138. + +* #1340: Can't search alphabetical words on the HTML quick search generated + with language='ja'. + Release 1.2 (released Dec 10, 2013) =================================== @@ -22,8 +36,10 @@ Bugs fixed * Restore ``versionmodified`` CSS class for versionadded/changed and deprecated directives. -* Fix: `html_theme_path=['.']` is a trigger of rebuild all documents always - (This change keeps the current "theme changes cause a rebuild" feature). + +* PR#181: Fix `html_theme_path=['.']` is a trigger of rebuild all documents + always (This change keeps the current "theme changes cause a rebuild" + feature). * #1296: Fix invalid charset in HTML help generated HTML files for default locale. diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 8d78feb21..67b6fe4ee 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -1084,7 +1084,7 @@ class ClassDocumenter(ModuleLevelDocumenter): initdocstring = self.get_attr( self.get_attr(self.object, '__init__', None), '__doc__') # for new-style classes, no __init__ means default __init__ - if initdocstring == object.__init__.__doc__: + if initdocstring.strip() == object.__init__.__doc__.strip(): initdocstring = None if initdocstring: if content == 'init': diff --git a/sphinx/jinja2glue.py b/sphinx/jinja2glue.py index 300cfef6e..a298d2eaf 100644 --- a/sphinx/jinja2glue.py +++ b/sphinx/jinja2glue.py @@ -95,9 +95,11 @@ class BuiltinTemplateLoader(TemplateBridge, BaseLoader): # then the theme parent paths loaderchain = pathchain + theme.themepath elif dirs: - pathchain = loaderchain = list(dirs) + pathchain = list(dirs) + loaderchain = list(dirs) else: - pathchain = loaderchain = [] + pathchain = [] + loaderchain = [] # prepend explicit template paths self.templatepathlen = len(builder.config.templates_path) diff --git a/sphinx/search/ja.py b/sphinx/search/ja.py index f0deb154e..099f4717d 100644 --- a/sphinx/search/ja.py +++ b/sphinx/search/ja.py @@ -236,7 +236,7 @@ class TinySegmenter(object): score += self.ts_(self.TQ4__, p3 + c2 + c3 + c4) p = u'O' if score > 0: - result.append(word) + result.append(word.strip()) word = u'' p = u'B' p1 = p2 @@ -244,7 +244,7 @@ class TinySegmenter(object): p3 = p word += seg[i] - result.append(word) + result.append(word.strip()) return result diff --git a/tests/roots/test-templating/_templates/autosummary/class.rst b/tests/roots/test-templating/_templates/autosummary/class.rst new file mode 100644 index 000000000..7f1536173 --- /dev/null +++ b/tests/roots/test-templating/_templates/autosummary/class.rst @@ -0,0 +1,8 @@ +{% extends "!autosummary/class.rst" %} + +{% block methods %} + + .. note:: autosummary/class.rst method block overloading + + {{ super() }} +{% endblock %} diff --git a/tests/roots/test-templating/_templates/layout.html b/tests/roots/test-templating/_templates/layout.html new file mode 100644 index 000000000..f836c7737 --- /dev/null +++ b/tests/roots/test-templating/_templates/layout.html @@ -0,0 +1,6 @@ +{% extends "!layout.html" %} + +{% block extrahead %} + +{{ super() }} +{% endblock %} diff --git a/tests/roots/test-templating/autosummary_templating.txt b/tests/roots/test-templating/autosummary_templating.txt new file mode 100644 index 000000000..05643a02d --- /dev/null +++ b/tests/roots/test-templating/autosummary_templating.txt @@ -0,0 +1,13 @@ +Autosummary templating test +=========================== + +.. autosummary:: + :toctree: generated + + sphinx.application.Sphinx + +.. currentmodule:: sphinx.application + +.. autoclass:: TemplateBridge + + .. automethod:: render diff --git a/tests/roots/test-templating/conf.py b/tests/roots/test-templating/conf.py new file mode 100644 index 000000000..225da82e7 --- /dev/null +++ b/tests/roots/test-templating/conf.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- + +project = 'Sphinx templating ' +source_suffix = '.txt' +keep_warnings = True +templates_path = ['_templates'] +release = version = '2013.120' + +extensions = ['sphinx.ext.autosummary'] +autosummary_generate = ['autosummary_templating'] + diff --git a/tests/roots/test-templating/contents.txt b/tests/roots/test-templating/contents.txt new file mode 100644 index 000000000..04a40e21c --- /dev/null +++ b/tests/roots/test-templating/contents.txt @@ -0,0 +1,7 @@ +Welcome to Sphinx Tests's documentation! +======================================== + +.. toctree:: + + autosummary_templating + diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 63c341f1b..3735a7b68 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -334,6 +334,20 @@ def test_get_doc(): directive.env.config.autoclass_content = 'both' assert getdocl('class', E) == ['Class docstring', '', 'Init docstring'] + # class does not have __init__ method + class F(object): + """Class docstring""" + + # docstring in the __init__ method of base class will be discard + for f in (False, True): + directive.env.config.autodoc_docstring_signature = f + directive.env.config.autoclass_content = 'class' + assert getdocl('class', F) == ['Class docstring'] + directive.env.config.autoclass_content = 'init' + assert getdocl('class', F) == ['Class docstring'] + directive.env.config.autoclass_content = 'both' + assert getdocl('class', F) == ['Class docstring'] + @with_setup(setup_test) def test_docstring_processing(): diff --git a/tests/test_templating.py b/tests/test_templating.py new file mode 100644 index 000000000..025d6fd07 --- /dev/null +++ b/tests/test_templating.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +""" + test_templating + ~~~~~~~~~~~~~~~~ + + Test templating. + + :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" + +from util import test_roots, with_app + + +def teardown_module(): + (test_roots / 'test-templating' / '_build').rmtree(True), + + +@with_app(buildername='html', srcdir=(test_roots / 'test-templating')) +def test_layout_overloading(app): + app.builder.build_all() + + result = (app.outdir / 'contents.html').text(encoding='utf-8') + + assert '' in result + + +@with_app(buildername='html', srcdir=(test_roots / 'test-templating')) +def test_autosummary_class_template_overloading(app): + app.builder.build_all() + + result = (app.outdir / 'generated' / 'sphinx.application.Sphinx.html').text( + encoding='utf-8') + + assert 'autosummary/class.rst method block overloading' in result +