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


Python nodes.inline_all_toctrees函数代码示例

本文整理汇总了Python中sphinx.util.nodes.inline_all_toctrees函数的典型用法代码示例。如果您正苦于以下问题:Python inline_all_toctrees函数的具体用法?Python inline_all_toctrees怎么用?Python inline_all_toctrees使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了inline_all_toctrees函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write

    def write(self, *ignored):
        global logger
        if logger is None: # Sphinx 1.2.3 compatibility, I know it's bad
            logger = self
        mastername = self.config.master_doc
        mastertree = self.env.get_doctree(mastername)
        mastertitle = u'%(project)s v%(release)s documentation' % \
                {'project': self.config.project, 'release': self.config.release}
        if hasattr(self.config, 'text_title') and self.config.text_title is not None:
            mastertitle = self.config.text_title

        logger.info(bold('preparing documents... '), nonl=True)
        self.prepare_writing(self.env.found_docs)
        logger.info('done')

        logger.info(bold('assembling single document... '), nonl=True)
        tree = None
        try:
            tree = inline_all_toctrees(self, set(), mastername,
                    mastertree, darkgreen)
        except TypeError:
            tree = inline_all_toctrees(self, set(), mastername,
                    mastertree, darkgreen, [mastername])
        tree['docname'] = mastername
        toctree = getTocTree(self, mastername, self, False)
        tree.insert(0, nodes.section() + nodes.title(mastertitle, mastertitle))
        tree.insert(1, toctree)
        self.env.resolve_references(tree, mastername, self)
        logger.info('done')

        logger.info(bold('writing... '), nonl=True)
        if hasattr(self, "write_doc_serialized"):
            self.write_doc_serialized(mastername, tree)
        self.write_doc(mastername, tree)
        logger.info('done')
开发者ID:vhelin,项目名称:wla-dx,代码行数:35,代码来源:singletext.py

示例2: assemble_doctree

 def assemble_doctree(self, indexfile):
     docnames = set([indexfile])
     self.info(darkgreen(indexfile) + " ", nonl=1)
     tree = self.env.get_doctree(indexfile)
     tree['docname'] = indexfile
     # extract toctree nodes from the tree and put them in a fresh document
     new_tree = docutils.utils.new_document('<rinoh output>')
     for node in tree.traverse(addnodes.toctree):
         new_tree += node
     largetree = inline_all_toctrees(self, docnames, indexfile, new_tree,
                                     darkgreen)
     largetree['docname'] = indexfile
     self.info()
     self.info("resolving references...")
     self.env.resolve_references(largetree, indexfile, self)
     # resolve :ref:s to distant tex files -- we can't add a cross-reference,
     # but append the document name
     for pendingnode in largetree.traverse(addnodes.pending_xref):
         docname = pendingnode['refdocname']
         sectname = pendingnode['refsectname']
         newnodes = [nodes.emphasis(sectname, sectname)]
         for subdir, title in self.titles:
             if docname.startswith(subdir):
                 newnodes.append(nodes.Text(_(' (in '), _(' (in ')))
                 newnodes.append(nodes.emphasis(title, title))
                 newnodes.append(nodes.Text(')', ')'))
                 break
         else:
             pass
         pendingnode.replace_self(newnodes)
     return largetree
开发者ID:ascribe,项目名称:rinohtype,代码行数:31,代码来源:__init__.py

示例3: assemble_doctree

 def assemble_doctree(self):
     master = self.config.master_doc
     tree = self.env.get_doctree(master)
     tree = inline_all_toctrees(self, set(), master, tree, darkgreen)
     tree['docname'] = master
     self.env.resolve_references(tree, master, self)
     return tree
开发者ID:AlphaTrainer,项目名称:mscthesis,代码行数:7,代码来源:singletext.py

示例4: assemble_doctree

 def assemble_doctree(self):
     master = self.config.master_doc
     tree = self.env.get_doctree(master)
     tree = inline_all_toctrees(self, set() , master, tree, darkgreen)
     tree['docname'] = master
     
     # skip code that checks references, etc.
     return tree
开发者ID:evangoer,项目名称:sphinx_dev,代码行数:8,代码来源:builders.py

示例5: assemble_doctree

 def assemble_doctree(self, indexfile, toctree_only, appendices):
     self.docnames = set([indexfile] + appendices)
     self.info(darkgreen(indexfile) + " ", nonl=1)
     tree = self.env.get_doctree(indexfile)
     tree['docname'] = indexfile
     if toctree_only:
         # extract toctree nodes from the tree and put them in a
         # fresh document
         new_tree = new_document('<pythonbook output>')
         new_sect = nodes.section()
         new_sect += nodes.title('<Set title in conf.py>',
                                 '<Set title in conf.py>')
         new_tree += new_sect
         for node in tree.traverse(addnodes.toctree):
             new_sect += node
         tree = new_tree
     try:
         largetree = inline_all_toctrees(self, self.docnames, indexfile, tree,
                                         darkgreen)
     except:
         largetree = inline_all_toctrees(self, self.docnames, indexfile, tree,
                                         darkgreen, [indexfile])
     largetree['docname'] = indexfile
     for docname in appendices:
         appendix = self.env.get_doctree(docname)
         appendix['docname'] = docname
         largetree.append(appendix)
     self.info()
     self.info("resolving references...")
     self.env.resolve_references(largetree, indexfile, self)
     # resolve :ref:s to distant tex files -- we can't add a cross-reference,
     # but append the document name
     for pendingnode in largetree.traverse(addnodes.pending_xref):
         docname = pendingnode['refdocname']
         sectname = pendingnode['refsectname']
         newnodes = [nodes.emphasis(sectname, sectname)]
         for subdir, title in self.titles:
             if docname.startswith(subdir):
                 newnodes.append(nodes.Text(_(' (in '), _(' (in ')))
                 newnodes.append(nodes.emphasis(title, title))
                 newnodes.append(nodes.Text(')', ')'))
                 break
         else:
             pass
         pendingnode.replace_self(newnodes)
     return largetree
开发者ID:dwjoyce,项目名称:pythonbook,代码行数:46,代码来源:builder.py

示例6: assemble_doctree

 def assemble_doctree(self):
     master = self.config.master_doc
     tree = self.env.get_doctree(master)
     # Final arg is the color function. There is no built-in "no change"
     # color function so we use a trivial lambda expression instead.
     tree = inline_all_toctrees(self, set(), master, tree, lambda x: x,
                                [master])
     tree['docname'] = master
     self.env.resolve_references(tree, master, self)
     return tree
开发者ID:gberriz,项目名称:rasmodel-copy,代码行数:10,代码来源:litmodel.py

示例7: write

    def write(self, *ignored):
        if self.config.man_pages:
            # build manpages from config.man_pages as usual
            ManualPageBuilder.write(self, *ignored)

        self.info(bold("scan master tree for kernel-doc man-pages ... ") + darkgreen("{"), nonl=True)

        master_tree = self.env.get_doctree(self.config.master_doc)
        master_tree = inline_all_toctrees(
            self, set(), self.config.master_doc, master_tree, darkgreen, [self.config.master_doc])
        self.info(darkgreen("}"))
        man_nodes   = master_tree.traverse(condition=self.is_manpage)
        if not man_nodes and not self.config.man_pages:
            self.warn('no "man_pages" config value nor manual section found; no manual pages '
                      'will be written')
            return

        self.info(bold('writing man pages ... '), nonl=True)

        for man_parent in man_nodes:

            doc_tree = self.get_partial_document(man_parent)
            Section2Manpage(doc_tree).apply()

            if not doc_tree.man_info["authors"] and self.config.author:
                doc_tree.man_info["authors"].append(self.config.author)

            doc_writer   = ManualPageWriter(self)
            doc_settings = OptionParser(
                defaults            = self.env.settings
                , components        = (doc_writer,)
                , read_config_files = True
                , ).get_default_values()

            doc_settings.__dict__.update(doc_tree.man_info)
            doc_tree.settings = doc_settings
            targetname  = '%s.%s' % (doc_tree.man_info.title, doc_tree.man_info.section)
            if doc_tree.man_info.decl_type in [
                    "struct", "enum", "union", "typedef"]:
                targetname = "%s_%s" % (doc_tree.man_info.decl_type, targetname)

            destination = FileOutput(
                destination_path = path.join(self.outdir, targetname)
                , encoding='utf-8')

            self.info(darkgreen(targetname) + " ", nonl=True)
            self.env.resolve_references(doc_tree, doc_tree.man_info.manpage, self)

            # remove pending_xref nodes
            for pendingnode in doc_tree.traverse(addnodes.pending_xref):
                pendingnode.replace_self(pendingnode.children)
            doc_writer.write(doc_tree, destination)
        self.info()
开发者ID:return42,项目名称:linuxdoc,代码行数:53,代码来源:manKernelDoc.py

示例8: write

 def write(self, *ignored):
     writer = MobiWriter(self)
     docsettings = OptionParser(
         defaults=self.env.settings,
         components=(writer,)).get_default_values()
     doc_name = self.config.master_doc
     tree = self.env.get_doctree(doc_name)
     master = self.config.master_doc
     tree = inline_all_toctrees(self, set(), master, tree, darkgreen)
     targetname = self.config.project + '.epub'
     tree.settings = docsettings
     writer.write(tree, rst2epub.EpubFileOutput(destination_path=path.join(self.outdir, targetname)))
开发者ID:nvdnkpr,项目名称:rst2epub2,代码行数:12,代码来源:sphinxext.py

示例9: write

    def write(self, *ignored):
        # type: (Any) -> None
        docwriter = ManualPageWriter(self)
        docsettings = OptionParser(
            defaults=self.env.settings,
            components=(docwriter,),
            read_config_files=True).get_default_values()  # type: Any

        logger.info(bold(__('writing... ')), nonl=True)

        for info in self.config.man_pages:
            docname, name, description, authors, section = info
            if docname not in self.env.all_docs:
                logger.warning(__('"man_pages" config value references unknown '
                                  'document %s'), docname)
                continue
            if isinstance(authors, str):
                if authors:
                    authors = [authors]
                else:
                    authors = []

            docsettings.title = name
            docsettings.subtitle = description
            docsettings.authors = authors
            docsettings.section = section

            targetname = '%s.%s' % (name, section)
            logger.info(darkgreen(targetname) + ' { ', nonl=True)
            destination = FileOutput(
                destination_path=path.join(self.outdir, targetname),
                encoding='utf-8')

            tree = self.env.get_doctree(docname)
            docnames = set()  # type: Set[str]
            largetree = inline_all_toctrees(self, docnames, docname, tree,
                                            darkgreen, [docname])
            largetree.settings = docsettings
            logger.info('} ', nonl=True)
            self.env.resolve_references(largetree, docname, self)
            # remove pending_xref nodes
            for pendingnode in largetree.traverse(addnodes.pending_xref):
                pendingnode.replace_self(pendingnode.children)

            docwriter.write(largetree, destination)
        logger.info('')
开发者ID:olivier-heurtier,项目名称:sphinx,代码行数:46,代码来源:manpage.py

示例10: write

 def write(self, *ignored):
     writer = MobiWriter(self)
     docsettings = OptionParser(
         defaults=self.env.settings,
         components=(writer,)).get_default_values()
     doc_name = self.config.master_doc
     self.imgpath = relative_uri(self.get_target_uri(doc_name), '_images')
     tree = self.env.get_doctree(doc_name)
     master = self.config.master_doc
     tree = inline_all_toctrees(self, set(), master, tree, darkgreen)
     # copy images into self.images
     self.post_process_images(tree)
     targetname = self.config.project + '.epub'
     tree.settings = docsettings
     writer.write(
         tree,
         rst2epub.EpubFileOutput(
             destination_path=os.path.join(self.outdir, targetname)))
开发者ID:mattharrison,项目名称:rst2epub2,代码行数:18,代码来源:sphinxext.py

示例11: assemble_doctree

 def assemble_doctree(self, indexfile, toctree_only, appendices):
     # type: (unicode, bool, List[unicode]) -> nodes.Node
     self.docnames = set([indexfile] + appendices)
     logger.info(darkgreen(indexfile) + " ", nonl=1)
     tree = self.env.get_doctree(indexfile)
     tree['docname'] = indexfile
     if toctree_only:
         # extract toctree nodes from the tree and put them in a
         # fresh document
         new_tree = new_document('<texinfo output>')
         new_sect = nodes.section()
         new_sect += nodes.title(u'<Set title in conf.py>',
                                 u'<Set title in conf.py>')
         new_tree += new_sect
         for node in tree.traverse(addnodes.toctree):
             new_sect += node
         tree = new_tree
     largetree = inline_all_toctrees(self, self.docnames, indexfile, tree,
                                     darkgreen, [indexfile])
     largetree['docname'] = indexfile
     for docname in appendices:
         appendix = self.env.get_doctree(docname)
         appendix['docname'] = docname
         largetree.append(appendix)
     logger.info('')
     logger.info("resolving references...")
     self.env.resolve_references(largetree, indexfile, self)
     # TODO: add support for external :ref:s
     for pendingnode in largetree.traverse(addnodes.pending_xref):
         docname = pendingnode['refdocname']
         sectname = pendingnode['refsectname']
         newnodes = [nodes.emphasis(sectname, sectname)]
         for subdir, title in self.titles:
             if docname.startswith(subdir):
                 newnodes.append(nodes.Text(_(' (in '), _(' (in ')))
                 newnodes.append(nodes.emphasis(title, title))
                 newnodes.append(nodes.Text(')', ')'))
                 break
         else:
             pass
         pendingnode.replace_self(newnodes)
     return largetree
开发者ID:LFYG,项目名称:sphinx,代码行数:42,代码来源:texinfo.py

示例12: write

    def write(self, *ignored):
        # overwritten -- use our own version of the Writer
        docwriter = CyrusManualPageWriter(self)
        docsettings = OptionParser(
            defaults=self.env.settings,
            components=(docwriter,),
            read_config_files=True).get_default_values()

        self.info(bold('writing... '), nonl=True)

        for info in self.config.man_pages:
            docname, name, description, authors, section = info
            if isinstance(authors, basestring):
                if authors:
                    authors = [authors]
                else:
                    authors = []

            targetname = '%s.%s' % (name, section)
            self.info(darkgreen(targetname) + ' { ', nonl=True)
            destination = FileOutput(
                destination_path=path.join(self.outdir, targetname),
                encoding='utf-8')

            tree = self.env.get_doctree(docname)
            docnames = set()
            largetree = inline_all_toctrees(self, docnames, docname, tree,
                                            darkgreen)
            self.info('} ', nonl=True)
            self.env.resolve_references(largetree, docname, self)
            # remove pending_xref nodes
            for pendingnode in largetree.traverse(addnodes.pending_xref):
                pendingnode.replace_self(pendingnode.children)

            largetree.settings = docsettings
            largetree.settings.title = name
            largetree.settings.subtitle = description
            largetree.settings.authors = authors
            largetree.settings.section = section

            docwriter.write(largetree, destination)
        self.info()
开发者ID:JensErat,项目名称:cyrus-imapd,代码行数:42,代码来源:manpage.py


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