本文整理匯總了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