本文整理匯總了Python中docutils.frontend.OptionParser.parse_args方法的典型用法代碼示例。如果您正苦於以下問題:Python OptionParser.parse_args方法的具體用法?Python OptionParser.parse_args怎麽用?Python OptionParser.parse_args使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類docutils.frontend.OptionParser
的用法示例。
在下文中一共展示了OptionParser.parse_args方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Writer
# 需要導入模塊: from docutils.frontend import OptionParser [as 別名]
# 或者: from docutils.frontend.OptionParser import parse_args [as 別名]
import sys
from package import parse_package_or_module
import transform
from docutils.writers.html4css1 import Writer
from docutils.frontend import OptionParser
usage = '%prog [options] [<package-directory> | <python-file> [html-file]]'
description = ('Generates .html documentation for the given Python package'
' or module.')
writer = Writer()
option_parser = OptionParser(components=[writer],
usage=usage,description=description)
settings = option_parser.parse_args(sys.argv[1:])
source_path = settings._source
target_path = settings._destination
nodes = parse_package_or_module(source_path)
# That then needs converting to a docutils tree
document = transform.make_document(nodes,settings)
# And *that* wants converting to the appropriate output format
try:
target = open(target_path,"w")
writer.write(document,target)
finally:
target.close()