本文整理汇总了Python中sphinx.writers.text.TextWriter类的典型用法代码示例。如果您正苦于以下问题:Python TextWriter类的具体用法?Python TextWriter怎么用?Python TextWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextWriter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: TextBuilder
class TextBuilder(Builder):
name = 'text'
format = 'text'
epilog = __('The text files are in %(outdir)s.')
out_suffix = '.txt'
allow_parallel = True
default_translator_class = TextTranslator
current_docname = None # type: str
def init(self):
# type: () -> None
# section numbers for headings in the currently visited document
self.secnumbers = {} # type: Dict[str, Tuple[int, ...]]
def get_outdated_docs(self):
# type: () -> Iterator[str]
for docname in self.env.found_docs:
if docname not in self.env.all_docs:
yield docname
continue
targetname = path.join(self.outdir, docname + self.out_suffix)
try:
targetmtime = path.getmtime(targetname)
except Exception:
targetmtime = 0
try:
srcmtime = path.getmtime(self.env.doc2path(docname))
if srcmtime > targetmtime:
yield docname
except OSError:
# source doesn't exist anymore
pass
def get_target_uri(self, docname, typ=None):
# type: (str, str) -> str
return ''
def prepare_writing(self, docnames):
# type: (Set[str]) -> None
self.writer = TextWriter(self)
def write_doc(self, docname, doctree):
# type: (str, nodes.Node) -> None
self.current_docname = docname
self.secnumbers = self.env.toc_secnumbers.get(docname, {})
destination = StringOutput(encoding='utf-8')
self.writer.write(doctree, destination)
outfilename = path.join(self.outdir, os_path(docname) + self.out_suffix)
ensuredir(path.dirname(outfilename))
try:
with open(outfilename, 'w', encoding='utf-8') as f:
f.write(self.writer.output)
except OSError as err:
logger.warning(__("error writing file %s: %s"), outfilename, err)
def finish(self):
# type: () -> None
pass
开发者ID:lmregus,项目名称:Portfolio,代码行数:60,代码来源:text.py
示例2: TextBuilder
class TextBuilder(Builder):
name = 'text'
format = 'text'
out_suffix = '.txt'
allow_parallel = True
default_translator_class = TextTranslator
current_docname = None # type: unicode
def init(self):
# type: () -> None
pass
def get_outdated_docs(self):
# type: () -> Iterator[unicode]
for docname in self.env.found_docs:
if docname not in self.env.all_docs:
yield docname
continue
targetname = self.env.doc2path(docname, self.outdir,
self.out_suffix)
try:
targetmtime = path.getmtime(targetname)
except Exception:
targetmtime = 0
try:
srcmtime = path.getmtime(self.env.doc2path(docname))
if srcmtime > targetmtime:
yield docname
except EnvironmentError:
# source doesn't exist anymore
pass
def get_target_uri(self, docname, typ=None):
# type: (unicode, unicode) -> unicode
return ''
def prepare_writing(self, docnames):
# type: (Set[unicode]) -> None
self.writer = TextWriter(self)
def write_doc(self, docname, doctree):
# type: (unicode, nodes.Node) -> None
self.current_docname = docname
destination = StringOutput(encoding='utf-8')
self.writer.write(doctree, destination)
outfilename = path.join(self.outdir, os_path(docname) + self.out_suffix)
ensuredir(path.dirname(outfilename))
try:
with codecs.open(outfilename, 'w', 'utf-8') as f: # type: ignore
f.write(self.writer.output)
except (IOError, OSError) as err:
logger.warning("error writing file %s: %s", outfilename, err)
def finish(self):
# type: () -> None
pass
开发者ID:nvmanh,项目名称:plant,代码行数:57,代码来源:text.py
示例3: render
def render(self, nodes, document):
new_document = document.copy()
new_document.children = nodes
writer = TextWriter(TextBuilder(self.app))
output = writer.write(new_document, FakeDestination())
return output.split('\n')[0]
开发者ID:k-okada,项目名称:breathe,代码行数:10,代码来源:directives.py
示例4: write
def write(self, *ignored):
writer = TextWriter(self)
for label in self.status_iterator(pydoc_topic_labels, "building topics... ", length=len(pydoc_topic_labels)):
if label not in self.env.domaindata["std"]["labels"]:
self.warn("label %r not in documentation" % label)
continue
docname, labelid, sectname = self.env.domaindata["std"]["labels"][label]
doctree = self.env.get_and_resolve_doctree(docname, self)
document = new_document("<section node>")
document.append(doctree.ids[labelid])
destination = StringOutput(encoding="utf-8")
writer.write(document, destination)
self.topics[label] = str(writer.output)
开发者ID:amjith,项目名称:oscon2012-inside-python,代码行数:13,代码来源:pyspecific.py
示例5: write
def write(self, *ignored):
writer = TextWriter(self)
for label in self.status_iterator(pydoc_topic_labels, 'building topics... '):
if label not in self.env.labels:
self.warn('label %r not in documentation' % label)
continue
docname, labelid, sectname = self.env.labels[label]
doctree = self.env.get_and_resolve_doctree(docname, self)
document = new_document('<section node>')
document.append(doctree.ids[labelid])
destination = StringOutput(encoding='utf-8')
writer.write(document, destination)
self.topics[label] = writer.output
开发者ID:AkshayJoshi,项目名称:python,代码行数:13,代码来源:pyspecific.py
示例6: TextBuilder
class TextBuilder(Builder):
name = 'text'
format = 'text'
out_suffix = '.txt'
allow_parallel = True
def init(self):
pass
def get_outdated_docs(self):
for docname in self.env.found_docs:
if docname not in self.env.all_docs:
yield docname
continue
targetname = self.env.doc2path(docname, self.outdir,
self.out_suffix)
try:
targetmtime = path.getmtime(targetname)
except Exception:
targetmtime = 0
try:
srcmtime = path.getmtime(self.env.doc2path(docname))
if srcmtime > targetmtime:
yield docname
except EnvironmentError:
# source doesn't exist anymore
pass
def get_target_uri(self, docname, typ=None):
return ''
def prepare_writing(self, docnames):
self.writer = TextWriter(self)
def write_doc(self, docname, doctree):
self.current_docname = docname
destination = StringOutput(encoding='utf-8')
self.writer.write(doctree, destination)
outfilename = path.join(self.outdir, os_path(docname) + self.out_suffix)
ensuredir(path.dirname(outfilename))
try:
f = codecs.open(outfilename, 'w', 'utf-8')
try:
f.write(self.writer.output)
finally:
f.close()
except (IOError, OSError) as err:
self.warn("error writing file %s: %s" % (outfilename, err))
def finish(self):
pass
开发者ID:lehmannro,项目名称:sphinx-mirror,代码行数:51,代码来源:text.py
示例7: prepare_writing
def prepare_writing(self, docnames):
self.writer = TextWriter(self)
开发者ID:ChimmyTee,项目名称:oh-mainline,代码行数:2,代码来源:text.py
示例8: __init__
def __init__(self, builder):
TextWriter.__init__(self, builder)
self.translator_class = self.builder.translator_class or RstTranslator
开发者ID:etarasenko,项目名称:sphinx-rstbuilder,代码行数:3,代码来源:rst.py
注:本文中的sphinx.writers.text.TextWriter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论