本文整理汇总了Python中docutils.io方法的典型用法代码示例。如果您正苦于以下问题:Python docutils.io方法的具体用法?Python docutils.io怎么用?Python docutils.io使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils
的用法示例。
在下文中一共展示了docutils.io方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write
# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import io [as 别名]
def write(self, document, destination):
"""
Process a document into its final form.
Translate `document` (a Docutils document tree) into the Writer's
native format, and write it out to its `destination` (a
`docutils.io.Output` subclass object).
Normally not overridden or extended in subclasses.
"""
self.document = document
self.language = languages.get_language(
document.settings.language_code,
document.reporter)
self.destination = destination
self.translate()
output = self.destination.write(self.output)
return output
示例2: format_doc
# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import io [as 别名]
def format_doc(docstring):
'''Return parsed documentation string, stripping RST markup.
'''
if not docstring:
return ''
# pylint: disable=unused-variable
output, pub = docutils.core.publish_programmatically(
source_class=docutils.io.StringInput,
source=' '.join(docstring.strip().split()),
source_path=None,
destination_class=docutils.io.NullOutput, destination=None,
destination_path=None,
reader=None, reader_name='standalone',
parser=None, parser_name='restructuredtext',
writer=None, writer_name='null',
settings=None, settings_spec=None, settings_overrides=None,
config_section=None, enable_exit_status=None)
return pub.writer.document.astext()
示例3: _generate_html
# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import io [as 别名]
def _generate_html(data):
extra_params = {'initial_header_level': '2',
'syntax_highlight': 'short',
'input_encoding': 'utf-8',
'exit_status_level': 2,
'compact_p': False,
'embed_stylesheet': False}
pub = docutils.core.Publisher(
source_class=docutils.io.StringInput,
destination_class=docutils.io.StringOutput)
pub.set_components('standalone', 'restructuredtext', 'html')
pub.writer.translator_class = PelicanHTMLTranslator
pub.process_programmatic_settings(None, extra_params, None)
pub.set_source(source=data, source_path=None)
pub.publish(enable_exit_status=True)
return pub.writer.parts['body']
示例4: _get_publisher
# 需要导入模块: import docutils [as 别名]
# 或者: from docutils import io [as 别名]
def _get_publisher(self, source, source_file_path):
# This is a slightly modified copy of `RstReader._get_publisher`
extra_params = {'initial_header_level': '4',
'syntax_highlight': 'short',
'input_encoding': 'utf-8',
'exit_status_level': 2,
'embed_stylesheet': False}
user_params = self.settings.get('DOCUTILS_SETTINGS')
if user_params:
extra_params.update(user_params)
pub = docutils.core.Publisher(
source_class=docutils.io.StringInput,
destination_class=docutils.io.StringOutput)
pub.set_components('standalone', 'restructuredtext', 'html')
pub.writer.translator_class = PelicanHTMLTranslator
pub.process_programmatic_settings(None, extra_params, None)
pub.set_source(source=source, source_path=source_file_path)
pub.publish(enable_exit_status=True)
return pub
# You need to have a read method, which takes a filename and returns
# some content and the associated metadata.