Merge pull request #6095 from tk0miya/refactor_build_specific2

Ignore filenames without file extensions given to ``Builder.build_specific()``
This commit is contained in:
Takeshi KOMIYA 2019-02-27 15:31:45 +09:00 committed by GitHub
commit b41e8a7025
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 2 deletions

View File

@ -7,6 +7,9 @@ Dependencies
Incompatible changes
--------------------
* Ignore filenames without file extension given to ``Builder.build_specific()``
API directly
Deprecated
----------

View File

@ -298,8 +298,7 @@ class Builder:
logger.warning(__('file %r given on command line is not under the '
'source directory, ignoring'), filename)
continue
if not (path.isfile(filename) or
any(path.isfile(filename + suffix) for suffix in suffixes)):
if not path.isfile(filename):
logger.warning(__('file %r given on command line does not exist, '
'ignoring'), filename)
continue

View File

@ -7,6 +7,9 @@
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from unittest.mock import Mock
import pytest
from docutils import nodes
@ -113,3 +116,22 @@ def test_add_is_parallel_allowed(app, status, warning):
"for parallel reading, assuming it isn't - please ") in warning.getvalue()
app.extensions.pop('write_serial')
warning.truncate(0) # reset warnings
@pytest.mark.sphinx('dummy', testroot='root')
def test_build_specific(app):
app.builder.build = Mock()
filenames = [app.srcdir / 'index.txt', # normal
app.srcdir / 'images', # without suffix
app.srcdir / 'notfound.txt', # not found
app.srcdir / 'img.png', # unknown suffix
'/index.txt', # external file
app.srcdir / 'subdir', # directory
app.srcdir / 'subdir/includes.txt', # file on subdir
app.srcdir / 'subdir/../subdir/excluded.txt'] # not normalized
app.build(False, filenames)
expected = ['index', 'img.png', 'subdir/includes', 'subdir/excluded']
app.builder.build.assert_called_with(expected,
method='specific',
summary='4 source files given on command line')