Merge branch '2.0'

This commit is contained in:
Takeshi KOMIYA 2019-06-29 01:51:53 +09:00
commit 66e66d5cf9
7 changed files with 49 additions and 19 deletions

View File

@ -52,6 +52,7 @@ Features added
* #5124: graphviz: ``:graphviz_dot:`` option is renamed to ``:layout:``
* #1464: html: emit a warning if :confval:`html_static_path` and
:confval:`html_extra_path` directories are inside output directory
* #6514: html: Add a label to search input for accessability purposes
* #5602: apidoc: Add ``--templatedir`` option
Bugs fixed
@ -64,6 +65,8 @@ Bugs fixed
* #5502: linkcheck: Consider HTTP 503 response as not an error
* #6439: Make generated download links reproducible
* #6486: UnboundLocalError is raised if broken extension installed
* #6498: autosummary: crashed with wrong autosummary_generate setting
* #6507: autosummary: crashes without no autosummary_generate setting
Testing
--------

View File

@ -47,7 +47,7 @@ extras_require = {
'html5lib',
'flake8>=3.5.0',
'flake8-import-order',
'mypy>=0.710',
'mypy>=0.711',
'docutils-stubs',
],
}

View File

@ -157,7 +157,7 @@ def create_package_file(root, master_package, subroot, py_files, opts, subs,
if submodules and opts.separatemodules:
for submodule in submodules:
create_module_file(None, submodule, opts)
create_module_file(None, submodule, opts, user_template_dir)
def create_modules_toc_file(modules, opts, name='modules', user_template_dir=None):

View File

@ -58,6 +58,7 @@ import posixpath
import re
import sys
import warnings
from os import path
from types import ModuleType
from typing import List, cast
@ -256,19 +257,26 @@ class Autosummary(SphinxDirective):
docname = posixpath.join(tree_prefix, real_name)
docname = posixpath.normpath(posixpath.join(dirname, docname))
if docname not in self.env.found_docs:
location = self.state_machine.get_source_and_line(self.lineno)
if excluded(self.env.doc2path(docname, None)):
logger.warning(__('toctree references excluded document %r'), docname)
msg = __('autosummary references excluded document %r. Ignored.')
else:
logger.warning(__('toctree references unknown document %r'), docname)
msg = __('autosummary: stub file not found %r. '
'Check your autosummary_generate setting.')
logger.warning(msg, real_name, location=location)
continue
docnames.append(docname)
tocnode = addnodes.toctree()
tocnode['includefiles'] = docnames
tocnode['entries'] = [(None, docn) for docn in docnames]
tocnode['maxdepth'] = -1
tocnode['glob'] = None
if docnames:
tocnode = addnodes.toctree()
tocnode['includefiles'] = docnames
tocnode['entries'] = [(None, docn) for docn in docnames]
tocnode['maxdepth'] = -1
tocnode['glob'] = None
nodes.append(autosummary_toc('', '', tocnode))
nodes.append(autosummary_toc('', '', tocnode))
return nodes
@ -731,26 +739,31 @@ def process_generate_options(app):
# type: (Sphinx) -> None
genfiles = app.config.autosummary_generate
if genfiles and not hasattr(genfiles, '__len__'):
if genfiles is True:
env = app.builder.env
genfiles = [env.doc2path(x, base=None) for x in env.found_docs
if os.path.isfile(env.doc2path(x))]
else:
ext = list(app.config.source_suffix)
genfiles = [genfile + (not genfile.endswith(tuple(ext)) and ext[0] or '')
for genfile in genfiles]
for entry in genfiles[:]:
if not path.isfile(path.join(app.srcdir, entry)):
logger.warning(__('autosummary_generate: file not found: %s'), entry)
genfiles.remove(entry)
if not genfiles:
return
from sphinx.ext.autosummary.generate import generate_autosummary_docs
ext = list(app.config.source_suffix)
genfiles = [genfile + (not genfile.endswith(tuple(ext)) and ext[0] or '')
for genfile in genfiles]
suffix = get_rst_suffix(app)
if suffix is None:
logger.warning(__('autosummary generats .rst files internally. '
'But your source_suffix does not contain .rst. Skipped.'))
return
from sphinx.ext.autosummary.generate import generate_autosummary_docs
imported_members = app.config.autosummary_imported_members
with mock(app.config.autosummary_mock_imports):
generate_autosummary_docs(genfiles, builder=app.builder,

View File

@ -33,7 +33,7 @@
containing fewer words won't appear in the result list.{% endtrans %}
</p>
<form action="" method="get">
<input type="text" name="q" value="" />
<input type="text" name="q" aria-labelledby="search-documentation" value="" />
<input type="submit" value="{{ _('search') }}" />
<span id="search-progress" style="padding-left: 10px"></span>
</form>

View File

@ -121,7 +121,7 @@ def isenumattribute(x: Any) -> bool:
def ispartial(obj: Any) -> bool:
"""Check if the object is partial."""
return isinstance(obj, (partial, partialmethod)) # type: ignore
return isinstance(obj, (partial, partialmethod))
def isclassmethod(obj: Any) -> bool:

View File

@ -302,3 +302,17 @@ def test_generate_autosummary_docs_property(app):
".. currentmodule:: target.methods\n"
"\n"
".. autoproperty:: Base.prop")
@pytest.mark.sphinx('dummy', testroot='ext-autosummary',
confoverrides={'autosummary_generate': []})
def test_empty_autosummary_generate(app, status, warning):
app.build()
assert ("WARNING: autosummary: stub file not found 'autosummary_importfail'"
in warning.getvalue())
@pytest.mark.sphinx('dummy', testroot='ext-autosummary',
confoverrides={'autosummary_generate': ['unknown']})
def test_invalid_autosummary_generate(app, status, warning):
assert 'WARNING: autosummary_generate: file not found: unknown.rst' in warning.getvalue()