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


Python locale._属性代码示例

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


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

示例1: setup

# 需要导入模块: from sphinx import locale [as 别名]
# 或者: from sphinx.locale import _ [as 别名]
def setup(app):
    from sphinx.domains.python import PyField
    from sphinx.util.docfields import Field

    app.add_object_type(
        'confval',
        'confval',
        objname='configuration value',
        indextemplate='pair: %s; configuration value',
        doc_field_types=[
            PyField(
                'type',
                label=_('Type'),
                has_arg=False,
                names=('type',),
                bodyrolename='class'
            ),
            Field(
                'default',
                label=_('Default'),
                has_arg=False,
                names=('default',),
            ),
        ]
    ) 
开发者ID:tirthajyoti,项目名称:doepy,代码行数:27,代码来源:conf.py

示例2: run

# 需要导入模块: from sphinx import locale [as 别名]
# 或者: from sphinx.locale import _ [as 别名]
def run(self):
        if len(self.content) != 1:
            raise ValueError(
                "`testproject` directive needs exactly one argument (the name of the test folder).  "
                "Example: .. testproject:: c_maths"
            )
        self.content[0] = textwrap.dedent('''\
            View the `{project} source code here <{baseurl}/{project_dir}>`_.

            See also: :data:`ExhaleTestCase.test_project <testing.base.ExhaleTestCase.test_project>`.
        '''.format(
            project=self.content[0],
            project_dir=self.content[0].replace(" ", "\\ "),
            baseurl=get_projects_baseurl()
        ))
        project_node = testproject("\n".join(self.content))
        project_node += nodes.title(_("Test Project Source"), _("Test Project Source"))
        self.state.nested_parse(self.content, self.content_offset, project_node)

        return [project_node] 
开发者ID:svenevs,项目名称:exhale,代码行数:22,代码来源:testproject.py

示例3: run

# 需要导入模块: from sphinx import locale [as 别名]
# 或者: from sphinx.locale import _ [as 别名]
def run(self):
        if len(self.content) != 0:
            raise ValueError("`autotested` directive does not allow any arguments.")
        # Seriously there _HAS_ to be a better way to do this...
        # Creating something of length 1 so that I can rage-replace it
        self.content = StringList("?")
        self.content[0] = textwrap.dedent('''\
            This method is tested automatically for every derived type of
            :class:`~testing.base.ExhaleTestCase` that is not decorated with
            :func:`~testing.decorators.no_run`.  The metaclass
            :class:`~testing.base.ExhaleTestCaseMetaclass` generates a testing method
            ``test_common`` that invokes this method.
        ''')
        autotested_node = autotested("\n".join(self.content))
        autotested_node += nodes.title(_("Automatically Tested"), _("Automatically Tested"))
        self.state.nested_parse(self.content, self.content_offset, autotested_node)

        return [autotested_node] 
开发者ID:svenevs,项目名称:exhale,代码行数:20,代码来源:autotested.py

示例4: get_search_results

# 需要导入模块: from sphinx import locale [as 别名]
# 或者: from sphinx.locale import _ [as 别名]
def get_search_results(self, q):
        """Perform a search for the query `q`, and create a set
        of search results. Then render the search results as html and
        return a context dict like the one created by
        :meth:`get_document`::

            document = support.get_search_results(q)

        :param q: the search query
        """
        results = self.search.query(q)
        ctx = {
            'q': q,
            'search_performed': True,
            'search_results': results,
            'docroot': '../',  # XXX
            '_': _,
        }
        document = {
            'body': self.results_template.render(ctx),
            'title': 'Search Results',
            'sidebar': '',
            'relbar': ''
        }
        return document 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:27,代码来源:core.py

示例5: _patch_python_domain

# 需要导入模块: from sphinx import locale [as 别名]
# 或者: from sphinx.locale import _ [as 别名]
def _patch_python_domain() -> None:
    try:
        from sphinx.domains.python import PyTypedField
    except ImportError:
        pass
    else:
        import sphinx.domains.python
        from sphinx.locale import _
        for doc_field in sphinx.domains.python.PyObject.doc_field_types:
            if doc_field.name == 'parameter':
                doc_field.names = ('param', 'parameter', 'arg', 'argument')
                break
        sphinx.domains.python.PyObject.doc_field_types.append(
            PyTypedField('keyword', label=_('Keyword Arguments'),
                         names=('keyword', 'kwarg', 'kwparam'),
                         typerolename='obj', typenames=('paramtype', 'kwtype'),
                         can_collapse=True)) 
开发者ID:thu-coai,项目名称:cotk,代码行数:19,代码来源:__init__.py

示例6: add_directive_header

# 需要导入模块: from sphinx import locale [as 别名]
# 或者: from sphinx.locale import _ [as 别名]
def add_directive_header(self, sig: str) -> None:
        if self.doc_as_attr:
            self.directivetype = 'attribute'
        super().add_directive_header(sig)

        # add inheritance info, if wanted
        if not self.doc_as_attr and self.options.show_inheritance:
            sourcename = self.get_sourcename()
            self.add_line('', sourcename)
            if hasattr(self.object, '__bases__') and len(self.object.__bases__):
                bases = [':class:`%s`' % b.__name__
                         if b.__module__ in ('__builtin__', 'builtins')
                         else ':class:`%s.%s`' % (b.__module__, b.__name__)
                         for b in self.object.__bases__]
                self.add_line('   ' + _('Bases: %s') % ', '.join(bases),
                              sourcename) 
开发者ID:thu-coai,项目名称:cotk,代码行数:18,代码来源:__init__.py

示例7: import_object

# 需要导入模块: from sphinx import locale [as 别名]
# 或者: from sphinx.locale import _ [as 别名]
def import_object(self) -> Any:
        """Never import anything."""
        # disguise as an attribute
        self.objtype = 'attribute'
        self._datadescriptor = True

        with mock(self.env.config.autodoc_mock_imports):
            try:
                ret = import_object(self.modname, self.objpath[:-1], 'class',
                                    attrgetter=self.get_attr,
                                    warningiserror=self.env.config.autodoc_warningiserror)
                self.module, _, _, self.parent = ret
                return True
            except ImportError as exc:
                logger.warning(exc.args[0], type='autodoc', subtype='import_object')
                self.env.note_reread()
                return False 
开发者ID:thu-coai,项目名称:cotk,代码行数:19,代码来源:__init__.py

示例8: run

# 需要导入模块: from sphinx import locale [as 别名]
# 或者: from sphinx.locale import _ [as 别名]
def run(self):
        env = self.state.document.settings.env
        targetid = "tag-%d" % env.new_serialno('tag')
        targetnode = nodes.target('', '', ids=[targetid])

        # The tags fetched from the custom directive are one piece of text
        # sitting in self.content[0]
        taggs = self.content[0].split(", ")
        links = []

        for tagg in taggs:
            # Create Sphinx doc refs of format :ref:`Tagname<Tagname>`
            link = ":ref:`" + tagg + "<" + tagg + ">`"
            links.append(link)
        # Put links back in a single comma-separated string together
        linkjoin = ", ".join(links)

        # Replace content[0] with hyperlinks to display in admonition
        self.content[0] = linkjoin

        ad = Admonition(self.name, [_('Tags')], self.options,
                        self.content, self.lineno, self.content_offset,
                        self.block_text, self.state, self.state_machine)

        return [targetnode] + ad.run() 
开发者ID:mdolab,项目名称:openconcept,代码行数:27,代码来源:tags.py

示例9: add_target_and_index

# 需要导入模块: from sphinx import locale [as 别名]
# 或者: from sphinx.locale import _ [as 别名]
def add_target_and_index(self, name, _, signode):
        targetname = self.objtype + '-' + name
        if targetname not in self.state.document.ids:
            signode['names'].append(targetname)
            signode['ids'].append(targetname)
            signode['first'] = (not self.names)
            self.state.document.note_explicit_target(signode)

            objects = self.env.domaindata['csharp']['objects']
            key = (self.objtype, name)
            if key in objects:
                self.env.warn(self.env.docname,
                              'duplicate description of %s %s, ' %
                              (self.objtype, name) +
                              'other instance in ' +
                              self.env.doc2path(objects[key]),
                              self.lineno)
            objects[key] = self.env.docname
        indextext = self.get_index_text(name)
        if indextext:
            self.indexnode['entries'].append(
                ('single', indextext, targetname, '')) 
开发者ID:djungelorm,项目名称:sphinx-csharp,代码行数:24,代码来源:csharp.py

示例10: resolve_xref

# 需要导入模块: from sphinx import locale [as 别名]
# 或者: from sphinx.locale import _ [as 别名]
def resolve_xref(self, _, fromdocname, builder,
                     typ, target, node, contnode):
        targets = [target]
        if node['csharp:parent'] is not None:
            parts = node['csharp:parent'].split('.')
            while parts:
                targets.append('.'.join(parts)+'.'+target)
                parts = parts[:-1]

        objects = self.data['objects']
        objtypes = self.objtypes_for_role(typ)
        for tgt in targets:
            for objtype in objtypes:
                if (objtype, tgt) in objects:
                    return make_refnode(builder, fromdocname,
                                        objects[objtype, tgt],
                                        objtype + '-' + tgt,
                                        contnode, tgt + ' ' + objtype)

        for tgt in targets:
            ref = get_msdn_ref(tgt)
            if ref is not None:
                return ref
        return None 
开发者ID:djungelorm,项目名称:sphinx-csharp,代码行数:26,代码来源:csharp.py

示例11: text_visit_symbolator

# 需要导入模块: from sphinx import locale [as 别名]
# 或者: from sphinx.locale import _ [as 别名]
def text_visit_symbolator(self, node):
    # type: (nodes.NodeVisitor, symbolator) -> None
    if 'alt' in node.attributes:
        self.add_text(_('[symbol: %s]') % node['alt'])
    else:
        self.add_text(_('[symbol]'))
    raise nodes.SkipNode 
开发者ID:kevinpt,项目名称:symbolator,代码行数:9,代码来源:symbolator_sphinx.py

示例12: man_visit_symbolator

# 需要导入模块: from sphinx import locale [as 别名]
# 或者: from sphinx.locale import _ [as 别名]
def man_visit_symbolator(self, node):
    # type: (nodes.NodeVisitor, symbolator) -> None
    if 'alt' in node.attributes:
        self.body.append(_('[symbol: %s]') % node['alt'])
    else:
        self.body.append(_('[symbol]'))
    raise nodes.SkipNode 
开发者ID:kevinpt,项目名称:symbolator,代码行数:9,代码来源:symbolator_sphinx.py

示例13: generic_visit_pdvega_plot

# 需要导入模块: from sphinx import locale [as 别名]
# 或者: from sphinx.locale import _ [as 别名]
def generic_visit_pdvega_plot(self, node):
    # TODO: generate PNGs and insert them here
    if 'alt' in node.attributes:
        self.body.append(_('[ graph: %s ]') % node['alt'])
    else:
        self.body.append(_('[ graph ]'))
    raise nodes.SkipNode 
开发者ID:altair-viz,项目名称:pdvega,代码行数:9,代码来源:pdvegaplot.py

示例14: get_index_text

# 需要导入模块: from sphinx import locale [as 别名]
# 或者: from sphinx.locale import _ [as 别名]
def get_index_text(self,name):
    if self.objtype == 'fixed':
      return _('%s (Protobuf fixed-width value)') % name
    if self.objtype == 'enum':
      return _('%s (Protobuf enum)') % name
    if self.objtype == 'message':
      return _('%s (Protobuf message)') % name
    if self.objtype == 'error':
      return _('%s (Protobuf error)') % name
    if self.objtype == 'rpc':
      return _('%s (Protobuf RPC)') % name 
开发者ID:ga4gh,项目名称:ga4gh-schemas,代码行数:13,代码来源:protobufdomain.py

示例15: visit_image

# 需要导入模块: from sphinx import locale [as 别名]
# 或者: from sphinx.locale import _ [as 别名]
def visit_image(self, node):
        self.new_state(0)
        if 'uri' in node:
            self.add_text(_('.. image:: %s') % node['uri'])
        elif 'target' in node.attributes:
            self.add_text(_('.. image: %s') % node['target'])
        elif 'alt' in node.attributes:
            self.add_text(_('[image: %s]') % node['alt'])
        else:
            self.add_text(_('[image]'))
        self.end_state(wrap=False)
        raise nodes.SkipNode 
开发者ID:sphinx-contrib,项目名称:restbuilder,代码行数:14,代码来源:rst.py


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