Rename Config.read() to Config.from_conf_py()

This commit is contained in:
Takeshi KOMIYA 2018-04-01 20:07:45 +09:00
parent a24601aa24
commit bc63dc8450
5 changed files with 10 additions and 10 deletions

View File

@ -56,7 +56,7 @@ Features added
* helper function ``warning()`` for HTML themes is added * helper function ``warning()`` for HTML themes is added
* Add ``Domain.enumerable_nodes`` to manage own enumerable nodes for domains * Add ``Domain.enumerable_nodes`` to manage own enumerable nodes for domains
(experimental) (experimental)
* Add ``Config.read()`` classmethod to create a new config object from * Add ``Config.from_conf_py()`` classmethod to create a new config object from
configuration file configuration file
Bugs fixed Bugs fixed

View File

@ -127,7 +127,7 @@ The following is a list of deprecated interface.
``Config.__init__()`` ``Config.__init__()``
- 1.8 - 1.8
- 3.0 - 3.0
- ``Config.read()`` - ``Config.from_conf_py()``
* - ``BuildEnvironment._nitpick_ignore`` * - ``BuildEnvironment._nitpick_ignore``
- 1.8 - 1.8

View File

@ -188,8 +188,8 @@ class Sphinx(object):
if self.confdir is None: if self.confdir is None:
self.config = Config({}, confoverrides or {}) self.config = Config({}, confoverrides or {})
else: else:
self.config = Config.read(path.join(self.confdir, CONFIG_FILENAME), self.config = Config.from_conf_py(path.join(self.confdir, CONFIG_FILENAME),
confoverrides or {}, self.tags) confoverrides or {}, self.tags)
check_unicode(self.config) check_unicode(self.config)
# initialize some limited config variables before initialize i18n and loading # initialize some limited config variables before initialize i18n and loading

View File

@ -152,7 +152,7 @@ class Config(object):
if len(args) == 4: if len(args) == 4:
# old style arguments: (dirname, filename, overrides, tags) # old style arguments: (dirname, filename, overrides, tags)
warnings.warn('The argument of Config() class has been changed. ' warnings.warn('The argument of Config() class has been changed. '
'Use Config.read() to read configuration from conf.py.', 'Use Config.from_conf_py() to read configuration from conf.py.',
RemovedInSphinx30Warning) RemovedInSphinx30Warning)
dirname, filename, overrides, tags = args dirname, filename, overrides, tags = args
if dirname is None: if dirname is None:
@ -181,7 +181,7 @@ class Config(object):
self.extensions = config.get('extensions', []) # type: List[unicode] self.extensions = config.get('extensions', []) # type: List[unicode]
@classmethod @classmethod
def read(cls, filename, overrides=None, tags=None): def from_conf_py(cls, filename, overrides=None, tags=None):
# type: (unicode, Dict, Tags) -> Config # type: (unicode, Dict, Tags) -> Config
"""Create a Config object from configuration file.""" """Create a Config object from configuration file."""
namespace = eval_config_file(filename, tags) namespace = eval_config_file(filename, tags)

View File

@ -124,14 +124,14 @@ def test_errors_warnings(logger, tempdir):
# test the error for syntax errors in the config file # test the error for syntax errors in the config file
(tempdir / 'conf.py').write_text(u'project = \n', encoding='ascii') (tempdir / 'conf.py').write_text(u'project = \n', encoding='ascii')
with pytest.raises(ConfigError) as excinfo: with pytest.raises(ConfigError) as excinfo:
Config.read(tempdir / 'conf.py', {}, None) Config.from_conf_py(tempdir / 'conf.py', {}, None)
assert 'conf.py' in str(excinfo.value) assert 'conf.py' in str(excinfo.value)
# test the automatic conversion of 2.x only code in configs # test the automatic conversion of 2.x only code in configs
(tempdir / 'conf.py').write_text( (tempdir / 'conf.py').write_text(
u'# -*- coding: utf-8\n\nproject = u"Jägermeister"\n', u'# -*- coding: utf-8\n\nproject = u"Jägermeister"\n',
encoding='utf-8') encoding='utf-8')
cfg = Config.read(tempdir / 'conf.py', {}, None) cfg = Config.from_conf_py(tempdir / 'conf.py', {}, None)
cfg.init_values() cfg.init_values()
assert cfg.project == u'Jägermeister' assert cfg.project == u'Jägermeister'
assert logger.called is False assert logger.called is False
@ -143,7 +143,7 @@ def test_errors_warnings(logger, tempdir):
return return
(tempdir / 'conf.py').write_text( (tempdir / 'conf.py').write_text(
u'# -*- coding: latin-1\nproject = "fooä"\n', encoding='latin-1') u'# -*- coding: latin-1\nproject = "fooä"\n', encoding='latin-1')
cfg = Config.read(tempdir / 'conf.py', {}, None) cfg = Config.from_conf_py(tempdir / 'conf.py', {}, None)
assert logger.warning.called is False assert logger.warning.called is False
cfg.check_unicode() cfg.check_unicode()
@ -202,7 +202,7 @@ def test_config_eol(logger, tempdir):
configfile = tempdir / 'conf.py' configfile = tempdir / 'conf.py'
for eol in (b'\n', b'\r\n'): for eol in (b'\n', b'\r\n'):
configfile.write_bytes(b'project = "spam"' + eol) configfile.write_bytes(b'project = "spam"' + eol)
cfg = Config.read(tempdir / 'conf.py', {}, None) cfg = Config.from_conf_py(tempdir / 'conf.py', {}, None)
cfg.init_values() cfg.init_values()
assert cfg.project == u'spam' assert cfg.project == u'spam'
assert logger.called is False assert logger.called is False