From bc63dc845002a74bc82e5b519e318afe39198dcb Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 1 Apr 2018 20:07:45 +0900 Subject: [PATCH] Rename Config.read() to Config.from_conf_py() --- CHANGES | 2 +- doc/extdev/index.rst | 2 +- sphinx/application.py | 4 ++-- sphinx/config.py | 4 ++-- tests/test_config.py | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index cb94800ec..e7e191f15 100644 --- a/CHANGES +++ b/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 diff --git a/doc/extdev/index.rst b/doc/extdev/index.rst index 192f6891a..7ca0c6f2e 100644 --- a/doc/extdev/index.rst +++ b/doc/extdev/index.rst @@ -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 diff --git a/sphinx/application.py b/sphinx/application.py index eaa5f8ccd..d84301dd6 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -188,8 +188,8 @@ class Sphinx(object): if self.confdir is None: self.config = Config({}, confoverrides or {}) else: - self.config = Config.read(path.join(self.confdir, CONFIG_FILENAME), - confoverrides or {}, self.tags) + self.config = Config.from_conf_py(path.join(self.confdir, CONFIG_FILENAME), + confoverrides or {}, self.tags) check_unicode(self.config) # initialize some limited config variables before initialize i18n and loading diff --git a/sphinx/config.py b/sphinx/config.py index d1ef82ee4..33f09a85e 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -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) diff --git a/tests/test_config.py b/tests/test_config.py index 7f27e3ff0..078a05a2a 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -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