本文整理汇总了Python中sphinx.config.Config类的典型用法代码示例。如果您正苦于以下问题:Python Config类的具体用法?Python Config怎么用?Python Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_conf_warning_message
def test_conf_warning_message(logger, name, default, annotation, actual, message):
config = Config({name: actual})
config.add(name, default, False, annotation or ())
config.init_values()
check_confval_types(None, config)
logger.warning.assert_called()
assert logger.warning.call_args[0][0] == message
开发者ID:olivier-heurtier,项目名称:sphinx,代码行数:7,代码来源:test_config.py
示例2: test_errors_warnings
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, {}, 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, {}, None)
cfg.init_values()
assert cfg.project == u'Jägermeister'
assert logger.called is False
# test the warning for bytestrings with non-ascii content
# bytestrings with non-ascii content are a syntax error in python3 so we
# skip the test there
if PY3:
return
(tempdir / 'conf.py').write_text(
u'# -*- coding: latin-1\nproject = "fooä"\n', encoding='latin-1')
cfg = Config.read(tempdir, {}, None)
assert logger.warning.called is False
cfg.check_unicode()
assert logger.warning.called is True
开发者ID:mgeier,项目名称:sphinx,代码行数:28,代码来源:test_config.py
示例3: test_config_eol
def test_config_eol(tmpdir):
# test config file's eol patterns: LF, CRLF
configfile = tmpdir / "conf.py"
for eol in ("\n", "\r\n"):
configfile.write_bytes(b('project = "spam"' + eol))
cfg = Config(tmpdir, "conf.py", {}, None)
cfg.init_values()
assert cfg.project == u"spam"
开发者ID:ethanfine,项目名称:oh-mainline,代码行数:8,代码来源:test_config.py
示例4: test_config_eol
def test_config_eol(tmpdir):
# test config file's eol patterns: LF, CRLF
configfile = tmpdir / 'conf.py'
for eol in (b'\n', b'\r\n'):
configfile.write_bytes(b'project = "spam"' + eol)
cfg = Config(tmpdir, 'conf.py', {}, None)
cfg.init_values(lambda warning: 1/0)
assert cfg.project == u'spam'
开发者ID:Basis,项目名称:sphinx,代码行数:8,代码来源:test_config.py
示例5: test_config_eol
def test_config_eol(logger, tempdir):
# test config file's eol patterns: LF, CRLF
configfile = tempdir / 'conf.py'
for eol in (b'\n', b'\r\n'):
configfile.write_bytes(b'project = "spam"' + eol)
cfg = Config(tempdir, 'conf.py', {}, None)
cfg.init_values()
assert cfg.project == u'spam'
assert logger.called is False
开发者ID:nwf,项目名称:sphinx,代码行数:9,代码来源:test_config.py
示例6: Sphinx
class Sphinx(object):
def __init__(self, srcdir, confdir, 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.confdir = confdir
self.outdir = outdir
self.doctreedir = doctreedir
self._status = status
self._warning = warning
self._warncount = 0
self._events = events.copy()
# read config
self.config = Config(confdir, CONFIG_FILENAME, confoverrides)
# load all extension modules
for extension in self.config.extensions:
self.setup_extension(extension)
# the config file itself can be an extension
if self.config.setup:
self.config.setup(self)
# now that we know all config values, collect them from conf.py
self.config.init_values()
if buildername is None:
print >>status, 'No builder selected, using default: html'
buildername = 'html'
if buildername not in self.builderclasses:
raise SphinxError('Builder name %s not registered' % buildername)
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 build(self, all_files, filenames):
try:
if all_files:
self.builder.build_all()
elif filenames:
self.builder.build_specific(filenames)
else:
self.builder.build_update()
except Exception, err:
self.emit('build-finished', err)
raise
else:
开发者ID:lshmenor,项目名称:IMTAphy,代码行数:57,代码来源:application.py
示例7: test_default_man_pages
def test_default_man_pages():
config = Config({'master_doc': 'index',
'project': u'STASI™ Documentation',
'author': u"Wolfgang Schäuble & G'Beckstein",
'release': '1.0'})
config.init_values()
expected = [('index', 'stasi', u'STASI™ Documentation 1.0',
[u"Wolfgang Schäuble & G'Beckstein"], 1)]
assert default_man_pages(config) == expected
开发者ID:olivier-heurtier,项目名称:sphinx,代码行数:9,代码来源:test_build_manpage.py
示例8: MockApp
class MockApp(object):
def __init__(self):
self.doctreedir = None
self.srcdir = None
self.config = Config()
self.config.pre_init_values()
self.config.init_values()
self.config.add('cpp_id_attributes', [], 'env', ())
self.config.add('cpp_paren_attributes', [], 'env', ())
self.config.add('cpp_index_common_prefix', [], 'env', ())
self.registry = MockRegistry()
开发者ID:EricFromCanada,项目名称:breathe,代码行数:11,代码来源:test_renderer.py
示例9: test_errors_warnings
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, {}, 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, {}, None)
cfg.init_values()
assert cfg.project == u'Jägermeister'
assert logger.called is False
开发者ID:olivier-heurtier,项目名称:sphinx,代码行数:15,代码来源:test_config.py
示例10: MockApp
class MockApp(object):
def __init__(self):
self.project = None
self.doctreedir = None
self.srcdir = None
self.config = Config()
self.config.pre_init_values()
self.config.init_values()
self.config.add('cpp_id_attributes', [], 'env', ())
self.config.add('cpp_paren_attributes', [], 'env', ())
self.config.add('cpp_index_common_prefix', [], 'env', ())
self.registry = MockRegistry()
def add_node(self, node):
if not docutils.is_node_registered(node):
docutils.register_node(node)
开发者ID:michaeljones,项目名称:breathe,代码行数:16,代码来源:test_renderer.py
示例11: __init__
def __init__(self, srcdir, confdir, 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.confdir = confdir
self.outdir = outdir
self.doctreedir = doctreedir
if status is None:
self._status = StringIO()
self.quiet = True
else:
self._status = status
self.quiet = False
if warning is None:
self._warning = StringIO()
else:
self._warning = warning
self._warncount = 0
self._events = events.copy()
# status code for command-line application
self.statuscode = 0
# read config
self.config = Config(confdir, CONFIG_FILENAME, confoverrides)
# load all extension modules
for extension in self.config.extensions:
self.setup_extension(extension)
# the config file itself can be an extension
if self.config.setup:
self.config.setup(self)
# now that we know all config values, collect them from conf.py
self.config.init_values()
if buildername is None:
print >>status, 'No builder selected, using default: html'
buildername = 'html'
if buildername not in self.builderclasses:
raise SphinxError('Builder name %s not registered' % buildername)
self.info(bold('Sphinx v%s, building %s' % (sphinx.__released__,
buildername)))
builderclass = self.builderclasses[buildername]
self.builder = builderclass(self, freshenv=freshenv)
self.emit('builder-inited')
开发者ID:lshmenor,项目名称:IMTAphy,代码行数:54,代码来源:application.py
示例12: test_errors_warnings
def test_errors_warnings(dir):
# test the error for syntax errors in the config file
write_file(dir / "conf.py", u"project = \n", "ascii")
raises_msg(ConfigError, "conf.py", Config, dir, "conf.py", {}, None)
# test the automatic conversion of 2.x only code in configs
write_file(dir / "conf.py", u"# -*- coding: utf-8\n\n" u'project = u"Jägermeister"\n', "utf-8")
cfg = Config(dir, "conf.py", {}, None)
cfg.init_values()
assert cfg.project == u"Jägermeister"
# test the warning for bytestrings with non-ascii content
# bytestrings with non-ascii content are a syntax error in python3 so we
# skip the test there
if sys.version_info >= (3, 0):
return
write_file(dir / "conf.py", u'# -*- coding: latin-1\nproject = "fooä"\n', "latin-1")
cfg = Config(dir, "conf.py", {}, None)
warned = [False]
def warn(msg):
warned[0] = True
cfg.check_unicode(warn)
assert warned[0]
开发者ID:solanolabs,项目名称:sphinx,代码行数:25,代码来源:test_config.py
示例13: test_errors_warnings
def test_errors_warnings(dir):
# test the error for syntax errors in the config file
(dir / 'conf.py').write_text(u'project = \n', encoding='ascii')
raises_msg(ConfigError, 'conf.py', Config, dir, 'conf.py', {}, None)
# test the automatic conversion of 2.x only code in configs
(dir / 'conf.py').write_text(
u'# -*- coding: utf-8\n\nproject = u"Jägermeister"\n',
encoding='utf-8')
cfg = Config(dir, 'conf.py', {}, None)
cfg.init_values(lambda warning: 1/0)
assert cfg.project == u'Jägermeister'
# test the warning for bytestrings with non-ascii content
# bytestrings with non-ascii content are a syntax error in python3 so we
# skip the test there
if PY3:
return
(dir / 'conf.py').write_text(
u'# -*- coding: latin-1\nproject = "fooä"\n', encoding='latin-1')
cfg = Config(dir, 'conf.py', {}, None)
warned = [False]
def warn(msg):
warned[0] = True
cfg.check_unicode(warn)
assert warned[0]
开发者ID:Basis,项目名称:sphinx,代码行数:26,代码来源:test_config.py
示例14: __init__
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')
开发者ID:lshmenor,项目名称:IMTAphy,代码行数:46,代码来源:application.py
示例15: test_extension_values
def test_extension_values():
config = Config()
# check standard settings
assert config.master_doc == 'contents'
# can't override it by add_config_value()
with pytest.raises(ExtensionError) as excinfo:
config.add('master_doc', 'index', 'env', None)
assert 'already present' in str(excinfo.value)
# add a new config value
config.add('value_from_ext', [], 'env', None)
assert config.value_from_ext == []
# can't override it by add_config_value()
with pytest.raises(ExtensionError) as excinfo:
config.add('value_from_ext', [], 'env', None)
assert 'already present' in str(excinfo.value)
开发者ID:mgeier,项目名称:sphinx,代码行数:19,代码来源:test_config.py
示例16: __init__
def __init__(self, filename, encoding="utf8", raise_exception=False):
"""
create an instance of a blog post from a file or a string
@param filename filename or string
@param encoding encoding
@param raise_exception to raise an exception when the blog cannot be parsed
The constructor creates the following members:
* title
* date
* keywords
* categories
* _filename
* _raw
* rst_obj: the object generated by docutils (@see cl BlogPostDirective)
* pub: Publisher
.. versionchanged:: 1.3
Parameter *raise_exception* was added to catch the standard error.
The constructor aims at getting the text of a blog post, not
interpreting it. The code used to throw warnings or errors due to
unreferenced nodes.
"""
if os.path.exists(filename):
with open(filename, "r", encoding=encoding) as f:
try:
content = f.read()
except UnicodeDecodeError as e:
raise Exception(
'unable to read filename (encoding issue):\n File "{0}", line 1'.format(filename)) from e
self._filename = filename
else:
content = filename
self._filename = None
self._raw = content
overrides = {}
overrides['input_encoding'] = encoding
overrides["out_blogpostlist"] = []
overrides["blog_background"] = False
overrides["sharepost"] = None
overrides.update({'doctitle_xform': True,
'initial_header_level': 2,
'warning_stream': StringIO(),
'out_blogpostlist': [],
'out_runpythonlist': [],
})
config = Config(None, None, overrides=overrides, tags=None)
config.blog_background = False
config.sharepost = None
env = BuildEnvironment(None, None, config=config)
env.temp_data["docname"] = "string"
overrides["env"] = env
errst = sys.stderr
keeperr = StringIO()
sys.stderr = keeperr
output, pub = publish_programmatically(
source_class=docio.StringInput,
source=content,
source_path=None,
destination_class=docio.StringOutput,
destination=None,
destination_path=None,
reader=None,
reader_name='standalone',
parser=None,
parser_name='restructuredtext',
writer=None,
writer_name='null',
settings=None,
settings_spec=None,
settings_overrides=overrides,
config_section=None,
enable_exit_status=None)
sys.stderr = errst
all_err = keeperr.getvalue()
if len(all_err) > 0:
if raise_exception:
raise BlogPostParseError("unable to parse a blogpost:\nERR:\n{0}\nFILE\n{1}\nCONTENT\n{2}".format(
all_err, self._filename, content))
else:
# we assume we just need the content, raising a warnings
# might make some process fail later
# warnings.warn("Raw rst was caught but unable to fully parse a blogpost:\nERR:\n{0}\nFILE\n{1}\nCONTENT\n{2}".format(
# all_err, self._filename, content))
pass
# document = pub.writer.document
objects = pub.settings.out_blogpostlist
if len(objects) != 1:
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:
示例17: test_check_enum_for_list_failed
def test_check_enum_for_list_failed(logger):
config = Config({'value': ['one', 'two', 'invalid']})
config.add('value', 'default', False, ENUM('default', 'one', 'two'))
config.init_values()
check_confval_types(None, config)
logger.warning.assert_called()
开发者ID:mgeier,项目名称:sphinx,代码行数:6,代码来源:test_config.py
示例18: Sphinx
class Sphinx(object):
def __init__(self, srcdir, confdir, outdir, doctreedir, buildername,
confoverrides=None, status=sys.stdout, warning=sys.stderr,
freshenv=False, warningiserror=False, tags=None, verbosity=0,
parallel=0):
# type: (unicode, unicode, unicode, unicode, unicode, Dict, IO, IO, bool, bool, List[unicode], int, int) -> None # NOQA
self.verbosity = verbosity
self.extensions = {} # type: Dict[unicode, Extension]
self._setting_up_extension = ['?'] # type: List[unicode]
self.builder = None # type: Builder
self.env = None # type: BuildEnvironment
self.registry = SphinxComponentRegistry()
self.enumerable_nodes = {} # type: Dict[nodes.Node, Tuple[unicode, Callable]] # NOQA
self.post_transforms = [] # type: List[Transform]
self.html_themes = {} # type: Dict[unicode, unicode]
self.srcdir = srcdir
self.confdir = confdir
self.outdir = outdir
self.doctreedir = doctreedir
self.parallel = parallel
if status is None:
self._status = cStringIO() # type: IO
self.quiet = True
else:
self._status = status
self.quiet = False
if warning is None:
self._warning = cStringIO() # type: IO
else:
self._warning = warning
self._warncount = 0
self.warningiserror = warningiserror
logging.setup(self, self._status, self._warning)
self.events = EventManager()
# keep last few messages for traceback
# This will be filled by sphinx.util.logging.LastMessagesWriter
self.messagelog = deque(maxlen=10) # type: deque
# say hello to the world
logger.info(bold('Running Sphinx v%s' % sphinx.__display_version__))
# status code for command-line application
self.statuscode = 0
if not path.isdir(outdir):
logger.info('making output directory...')
os.makedirs(outdir)
# read config
self.tags = Tags(tags)
self.config = Config(confdir, CONFIG_FILENAME,
confoverrides or {}, self.tags)
self.config.check_unicode()
# defer checking types until i18n has been initialized
# initialize some limited config variables before initialize i18n and loading
# extensions
self.config.pre_init_values()
# set up translation infrastructure
self._init_i18n()
# check the Sphinx version if requested
if self.config.needs_sphinx and self.config.needs_sphinx > sphinx.__display_version__:
raise VersionRequirementError(
__('This project needs at least Sphinx v%s and therefore cannot '
'be built with this version.') % self.config.needs_sphinx)
# set confdir to srcdir if -C given (!= no confdir); a few pieces
# of code expect a confdir to be set
if self.confdir is None:
self.confdir = self.srcdir
# load all built-in extension modules
for extension in builtin_extensions:
self.setup_extension(extension)
# load all user-given extension modules
for extension in self.config.extensions:
self.setup_extension(extension)
# preload builder module (before init config values)
self.preload_builder(buildername)
# the config file itself can be an extension
if self.config.setup:
self._setting_up_extension = ['conf.py']
# py31 doesn't have 'callable' function for below check
if hasattr(self.config.setup, '__call__'):
self.config.setup(self)
else:
raise ConfigError(
__("'setup' as currently defined in conf.py isn't a Python callable. "
#.........这里部分代码省略.........
开发者ID:marcosptf,项目名称:fedora,代码行数:101,代码来源:application.py
示例19: __init__
def __init__(self, srcdir, confdir, outdir, doctreedir, buildername,
confoverrides=None, status=sys.stdout, warning=sys.stderr,
freshenv=False, warningiserror=False, tags=None, verbosity=0,
parallel=0):
# type: (unicode, unicode, unicode, unicode, unicode, Dict, IO, IO, bool, bool, List[unicode], int, int) -> None # NOQA
self.verbosity = verbosity
self.extensions = {} # type: Dict[unicode, Extension]
self._setting_up_extension = ['?'] # type: List[unicode]
self.builder = None # type: Builder
self.env = None # type: BuildEnvironment
self.registry = SphinxComponentRegistry()
self.enumerable_nodes = {} # type: Dict[nodes.Node, Tuple[unicode, Callable]] # NOQA
self.post_transforms = [] # type: List[Transform]
self.html_themes = {} # type: Dict[unicode, unicode]
self.srcdir = srcdir
self.confdir = confdir
self.outdir = outdir
self.doctreedir = doctreedir
self.parallel = parallel
if status is None:
self._status = cStringIO() # type: IO
self.quiet = True
else:
self._status = status
self.quiet = False
if warning is None:
self._warning = cStringIO() # type: IO
else:
self._warning = warning
self._warncount = 0
self.warningiserror = warningiserror
logging.setup(self, self._status, self._warning)
self.events = EventManager()
# keep last few messages for traceback
# This will be filled by sphinx.util.logging.LastMessagesWriter
self.messagelog = deque(maxlen=10) # type: deque
# say hello to the world
logger.info(bold('Running Sphinx v%s' % sphinx.__display_version__))
# status code for command-line application
self.statuscode = 0
if not path.isdir(outdir):
logger.info('making output directory...')
os.makedirs(outdir)
# read config
self.tags = Tags(tags)
self.config = Config(confdir, CONFIG_FILENAME,
confoverrides or {}, self.tags)
self.config.check_unicode()
# defer checking types until i18n has been initialized
# initialize some limited config variables before initialize i18n and loading
# extensions
self.config.pre_init_values()
# set up translation infrastructure
self._init_i18n()
# check the Sphinx version if requested
if self.config.needs_sphinx and self.config.needs_sphinx > sphinx.__display_version__:
raise VersionRequirementError(
__('This project needs at least Sphinx v%s and therefore cannot '
'be built with this version.') % self.config.needs_sphinx)
# set confdir to srcdir if -C given (!= no confdir); a few pieces
# of code expect a confdir to be set
if self.confdir is None:
self.confdir = self.srcdir
# load all built-in extension modules
for extension in builtin_extensions:
self.setup_extension(extension)
# load all user-given extension modules
for extension in self.config.extensions:
self.setup_extension(extension)
# preload builder module (before init config values)
self.preload_builder(buildername)
# the config file itself can be an extension
if self.config.setup:
self._setting_up_extension = ['conf.py']
# py31 doesn't have 'callable' function for below check
if hasattr(self.config.setup, '__call__'):
self.config.setup(self)
else:
raise ConfigError(
__("'setup' as currently defined in conf.py isn't a Python callable. "
"Please modify its definition to make it a callable function. This is "
"needed for conf.py to behave as a Sphinx extension.")
#.........这里部分代码省略.........
开发者ID:marcosptf,项目名称:fedora,代码行数:101,代码来源:application.py
示例20: Sphinx
class Sphinx(object):
def __init__(self, srcdir, confdir, outdir, doctreedir, buildername,
confoverrides=None, status=sys.stdout, warning=sys.stderr,
freshenv=False, warningiserror=False, tags=None, verbosity=0,
parallel=0):
self.verbosity = verbosity
self.next_listener_id = 0
self._extensions = {}
self._listeners = {}
self.domains = BUILTIN_DOMAINS.copy()
self.builderclasses = BUILTIN_BUILDERS.copy()
self.builder = None
self.env = None
self.srcdir = srcdir
self.confdir = confdir
self.outdir = outdir
self.doctreedir = doctreedir
self.parallel = parallel
if status is None:
self._status = StringIO()
self.quiet = True
else:
self._status = status
self.quiet = False
if warning is None:
self._warning = StringIO()
else:
self._warning = warning
self._warncount = 0
self.warningiserror = warningiserror
self._events = events.copy()
# say hello to the world
self.info(bold('Running Sphinx v%s' % sphinx.__version__))
# status code for command-line application
self.statuscode = 0
# read config
self.tags = Tags(tags)
self.config = Config(confdir, CONFIG_FILENAME,
confoverrides or {}, self.tags)
self.config.check_unicode(self.warn)
# set confdir to srcdir if -C given (!= no confdir); a few pieces
# of code expect a confdir to be set
if self.confdir is None:
self.confdir = self.srcdir
# backwards compatibility: activate old C markup
self.setup_extension('sphinx.ext.oldcmarkup')
# load all user-given extension modules
for extension in self.config.extensions:
self.setup_extension(extension)
# the config file itself can be an extension
if self.config.setup:
self.config.setup(self)
# now that we know all config values, collect them from conf.py
self.config.init_values()
# check the Sphinx version if requested
if self.config.needs_sphinx and \
self.config.needs_sphinx > sphinx.__version__[:3]:
raise VersionRequirementError(
'This project needs at least Sphinx v%s and therefore cannot '
'be built with this version.' % self.config.needs_sphinx)
# set up translation infrastructure
self._init_i18n()
# set up the build environment
self._init_env(freshenv)
# set up the builder
self._init_builder(buildername)
def _init_i18n(self):
"""Load translated strings from the configured localedirs if enabled in
the configuration.
"""
if self.config.language is not None:
self.info(bold('loading translations [%s]... ' %
self.config.language), nonl=True)
locale_dirs = [None, path.join(package_dir, 'locale')] + \
[path.join(self.srcdir, x) for x in self.config.locale_dirs]
else:
locale_dirs = []
self.translator, has_translation = locale.init(locale_dirs,
self.config.language)
if self.config.language is not None:
if has_translation:
self.info('done')
else:
self.info('locale not available')
#.........这里部分代码省略.........
开发者ID:aras0,项目名称:porownywarka-ofert,代码行数:101,代码来源:application.py
注:本文中的sphinx.config.Config类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论