2008-01-21 14:20:37 -06:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
sphinx.config
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Build configuration file handling.
|
|
|
|
|
|
|
|
:copyright: 2008 by Georg Brandl.
|
|
|
|
:license: BSD license.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
from os import path
|
|
|
|
|
|
|
|
|
|
|
|
class Config(object):
|
|
|
|
"""Configuration file abstraction."""
|
|
|
|
|
|
|
|
# the values are: (default, needs fresh doctrees if changed)
|
|
|
|
|
2008-02-23 09:24:30 -06:00
|
|
|
# If you add a value here, don't forget to include it in the
|
2008-03-09 13:18:41 -05:00
|
|
|
# quickstart.py file template as well as in the docs!
|
2008-02-23 09:24:30 -06:00
|
|
|
|
2008-01-21 14:20:37 -06:00
|
|
|
config_values = dict(
|
2008-08-08 05:54:00 -05:00
|
|
|
# general options
|
2008-01-21 14:20:37 -06:00
|
|
|
project = ('Python', True),
|
|
|
|
copyright = ('', False),
|
|
|
|
version = ('', True),
|
|
|
|
release = ('', True),
|
|
|
|
today = ('', True),
|
2008-08-08 05:54:00 -05:00
|
|
|
today_fmt = (None, True), # the real default is locale-dependent
|
|
|
|
|
|
|
|
language = ('en', True),
|
|
|
|
locale_dirs = ([], True),
|
2008-01-21 14:20:37 -06:00
|
|
|
|
2008-02-01 14:44:17 -06:00
|
|
|
master_doc = ('contents', True),
|
|
|
|
source_suffix = ('.rst', True),
|
2008-02-09 17:09:36 -06:00
|
|
|
unused_docs = ([], True),
|
2008-05-02 04:15:59 -05:00
|
|
|
exclude_dirs = ([], True),
|
2008-05-24 11:28:06 -05:00
|
|
|
exclude_trees = ([], True),
|
2008-06-17 05:06:37 -05:00
|
|
|
default_role = (None, True),
|
2008-01-21 14:20:37 -06:00
|
|
|
add_function_parentheses = (True, True),
|
|
|
|
add_module_names = (True, True),
|
2008-03-09 13:18:41 -05:00
|
|
|
show_authors = (False, True),
|
2008-02-23 09:24:30 -06:00
|
|
|
pygments_style = ('sphinx', False),
|
2008-06-04 15:25:27 -05:00
|
|
|
templates_path = ([], False),
|
2008-04-13 13:16:55 -05:00
|
|
|
template_bridge = (None, False),
|
2008-01-21 14:20:37 -06:00
|
|
|
|
|
|
|
# HTML options
|
2008-05-24 13:03:56 -05:00
|
|
|
html_title = (lambda self: '%s v%s documentation' %
|
|
|
|
(self.project, self.release),
|
|
|
|
False),
|
|
|
|
html_short_title = (lambda self: self.html_title, False),
|
2008-02-23 09:24:30 -06:00
|
|
|
html_style = ('default.css', False),
|
2008-04-27 14:43:45 -05:00
|
|
|
html_logo = (None, False),
|
2008-06-15 03:48:06 -05:00
|
|
|
html_favicon = (None, False),
|
2008-02-23 09:24:30 -06:00
|
|
|
html_static_path = ([], False),
|
2008-08-08 05:54:00 -05:00
|
|
|
html_last_updated_fmt = (None, False), # the real default is locale-dependent
|
2008-01-21 14:20:37 -06:00
|
|
|
html_use_smartypants = (True, False),
|
|
|
|
html_translator_class = (None, False),
|
|
|
|
html_sidebars = ({}, False),
|
|
|
|
html_additional_pages = ({}, False),
|
2008-03-18 14:54:45 -05:00
|
|
|
html_use_modindex = (True, False),
|
2008-05-23 09:01:53 -05:00
|
|
|
html_use_index = (True, False),
|
2008-06-17 04:01:26 -05:00
|
|
|
html_split_index = (False, False),
|
2008-02-01 14:44:17 -06:00
|
|
|
html_copy_source = (True, False),
|
2008-05-03 15:15:25 -05:00
|
|
|
html_use_opensearch = ('', False),
|
2008-05-06 09:25:29 -05:00
|
|
|
html_file_suffix = (None, False),
|
2008-05-24 13:03:56 -05:00
|
|
|
html_show_sphinx = (True, False),
|
2008-01-21 14:20:37 -06:00
|
|
|
|
2008-05-06 09:25:29 -05:00
|
|
|
# HTML help only options
|
2008-01-21 14:20:37 -06:00
|
|
|
htmlhelp_basename = ('pydoc', False),
|
|
|
|
|
|
|
|
# LaTeX options
|
|
|
|
latex_paper_size = ('letter', False),
|
|
|
|
latex_font_size = ('10pt', False),
|
|
|
|
latex_documents = ([], False),
|
2008-04-27 14:43:45 -05:00
|
|
|
latex_logo = (None, False),
|
2008-01-21 14:20:37 -06:00
|
|
|
latex_preamble = ('', False),
|
|
|
|
latex_appendices = ([], False),
|
2008-05-03 13:14:13 -05:00
|
|
|
latex_use_parts = (False, False),
|
2008-03-18 14:54:45 -05:00
|
|
|
latex_use_modindex = (True, False),
|
2008-01-21 14:20:37 -06:00
|
|
|
)
|
|
|
|
|
2008-06-04 15:25:27 -05:00
|
|
|
def __init__(self, dirname, filename, overrides):
|
|
|
|
self.overrides = overrides
|
2008-06-05 03:58:43 -05:00
|
|
|
self.values = Config.config_values.copy()
|
2008-03-16 15:52:34 -05:00
|
|
|
config = {'__file__': path.join(dirname, filename)}
|
2008-01-21 14:20:37 -06:00
|
|
|
olddir = os.getcwd()
|
|
|
|
try:
|
|
|
|
os.chdir(dirname)
|
2008-03-16 15:52:34 -05:00
|
|
|
execfile(config['__file__'], config)
|
2008-01-21 14:20:37 -06:00
|
|
|
finally:
|
|
|
|
os.chdir(olddir)
|
2008-06-04 15:25:27 -05:00
|
|
|
self._raw_config = config
|
|
|
|
# these two must be preinitialized because extensions can add their
|
|
|
|
# own config values
|
2008-05-24 13:03:56 -05:00
|
|
|
self.setup = config.get('setup', None)
|
2008-06-04 15:25:27 -05:00
|
|
|
self.extensions = config.get('extensions', [])
|
|
|
|
|
|
|
|
def init_values(self):
|
|
|
|
config = self._raw_config
|
|
|
|
config.update(self.overrides)
|
2008-06-05 03:58:43 -05:00
|
|
|
for name in config:
|
|
|
|
if name in self.values:
|
2008-06-04 15:25:27 -05:00
|
|
|
self.__dict__[name] = config[name]
|
|
|
|
del self._raw_config
|
2008-05-24 13:03:56 -05:00
|
|
|
|
|
|
|
def __getattr__(self, name):
|
|
|
|
if name.startswith('_'):
|
|
|
|
raise AttributeError(name)
|
2008-06-05 03:58:43 -05:00
|
|
|
if name not in self.values:
|
2008-05-24 13:03:56 -05:00
|
|
|
raise AttributeError('No such config value: %s' % name)
|
2008-06-05 03:58:43 -05:00
|
|
|
default = self.values[name][0]
|
2008-05-24 13:03:56 -05:00
|
|
|
if callable(default):
|
|
|
|
return default(self)
|
|
|
|
return default
|
2008-01-21 14:20:37 -06:00
|
|
|
|
|
|
|
def __getitem__(self, name):
|
|
|
|
return getattr(self, name)
|
2008-02-23 12:47:35 -06:00
|
|
|
|
2008-04-06 12:38:55 -05:00
|
|
|
def __setitem__(self, name, value):
|
|
|
|
setattr(self, name, value)
|
|
|
|
|
|
|
|
def __delitem__(self, name):
|
|
|
|
delattr(self, name)
|
|
|
|
|
2008-02-23 12:47:35 -06:00
|
|
|
def __contains__(self, name):
|
2008-06-05 03:58:43 -05:00
|
|
|
return name in self.values
|