mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
ENH: Explain rebuilds
This commit is contained in:
parent
bbc11a059f
commit
c0e46adc07
@ -388,9 +388,11 @@ class Builder:
|
|||||||
# ... but not those that already were removed
|
# ... but not those that already were removed
|
||||||
changed.update(self.env.glob_toctrees & self.env.found_docs)
|
changed.update(self.env.glob_toctrees & self.env.found_docs)
|
||||||
|
|
||||||
if changed:
|
if updated: # explain the change iff build config status was not ok
|
||||||
reason = CONFIG_CHANGED_REASON.get(self.env.config_status, '')
|
reason = (CONFIG_CHANGED_REASON.get(self.env.config_status, '') +
|
||||||
|
(self.env.config_status_extra or ''))
|
||||||
logger.info('[%s] ', reason, nonl=True)
|
logger.info('[%s] ', reason, nonl=True)
|
||||||
|
|
||||||
logger.info(__('%s added, %s changed, %s removed'),
|
logger.info(__('%s added, %s changed, %s removed'),
|
||||||
len(added), len(changed), len(removed))
|
len(added), len(changed), len(removed))
|
||||||
|
|
||||||
|
@ -95,14 +95,15 @@ class BuildEnvironment:
|
|||||||
# --------- ENVIRONMENT INITIALIZATION -------------------------------------
|
# --------- ENVIRONMENT INITIALIZATION -------------------------------------
|
||||||
|
|
||||||
def __init__(self, app: "Sphinx" = None):
|
def __init__(self, app: "Sphinx" = None):
|
||||||
self.app = None # type: Sphinx
|
self.app = None # type: Sphinx
|
||||||
self.doctreedir = None # type: str
|
self.doctreedir = None # type: str
|
||||||
self.srcdir = None # type: str
|
self.srcdir = None # type: str
|
||||||
self.config = None # type: Config
|
self.config = None # type: Config
|
||||||
self.config_status = None # type: int
|
self.config_status = None # type: int
|
||||||
self.events = None # type: EventManager
|
self.config_status_extra = None # type: str
|
||||||
self.project = None # type: Project
|
self.events = None # type: EventManager
|
||||||
self.version = None # type: Dict[str, str]
|
self.project = None # type: Project
|
||||||
|
self.version = None # type: Dict[str, str]
|
||||||
|
|
||||||
# the method of doctree versioning; see set_versioning_method
|
# the method of doctree versioning; see set_versioning_method
|
||||||
self.versioning_condition = None # type: Union[bool, Callable]
|
self.versioning_condition = None # type: Union[bool, Callable]
|
||||||
@ -232,16 +233,25 @@ class BuildEnvironment:
|
|||||||
def _update_config(self, config: Config) -> None:
|
def _update_config(self, config: Config) -> None:
|
||||||
"""Update configurations by new one."""
|
"""Update configurations by new one."""
|
||||||
self.config_status = CONFIG_OK
|
self.config_status = CONFIG_OK
|
||||||
|
self.config_status_extra = ''
|
||||||
if self.config is None:
|
if self.config is None:
|
||||||
self.config_status = CONFIG_NEW
|
self.config_status = CONFIG_NEW
|
||||||
elif self.config.extensions != config.extensions:
|
elif self.config.extensions != config.extensions:
|
||||||
self.config_status = CONFIG_EXTENSIONS_CHANGED
|
self.config_status = CONFIG_EXTENSIONS_CHANGED
|
||||||
|
extensions = sorted(
|
||||||
|
set(self.config.extensions) ^ set(config.extensions))
|
||||||
|
if len(extensions) == 1:
|
||||||
|
extension = extensions[0]
|
||||||
|
else:
|
||||||
|
extension = '%d' % (len(extensions),)
|
||||||
|
self.config_status_extra = ' (%r)' % (extension,)
|
||||||
else:
|
else:
|
||||||
# check if a config value was changed that affects how
|
# check if a config value was changed that affects how
|
||||||
# doctrees are read
|
# doctrees are read
|
||||||
for item in config.filter('env'):
|
for item in config.filter('env'):
|
||||||
if self.config[item.name] != item.value:
|
if self.config[item.name] != item.value:
|
||||||
self.config_status = CONFIG_CHANGED
|
self.config_status = CONFIG_CHANGED
|
||||||
|
self.config_status_extra = ' (%r)' % (item.name,)
|
||||||
break
|
break
|
||||||
|
|
||||||
self.config = config
|
self.config = config
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
:copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
|
||||||
:license: BSD, see LICENSE for details.
|
:license: BSD, see LICENSE for details.
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from sphinx.builders.html import StandaloneHTMLBuilder
|
from sphinx.builders.html import StandaloneHTMLBuilder
|
||||||
@ -23,18 +25,30 @@ def test_config_status(make_app, app_params):
|
|||||||
app1 = make_app(*args, freshenv=True, **kwargs)
|
app1 = make_app(*args, freshenv=True, **kwargs)
|
||||||
assert app1.env.config_status == CONFIG_NEW
|
assert app1.env.config_status == CONFIG_NEW
|
||||||
app1.build()
|
app1.build()
|
||||||
|
assert '[new config] 1 added' in app1._status.getvalue()
|
||||||
|
|
||||||
# incremental build (no config changed)
|
# incremental build (no config changed)
|
||||||
app2 = make_app(*args, **kwargs)
|
app2 = make_app(*args, **kwargs)
|
||||||
assert app2.env.config_status == CONFIG_OK
|
assert app2.env.config_status == CONFIG_OK
|
||||||
|
app2.build()
|
||||||
|
assert "0 added, 0 changed, 0 removed" in app2._status.getvalue()
|
||||||
|
|
||||||
# incremental build (config entry changed)
|
# incremental build (config entry changed)
|
||||||
app3 = make_app(*args, confoverrides={'master_doc': 'content'}, **kwargs)
|
app3 = make_app(*args, confoverrides={'master_doc': 'indexx'}, **kwargs)
|
||||||
|
fname = os.path.join(app3.srcdir, 'index.rst')
|
||||||
|
assert os.path.isfile(fname)
|
||||||
|
shutil.move(fname, fname[:-4] + 'x.rst')
|
||||||
assert app3.env.config_status == CONFIG_CHANGED
|
assert app3.env.config_status == CONFIG_CHANGED
|
||||||
|
app3.build()
|
||||||
|
shutil.move(fname[:-4] + 'x.rst', fname)
|
||||||
|
assert "[config changed ('master_doc')] 1 added" in app3._status.getvalue()
|
||||||
|
|
||||||
# incremental build (extension changed)
|
# incremental build (extension changed)
|
||||||
app4 = make_app(*args, confoverrides={'extensions': ['sphinx.ext.autodoc']}, **kwargs)
|
app4 = make_app(*args, confoverrides={'extensions': ['sphinx.ext.autodoc']}, **kwargs)
|
||||||
assert app4.env.config_status == CONFIG_EXTENSIONS_CHANGED
|
assert app4.env.config_status == CONFIG_EXTENSIONS_CHANGED
|
||||||
|
app4.build()
|
||||||
|
want_str = "[extensions changed ('sphinx.ext.autodoc')] 1 added"
|
||||||
|
assert want_str in app4._status.getvalue()
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sphinx('dummy')
|
@pytest.mark.sphinx('dummy')
|
||||||
|
Loading…
Reference in New Issue
Block a user