本文整理匯總了Python中docutils.frontend.OptionParser方法的典型用法代碼示例。如果您正苦於以下問題:Python frontend.OptionParser方法的具體用法?Python frontend.OptionParser怎麽用?Python frontend.OptionParser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類docutils.frontend
的用法示例。
在下文中一共展示了frontend.OptionParser方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _check_rst_data
# 需要導入模塊: from docutils import frontend [as 別名]
# 或者: from docutils.frontend import OptionParser [as 別名]
def _check_rst_data(self, data):
"""Returns warnings when the provided data doesn't compile."""
source_path = StringIO()
parser = Parser()
settings = frontend.OptionParser().get_default_values()
settings.tab_width = 4
settings.pep_references = None
settings.rfc_references = None
reporter = SilentReporter(source_path,
settings.report_level,
settings.halt_level,
stream=settings.warning_stream,
debug=settings.debug,
encoding=settings.error_encoding,
error_handler=settings.error_encoding_error_handler)
document = nodes.document(settings, reporter, source=source_path)
document.note_source(source_path, -1)
try:
parser.parse(data, document)
except AttributeError:
reporter.messages.append((-1, 'Could not finish the parsing.',
'', {}))
return reporter.messages
示例2: setup_option_parser
# 需要導入模塊: from docutils import frontend [as 別名]
# 或者: from docutils.frontend import OptionParser [as 別名]
def setup_option_parser(self, usage=None, description=None,
settings_spec=None, config_section=None,
**defaults):
if config_section:
if not settings_spec:
settings_spec = SettingsSpec()
settings_spec.config_section = config_section
parts = config_section.split()
if len(parts) > 1 and parts[-1] == 'application':
settings_spec.config_section_dependencies = ['applications']
#@@@ Add self.source & self.destination to components in future?
option_parser = OptionParser(
components=(self.parser, self.reader, self.writer, settings_spec),
defaults=defaults, read_config_files=True,
usage=usage, description=description)
return option_parser
示例3: _check_rst_data
# 需要導入模塊: from docutils import frontend [as 別名]
# 或者: from docutils.frontend import OptionParser [as 別名]
def _check_rst_data(self, data):
"""Returns warnings when the provided data doesn't compile."""
source_path = StringIO()
parser = Parser()
settings = frontend.OptionParser(components=(Parser,)).get_default_values()
settings.tab_width = 4
settings.pep_references = None
settings.rfc_references = None
reporter = SilentReporter(source_path,
settings.report_level,
settings.halt_level,
stream=settings.warning_stream,
debug=settings.debug,
encoding=settings.error_encoding,
error_handler=settings.error_encoding_error_handler)
document = nodes.document(settings, reporter, source=source_path)
document.note_source(source_path, -1)
try:
parser.parse(data, document)
except AttributeError as e:
reporter.messages.append(
(-1, 'Could not finish the parsing: %s.' % e, '', {}))
return reporter.messages
示例4: renderList
# 需要導入模塊: from docutils import frontend [as 別名]
# 或者: from docutils.frontend import OptionParser [as 別名]
def renderList(l, markDownHelp, settings=None):
"""
Given a list of reStructuredText or MarkDown sections, return a docutils node list
"""
if len(l) == 0:
return []
if markDownHelp:
return parseMarkDownBlock('\n\n'.join(l) + '\n')
else:
if settings is None:
settings = OptionParser(components=(Parser,)).get_default_values()
document = new_document(None, settings)
Parser().parse('\n\n'.join(l) + '\n', document)
return document.children