当前位置: 首页>>代码示例>>Python>>正文


Python Config.add方法代码示例

本文整理汇总了Python中sphinx.config.Config.add方法的典型用法代码示例。如果您正苦于以下问题:Python Config.add方法的具体用法?Python Config.add怎么用?Python Config.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sphinx.config.Config的用法示例。


在下文中一共展示了Config.add方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_conf_warning_message

# 需要导入模块: from sphinx.config import Config [as 别名]
# 或者: from sphinx.config.Config import add [as 别名]
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,代码行数:9,代码来源:test_config.py

示例2: test_overrides

# 需要导入模块: from sphinx.config import Config [as 别名]
# 或者: from sphinx.config.Config import add [as 别名]
def test_overrides():
    config = Config({'value1': '1', 'value2': 2, 'value6': {'default': 6}},
                    {'value2': 999, 'value3': '999', 'value5.attr1': 999, 'value6.attr1': 999,
                     'value7': 'abc,def,ghi', 'value8': 'abc,def,ghi'})
    config.add('value1', None, 'env', ())
    config.add('value2', None, 'env', ())
    config.add('value3', 0, 'env', ())
    config.add('value4', 0, 'env', ())
    config.add('value5', {'default': 0}, 'env', ())
    config.add('value6', {'default': 0}, 'env', ())
    config.add('value7', None, 'env', ())
    config.add('value8', [], 'env', ())
    config.init_values()

    assert config.value1 == '1'
    assert config.value2 == 999
    assert config.value3 == 999
    assert config.value4 == 0
    assert config.value5 == {'attr1': 999}
    assert config.value6 == {'default': 6, 'attr1': 999}
    assert config.value7 == 'abc,def,ghi'
    assert config.value8 == ['abc', 'def', 'ghi']
开发者ID:mgeier,项目名称:sphinx,代码行数:24,代码来源:test_config.py

示例3: MockApp

# 需要导入模块: from sphinx.config import Config [as 别名]
# 或者: from sphinx.config.Config import add [as 别名]
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,代码行数:13,代码来源:test_renderer.py

示例4: MockApp

# 需要导入模块: from sphinx.config import Config [as 别名]
# 或者: from sphinx.config.Config import add [as 别名]
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,代码行数:18,代码来源:test_renderer.py

示例5: test_extension_values

# 需要导入模块: from sphinx.config import Config [as 别名]
# 或者: from sphinx.config.Config import add [as 别名]
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,代码行数:21,代码来源:test_config.py

示例6: Sphinx

# 需要导入模块: from sphinx.config import Config [as 别名]
# 或者: from sphinx.config.Config import add [as 别名]

#.........这里部分代码省略.........
        self._init_builder()
        # set up the enumerable nodes
        self._init_enumerable_nodes()

    def _init_i18n(self):
        # type: () -> None
        """Load translated strings from the configured localedirs if enabled in
        the configuration.
        """
        if self.config.language is not None:
            logger.info(bold('loading translations [%s]... ' % self.config.language),
                        nonl=True)
            user_locale_dirs = [
                path.join(self.srcdir, x) for x in self.config.locale_dirs]
            # compile mo files if sphinx.po file in user locale directories are updated
            for catinfo in find_catalog_source_files(
                    user_locale_dirs, self.config.language, domains=['sphinx'],
                    charset=self.config.source_encoding):
                catinfo.write_mo(self.config.language)
            locale_dirs = [None, path.join(package_dir, 'locale')] + user_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 or self.config.language == 'en':
                # "en" never needs to be translated
                logger.info(__('done'))
            else:
                logger.info('not available for built-in messages')

    def _init_source_parsers(self):
        # type: () -> None
        for suffix, parser in iteritems(self.config.source_parsers):
            self.add_source_parser(suffix, parser)
        for suffix, parser in iteritems(self.registry.get_source_parsers()):
            if suffix not in self.config.source_suffix and suffix != '*':
                self.config.source_suffix.append(suffix)

    def _init_env(self, freshenv):
        # type: (bool) -> None
        if freshenv:
            self.env = BuildEnvironment(self)
            self.env.find_files(self.config, self.builder)
            for domain in self.registry.create_domains(self.env):
                self.env.domains[domain.name] = domain
        else:
            try:
                logger.info(bold(__('loading pickled environment... ')), nonl=True)
                filename = path.join(self.doctreedir, ENV_PICKLE_FILENAME)
                self.env = BuildEnvironment.frompickle(filename, self)
                self.env.domains = {}
                for domain in self.registry.create_domains(self.env):
                    # this can raise if the data version doesn't fit
                    self.env.domains[domain.name] = domain
                logger.info(__('done'))
            except Exception as err:
                if isinstance(err, IOError) and err.errno == ENOENT:
                    logger.info(__('not yet created'))
                else:
                    logger.info(__('failed: %s'), err)
                self._init_env(freshenv=True)

    def preload_builder(self, name):
        # type: (unicode) -> None
        self.registry.preload_builder(self, name)
开发者ID:marcosptf,项目名称:fedora,代码行数:69,代码来源:application.py

示例7: test_check_enum_for_list_failed

# 需要导入模块: from sphinx.config import Config [as 别名]
# 或者: from sphinx.config.Config import add [as 别名]
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,代码行数:8,代码来源:test_config.py

示例8: test_check_enum

# 需要导入模块: from sphinx.config import Config [as 别名]
# 或者: from sphinx.config.Config import add [as 别名]
def test_check_enum(logger):
    config = Config()
    config.add('value', 'default', False, ENUM('default', 'one', 'two'))
    config.init_values()
    check_confval_types(None, config)
    logger.warning.assert_not_called()  # not warned
开发者ID:mgeier,项目名称:sphinx,代码行数:8,代码来源:test_config.py

示例9: test_check_types

# 需要导入模块: from sphinx.config import Config [as 别名]
# 或者: from sphinx.config.Config import add [as 别名]
def test_check_types(logger, name, default, annotation, actual, warned):
    config = Config({name: actual})
    config.add(name, default, 'env', annotation or ())
    config.init_values()
    check_confval_types(None, config)
    assert logger.warning.called == warned
开发者ID:mgeier,项目名称:sphinx,代码行数:8,代码来源:test_config.py

示例10: __init__

# 需要导入模块: from sphinx.config import Config [as 别名]
# 或者: from sphinx.config.Config import add [as 别名]

#.........这里部分代码省略.........
                })
        except Exception as err:
            # delete the saved env to force a fresh build next time
            envfile = path.join(self.doctreedir, ENV_PICKLE_FILENAME)
            if path.isfile(envfile):
                os.unlink(envfile)
            self.emit('build-finished', err)
            raise
        else:
            self.emit('build-finished', None)
        self.builder.cleanup()

    # ---- general extensibility interface -------------------------------------

    def setup_extension(self, extname):
        # type: (str) -> None
        """Import and setup a Sphinx extension module.

        Load the extension given by the module *name*.  Use this if your
        extension needs the features provided by another extension.  No-op if
        called twice.
        """
        logger.debug('[app] setting up extension: %r', extname)
        self.registry.load_extension(self, extname)

    def require_sphinx(self, version):
        # type: (str) -> None
        """Check the Sphinx version if requested.

        Compare *version* (which must be a ``major.minor`` version string, e.g.
        ``'1.1'``) with the version of the running Sphinx, and abort the build
        when it is too old.

        .. versionadded:: 1.0
        """
        if version > sphinx.__display_version__[:3]:
            raise VersionRequirementError(version)

    def import_object(self, objname, source=None):
        # type: (str, str) -> Any
        """Import an object from a ``module.name`` string.

        .. deprecated:: 1.8
           Use ``sphinx.util.import_object()`` instead.
        """
        warnings.warn('app.import_object() is deprecated. '
                      'Use sphinx.util.add_object_type() instead.',
                      RemovedInSphinx30Warning, stacklevel=2)
        return import_object(objname, source=None)

    # event interface
    def connect(self, event, callback):
        # type: (str, Callable) -> int
        """Register *callback* to be called when *event* is emitted.

        For details on available core events and the arguments of callback
        functions, please see :ref:`events`.

        The method returns a "listener ID" that can be used as an argument to
        :meth:`disconnect`.
        """
        listener_id = self.events.connect(event, callback)
        logger.debug('[app] connecting event %r: %r [id=%s]', event, callback, listener_id)
        return listener_id

    def disconnect(self, listener_id):
开发者ID:lmregus,项目名称:Portfolio,代码行数:70,代码来源:application.py


注:本文中的sphinx.config.Config.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。