本文整理汇总了Python中docutils.parsers.rst.states.Inliner方法的典型用法代码示例。如果您正苦于以下问题:Python states.Inliner方法的具体用法?Python states.Inliner怎么用?Python states.Inliner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils.parsers.rst.states
的用法示例。
在下文中一共展示了states.Inliner方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from docutils.parsers.rst import states [as 别名]
# 或者: from docutils.parsers.rst.states import Inliner [as 别名]
def __call__(
self,
name: str,
rawtext: str,
text: str,
lineno: int,
inliner: Inliner,
options: Mapping[str, Any] = MappingProxyType({}),
content: Sequence[str] = (),
):
url = self.url_template.format(text)
title = self.title_template.format(text)
options = {**dict(classes=[self.class_name],), **options}
node = nodes.reference(rawtext, title, refuri=url, **options)
return [node], []
示例2: _parse
# 需要导入模块: from docutils.parsers.rst import states [as 别名]
# 或者: from docutils.parsers.rst.states import Inliner [as 别名]
def _parse(self, line):
"""
Parses a single line/string for inline rst statements, like strong, emphasis, literal, ...
:param line: string to parse
:return: nodes
"""
inline_parser = Inliner()
inline_parser.init_customizations(self.doc_settings)
result, message = inline_parser.parse(line, 0, self.doc_memo, self.dummy_doc)
if message:
raise SphinxNeedLayoutException(message)
return result
示例3: reset
# 需要导入模块: from docutils.parsers.rst import states [as 别名]
# 或者: from docutils.parsers.rst.states import Inliner [as 别名]
def reset(self, document, parent, level):
"""Reset the state of state machine.
After reset, self and self.state can be used to
passed to docutils.parsers.rst.Directive.run
Parameters
----------
document: docutils document
Current document of the node.
parent: parent node
Parent node that will be used to interpret role and directives.
level: int
Current section level.
"""
self.language = languages.get_language(
document.settings.language_code)
# setup memo
self.memo.document = document
self.memo.reporter = document.reporter
self.memo.language = self.language
self.memo.section_level = level
# setup inliner
if self.memo.inliner is None:
self.memo.inliner = Inliner()
self.memo.inliner.init_customizations(document.settings)
inliner = self.memo.inliner
inliner.reporter = document.reporter
inliner.document = document
inliner.language = self.language
inliner.parent = parent
# setup self
self.document = document
self.reporter = self.memo.reporter
self.node = parent
self.state.runtime_init()
self.input_lines = document['source']