本文整理汇总了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',),
),
]
)
示例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]
示例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]
示例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
示例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))
示例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)
示例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
示例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()
示例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, ''))
示例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
示例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
示例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
示例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
示例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
示例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