mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Rename Config.read() to Config.from_conf_py()
This commit is contained in:
parent
a24601aa24
commit
bc63dc8450
2
CHANGES
2
CHANGES
@ -56,7 +56,7 @@ Features added
|
||||
* helper function ``warning()`` for HTML themes is added
|
||||
* Add ``Domain.enumerable_nodes`` to manage own enumerable nodes for domains
|
||||
(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
|
||||
|
||||
Bugs fixed
|
||||
|
@ -127,7 +127,7 @@ The following is a list of deprecated interface.
|
||||
``Config.__init__()``
|
||||
- 1.8
|
||||
- 3.0
|
||||
- ``Config.read()``
|
||||
- ``Config.from_conf_py()``
|
||||
|
||||
* - ``BuildEnvironment._nitpick_ignore``
|
||||
- 1.8
|
||||
|
@ -188,7 +188,7 @@ class Sphinx(object):
|
||||
if self.confdir is None:
|
||||
self.config = Config({}, confoverrides or {})
|
||||
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)
|
||||
check_unicode(self.config)
|
||||
|
||||
|
@ -152,7 +152,7 @@ class Config(object):
|
||||
if len(args) == 4:
|
||||
# old style arguments: (dirname, filename, overrides, tags)
|
||||
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)
|
||||
dirname, filename, overrides, tags = args
|
||||
if dirname is None:
|
||||
@ -181,7 +181,7 @@ class Config(object):
|
||||
self.extensions = config.get('extensions', []) # type: List[unicode]
|
||||
|
||||
@classmethod
|
||||
def read(cls, filename, overrides=None, tags=None):
|
||||
def from_conf_py(cls, filename, overrides=None, tags=None):
|
||||
# type: (unicode, Dict, Tags) -> Config
|
||||
"""Create a Config object from configuration file."""
|
||||
namespace = eval_config_file(filename, tags)
|
||||
|
@ -124,14 +124,14 @@ def test_errors_warnings(logger, tempdir):
|
||||
# test the error for syntax errors in the config file
|
||||
(tempdir / 'conf.py').write_text(u'project = \n', encoding='ascii')
|
||||
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)
|
||||
|
||||
# test the automatic conversion of 2.x only code in configs
|
||||
(tempdir / 'conf.py').write_text(
|
||||
u'# -*- coding: utf-8\n\nproject = u"Jägermeister"\n',
|
||||
encoding='utf-8')
|
||||
cfg = Config.read(tempdir / 'conf.py', {}, None)
|
||||
cfg = Config.from_conf_py(tempdir / 'conf.py', {}, None)
|
||||
cfg.init_values()
|
||||
assert cfg.project == u'Jägermeister'
|
||||
assert logger.called is False
|
||||
@ -143,7 +143,7 @@ def test_errors_warnings(logger, tempdir):
|
||||
return
|
||||
(tempdir / 'conf.py').write_text(
|
||||
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
|
||||
cfg.check_unicode()
|
||||
@ -202,7 +202,7 @@ def test_config_eol(logger, tempdir):
|
||||
configfile = tempdir / 'conf.py'
|
||||
for eol in (b'\n', b'\r\n'):
|
||||
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()
|
||||
assert cfg.project == u'spam'
|
||||
assert logger.called is False
|
||||
|
Loading…
Reference in New Issue
Block a user