本文整理汇总了Python中docutils.writers.html4css1.Writer.write方法的典型用法代码示例。如果您正苦于以下问题:Python Writer.write方法的具体用法?Python Writer.write怎么用?Python Writer.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils.writers.html4css1.Writer
的用法示例。
在下文中一共展示了Writer.write方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: output
# 需要导入模块: from docutils.writers.html4css1 import Writer [as 别名]
# 或者: from docutils.writers.html4css1.Writer import write [as 别名]
def output(self):
writer = Writer()
output = StringOutput(encoding="utf8")
mydoc = copy.deepcopy(self.document.source)
mydoc.reporter = self.document.source.reporter
mydoc.settings = \
OptionParser(components=(Writer,)).get_default_values()
if config.footer:
mydoc.append(
docutils.nodes.footer(config.footer,
docutils.nodes.Text(config.footer)))
return writer.write(mydoc, output)
示例2: Writer
# 需要导入模块: from docutils.writers.html4css1 import Writer [as 别名]
# 或者: from docutils.writers.html4css1.Writer import write [as 别名]
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()
示例3: Writer
# 需要导入模块: from docutils.writers.html4css1 import Writer [as 别名]
# 或者: from docutils.writers.html4css1.Writer import write [as 别名]
elif output_format == "ast":
thing.show_ast(outstream)
print
elif output_format == "pretty":
outstream.write(document.pformat(indent=" "))
elif output_format == "xml":
if not quiet: print >>sys.stderr, "*** Producing a DOM tree"
domtree = document.asdom()
if not quiet: print >>sys.stderr, " Writing XML"
domtree.writexml(outstream,indent="", addindent=" ",newl="\n")
elif output_format == "html":
if not quiet: print >>sys.stderr, "*** Writing HTML"
if new_writer:
from docutils.writers.html4css1 import Writer
writer = Writer()
writer.write(document,outstream)
elif input_format == "text":
writer = html.Writer()
writer(document,outstream)
else:
writer = html.PythonWriter()
writer(document,outstream)
finally:
if outstream != sys.stdout:
outstream.close()
# ----------------------------------------------------------------------
if __name__ == "__main__":
main()