本文整理汇总了Python中docutils.parsers.rst.roles._roles方法的典型用法代码示例。如果您正苦于以下问题:Python roles._roles方法的具体用法?Python roles._roles怎么用?Python roles._roles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils.parsers.rst.roles
的用法示例。
在下文中一共展示了roles._roles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from docutils.parsers.rst import roles [as 别名]
# 或者: from docutils.parsers.rst.roles import _roles [as 别名]
def run(self):
if not self.arguments:
if '' in roles._roles:
# restore the "default" default role
del roles._roles['']
return []
role_name = self.arguments[0]
role, messages = roles.role(role_name, self.state_machine.language,
self.lineno, self.state.reporter)
if role is None:
error = self.state.reporter.error(
'Unknown interpreted text role "%s".' % role_name,
nodes.literal_block(self.block_text, self.block_text),
line=self.lineno)
return messages + [error]
roles._roles[''] = role
# @@@ should this be local to the document, not the parser?
return messages
示例2: run
# 需要导入模块: from docutils.parsers.rst import roles [as 别名]
# 或者: from docutils.parsers.rst.roles import _roles [as 别名]
def run(self):
if not self.arguments:
if '' in roles._roles:
# restore the "default" default role
del roles._roles['']
return []
role_name = self.arguments[0]
role, messages = roles.role(role_name, self.state_machine.language,
self.lineno, self.state.reporter)
if role is None:
error = self.state.reporter.error(
'Unknown interpreted text role "%s".' % role_name,
nodes.literal_block(self.block_text, self.block_text),
line=self.lineno)
return messages + [error]
roles._roles[''] = role
return messages
示例3: setUp
# 需要导入模块: from docutils.parsers.rst import roles [as 别名]
# 或者: from docutils.parsers.rst.roles import _roles [as 别名]
def setUp(self):
# Avoid "WARNING: while setting up extension
# sphinxcontrib.programoutput: directive u'program-output' is
# already registered, it will be overridden".
# This may only be needed for Sphinx 1.
self.directives = directives._directives.copy()
# Likewise for 'eq'
self.roles = roles._roles.copy()
# Avoid "node class 'toctree' is already registered, its visitors will be overridden"
# By default this class has *no* `visit_` methods
for node in self.duplicate_nodes_to_remove:
if hasattr(nodes.GenericNodeVisitor, 'visit_' + node):
delattr(nodes.GenericNodeVisitor, 'visit_' + node)
示例4: tearDown
# 需要导入模块: from docutils.parsers.rst import roles [as 别名]
# 或者: from docutils.parsers.rst.roles import _roles [as 别名]
def tearDown(self):
directives._directives = self.directives
roles._roles = self.roles