本文整理汇总了Python中sphinx.config.Config.init_defaults方法的典型用法代码示例。如果您正苦于以下问题:Python Config.init_defaults方法的具体用法?Python Config.init_defaults怎么用?Python Config.init_defaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sphinx.config.Config
的用法示例。
在下文中一共展示了Config.init_defaults方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Sphinx
# 需要导入模块: from sphinx.config import Config [as 别名]
# 或者: from sphinx.config.Config import init_defaults [as 别名]
class Sphinx(object):
def __init__(self, srcdir, outdir, doctreedir, buildername,
confoverrides, status, warning=sys.stderr, freshenv=False):
self.next_listener_id = 0
self._listeners = {}
self.builderclasses = builtin_builders.copy()
self.builder = None
self.srcdir = srcdir
self.outdir = outdir
self.doctreedir = doctreedir
self._status = status
self._warning = warning
self._warncount = 0
self._events = events.copy()
# read config
self.config = Config(srcdir, 'conf.py')
if confoverrides:
for key, val in confoverrides.items():
setattr(self.config, key, val)
# load all extension modules
for extension in getattr(self.config, 'extensions', ()):
self.setup_extension(extension)
# the config file itself can be an extension
if hasattr(self.config, 'setup'):
self.config.setup(self)
# this must happen after loading extension modules, since they
# can add custom config values
self.config.init_defaults()
if buildername is None:
print >>status, 'No builder selected, using default: html'
buildername = 'html'
if buildername not in self.builderclasses:
print >>warning, 'Builder name %s not registered' % buildername
return
self.info(bold('Sphinx v%s, building %s' % (sphinx.__version__, buildername)))
builderclass = self.builderclasses[buildername]
self.builder = builderclass(self, freshenv=freshenv)
self.emit('builder-inited')
def warn(self, message):
self._warncount += 1
self._warning.write('WARNING: %s\n' % message)
def info(self, message='', nonl=False):
if nonl:
self._status.write(message)
else:
self._status.write(message + '\n')
self._status.flush()
# general extensibility interface
def setup_extension(self, extension):
"""Import and setup a Sphinx extension module."""
try:
mod = __import__(extension, None, None, ['setup'])
except ImportError, err:
raise ExtensionError('Could not import extension %s' % extension, err)
if hasattr(mod, 'setup'):
mod.setup(self)