mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #5619 from tk0miya/5614_broken_incremental_build
Fix #5614: autodoc: incremental build is broken when builtin modules …
This commit is contained in:
commit
a0aee7a0f3
1
CHANGES
1
CHANGES
@ -17,6 +17,7 @@ Bugs fixed
|
||||
----------
|
||||
|
||||
* #5460: html search does not work with some 3rd party themes
|
||||
* #5614: autodoc: incremental build is broken when builtin modules are imported
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
@ -301,7 +301,9 @@ def get_module_source(modname):
|
||||
raise PycodeError('error getting filename for %r' % filename, err)
|
||||
if filename is None and loader:
|
||||
try:
|
||||
return 'string', loader.get_source(modname)
|
||||
filename = loader.get_source(modname)
|
||||
if filename:
|
||||
return 'string', filename
|
||||
except Exception as err:
|
||||
raise PycodeError('error getting source for %r' % modname, err)
|
||||
if filename is None:
|
||||
|
@ -12,9 +12,14 @@
|
||||
import pytest
|
||||
from mock import patch
|
||||
|
||||
from six import PY2
|
||||
|
||||
import sphinx
|
||||
from sphinx.errors import PycodeError
|
||||
from sphinx.testing.util import strip_escseq
|
||||
from sphinx.util import (
|
||||
display_chunk, encode_uri, parselinenos, status_iterator, xmlname_checker
|
||||
display_chunk, encode_uri, get_module_source, parselinenos, status_iterator,
|
||||
xmlname_checker
|
||||
)
|
||||
from sphinx.util import logging
|
||||
|
||||
@ -42,6 +47,19 @@ def test_display_chunk():
|
||||
assert display_chunk(('hello', 'sphinx', 'world')) == 'hello .. world'
|
||||
|
||||
|
||||
def test_get_module_source():
|
||||
if PY2:
|
||||
assert get_module_source('sphinx') == ('file', sphinx.__file__.replace('.pyc', '.py'))
|
||||
else:
|
||||
assert get_module_source('sphinx') == ('file', sphinx.__file__)
|
||||
|
||||
# failed to obtain source information from builtin modules
|
||||
with pytest.raises(PycodeError):
|
||||
get_module_source('builtins')
|
||||
with pytest.raises(PycodeError):
|
||||
get_module_source('itertools')
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy')
|
||||
@patch('sphinx.util.console._tw', 40) # terminal width = 40
|
||||
def test_status_iterator(app, status, warning):
|
||||
|
Loading…
Reference in New Issue
Block a user