diff options
author | Georg Brandl <georg@python.org> | 2014-03-01 08:18:23 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-03-01 08:18:23 +0100 |
commit | 2f950d546d7304e7b9d6592d27b47f82b3a424ad (patch) | |
tree | 54b9419c78a5f725508241c48a1ca731ee9317fa /sphinx/config.py | |
parent | 3c649bfde0126d72894989506c40bb8ae35d7d23 (diff) | |
parent | 4047fe8184c2984241b92754b6e6d6b639b8d09b (diff) | |
download | sphinx-2f950d546d7304e7b9d6592d27b47f82b3a424ad.tar.gz |
Update copyright year.
Diffstat (limited to 'sphinx/config.py')
-rw-r--r-- | sphinx/config.py | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/sphinx/config.py b/sphinx/config.py index a4fc234a..3725e49c 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -51,10 +51,6 @@ class Config(object): source_suffix = ('.rst', 'env'), source_encoding = ('utf-8-sig', 'env'), exclude_patterns = ([], 'env'), - # the next three are all deprecated now - unused_docs = ([], 'env'), - exclude_trees = ([], 'env'), - exclude_dirnames = ([], 'env'), default_role = (None, 'env'), add_function_parentheses = (True, 'env'), add_module_names = (True, 'env'), @@ -214,8 +210,11 @@ class Config(object): self.overrides = overrides self.values = Config.config_values.copy() config = {} - if "extensions" in overrides: - config["extensions"] = overrides["extensions"] + if 'extensions' in overrides: + if isinstance(overrides['extensions'], (str, unicode)): + config['extensions'] = overrides.pop('extensions').split(',') + else: + config['extensions'] = overrides.pop('extensions') if dirname is not None: config_file = path.join(dirname, filename) config['__file__'] = config_file @@ -227,7 +226,7 @@ class Config(object): os.chdir(dirname) try: execfile_(filename, config) - except SyntaxError, err: + except SyntaxError as err: raise ConfigError(CONFIG_SYNTAX_ERROR % err) finally: os.chdir(olddir) @@ -248,12 +247,36 @@ class Config(object): 'Please use Unicode strings, e.g. %r.' % (name, u'Content') ) - def init_values(self): + def init_values(self, warn): config = self._raw_config for valname, value in self.overrides.iteritems(): if '.' in valname: realvalname, key = valname.split('.', 1) config.setdefault(realvalname, {})[key] = value + continue + elif valname not in self.values: + warn('unknown config value %r in override, ignoring' % valname) + continue + defvalue = self.values[valname][0] + if isinstance(value, (str, unicode)): + if isinstance(defvalue, dict): + warn('cannot override dictionary config setting %r, ' + 'ignoring (use %r to set individual elements)' % + (valname, valname + '.key=value')) + continue + elif isinstance(defvalue, list): + config[valname] = value.split(',') + elif isinstance(defvalue, (int, long)): + try: + config[valname] = int(value) + except ValueError: + warn('invalid number %r for config value %r, ignoring' + % (value, valname)) + elif defvalue is not None and not isinstance(defvalue, (str, unicode)): + warn('cannot override config setting %r with unsupported type, ' + 'ignoring' % valname) + else: + config[valname] = value else: config[valname] = value for name in config: |