当前位置: 首页>>代码示例>>Python>>正文


Python Writer.write方法代码示例

本文整理汇总了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)
开发者ID:stpierre,项目名称:dmr,代码行数:15,代码来源:html.py

示例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()
开发者ID:Distrotech,项目名称:docutils,代码行数:32,代码来源:pysrc2html.py

示例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()
开发者ID:Distrotech,项目名称:docutils,代码行数:32,代码来源:pysource.py


注:本文中的docutils.writers.html4css1.Writer.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。