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


Python osutil.relative_uri函数代码示例

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


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

示例1: write

    def write(self, *ignored):
        docnames = self.env.all_docs

        self.info(bold('preparing documents... '), nonl=True)
        self.prepare_writing(docnames)
        self.info('done')

        self.info(bold('assembling single document... '), nonl=True)
        doctree = self.assemble_doctree()
        doctree.settings = self.docsettings

        self.env.toc_secnumbers = self.assemble_toc_secnumbers()
        self.secnumbers = self.env.toc_secnumbers.get(self.config.master_doc,
                                                      {})
        self.fignumbers = self.env.toc_fignumbers.get(self.config.master_doc,
                                                      {})

        target_uri = self.get_target_uri(self.config.master_doc)
        self.imgpath = relative_uri(target_uri, '_images')
        self.dlpath = relative_uri(target_uri, '_downloads')
        self.current_docname = self.config.master_doc

        if self.should_submit:
            self.post_process_images(doctree)

        meta = self.env.metadata.get(self.config.master_doc)

        title = self.env.longtitles.get(self.config.master_doc)
        toc = self.env.get_toctree_for(self.config.master_doc, self, False)

        self.fix_refuris(toc)

        rendered_title = self.render_partial(title)['title']
        rendered_toc = self.render_partial(toc)['fragment']
        layout_key = meta.get('deconstlayout',
                              self.config.deconst_default_layout)

        rendered_body = self.write_body(doctree)

        envelope = {
            "title": meta.get('deconsttitle', rendered_title),
            "body": rendered_body,
            "toc": rendered_toc,
            "layout_key": layout_key,
            "meta": dict(meta)
        }

        outfile = os.path.join(self.outdir, self.config.master_doc + '.json')

        with open(outfile, 'w', encoding="utf-8") as dumpfile:
            json.dump(envelope, dumpfile)
开发者ID:pombredanne,项目名称:preparer-sphinx,代码行数:51,代码来源:single.py

示例2: write_doc

    def write_doc(self, docname, doctree):
        destination = StringOutput(encoding='utf-8')

        doctree.settings = self.docsettings

        self.secnumbers = self.env.toc_secnumbers.get(docname, {})
        self.imgpath = relative_uri(self.get_target_uri(docname), '_images')
        self.post_process_images(doctree)
        self.dlpath = relative_uri(self.get_target_uri(docname), '_downloads')
        self.docwriter.write(doctree, destination)
        self.docwriter.assemble_parts()
        body = self.docwriter.parts['fragment']
        metatags = self.docwriter.clean_meta
        return destination
开发者ID:VirtualPlants,项目名称:openalea,代码行数:14,代码来源:lightsphinx.py

示例3: html_builder_write_doc

def html_builder_write_doc(self, docname, doctree):
    """Part of :meth:`sphinx.builders.html.StandaloneHTMLBuilder.write_doc`
    method used to convert *doctree* to HTML."""

    destination = StringOutput(encoding='utf-8')
    doctree.settings = self.docsettings

    self.secnumbers = {}
    self.imgpath = relative_uri(self.get_target_uri(docname), '_images')
    self.dlpath = relative_uri(self.get_target_uri(docname), '_downloads')
    self.current_docname = docname
    self.docwriter.write(doctree, destination)
    self.docwriter.assemble_parts()
    return self.docwriter.parts['fragment']
开发者ID:ketanbhatt,项目名称:ablog,代码行数:14,代码来源:blog.py

示例4: link_builder

 def link_builder(edition, to_current=False):
     here = app.builder.get_target_uri(base_page)
     if to_current:
         uri = relative_uri(here, '../' + edition + '/' +
                            here.lstrip('/')) or './'
     else:
         root = app.builder.get_target_uri(app.env.config.master_doc) or './'
         uri = relative_uri(here, root) or ''
         if app.builder.name in ('sentryhtml', 'html'):
             uri = (posixpath.dirname(uri or '.') or '.').rstrip('/') + \
                 '/../' + edition + '/index.html'
         else:
             uri = uri.rstrip('/') + '/../' + edition + '/'
     return uri
开发者ID:Pierre-Ferreira,项目名称:reduxstagramPDF,代码行数:14,代码来源:sentryext.py

示例5: write_doc

    def write_doc(self, docname, doctree):
        destination = StringOutput(encoding="utf-8")
        doctree.settings = self.docsettings

        self.secnumbers = self.env.toc_secnumbers.get(docname, {})
        self.fignumbers = self.env.toc_fignumbers.get(docname, {})
        self.imgpath = relative_uri(self.get_target_uri(docname), "_images")
        self.dlpath = relative_uri(self.get_target_uri(docname), "_downloads")
        self.current_docname = docname
        self.docwriter.write(doctree, destination)
        self.docwriter.assemble_parts()
        body = self.docwriter.parts["fragment"]

        ctx = self.get_doc_context(docname, body)
        self.handle_page(docname, ctx, event_arg=doctree)
开发者ID:CartoDB,项目名称:bigmetadata,代码行数:15,代码来源:markdown.py

示例6: write_doc

    def write_doc(self, docname, doctree):
        destination = StringOutput(encoding='utf-8')
        doctree.settings = self.docsettings

        self.secnumbers = self.env.toc_secnumbers.get(docname, {})
        self.imgpath = relative_uri(self.get_target_uri(docname), '_images')
        self.dlpath = relative_uri(self.get_target_uri(docname), '_downloads')
        self.current_docname = docname
        self.docwriter.write(doctree, destination)
        self.docwriter.assemble_parts()
        body = self.docwriter.parts['fragment']
        metatags = self.docwriter.clean_meta

        ctx = self.get_doc_context(docname, body, metatags)
        self.handle_page(docname, ctx, event_arg=doctree)
开发者ID:ChimmyTee,项目名称:oh-mainline,代码行数:15,代码来源:html.py

示例7: get_relative_uri

    def get_relative_uri(self, from_, to, typ=None):
        """Return a relative URI between two source filenames.

        May raise environment.NoUri if there's no way to return a sensible URI.
        """
        return relative_uri(self.get_target_uri(from_),
                            self.get_target_uri(to, typ))
开发者ID:Lyoness,项目名称:sphinx,代码行数:7,代码来源:__init__.py

示例8: pathto

 def pathto(otheruri, resource=False, baseuri=self.get_target_uri(pagename)):
     if resource and "://" in otheruri:
         return otheruri
     elif not resource:
         otheruri = self.get_target_uri(otheruri)
         return relative_uri(baseuri, otheruri) or "#"
     else:
         return "/" + posixpath.join(self.virtual_staticdir, otheruri)
开发者ID:hitej,项目名称:meta-core,代码行数:8,代码来源:websupport.py

示例9: pathto

 def pathto(otheruri, resource=False, baseuri=default_baseuri):
     if resource and '://' in otheruri:
         # allow non-local resources given by scheme
         return otheruri
     elif not resource:
         otheruri = self.get_target_uri(otheruri)
     uri = relative_uri(baseuri, otheruri) or '#'
     return uri
开发者ID:Titan-C,项目名称:sphinx,代码行数:8,代码来源:html.py

示例10: pathto

 def pathto(otheruri, resource=False,
            baseuri=self.get_target_uri(pagename)):
     # type: (unicode, bool, unicode) -> unicode
     if resource and '://' in otheruri:
         return otheruri
     elif not resource:
         otheruri = self.get_target_uri(otheruri)
         return relative_uri(baseuri, otheruri) or '#'
     else:
         return '/' + posixpath.join(self.virtual_staticdir, otheruri)
开发者ID:marcosptf,项目名称:fedora,代码行数:10,代码来源:builder.py

示例11: process_sibling_ref_nodes

def process_sibling_ref_nodes(app, doctree, fromdocname):
    fromTargetURI = app.builder.get_target_uri(fromdocname)
    # resolves links for all sibling_ref nodes
    for node in doctree.traverse(sibling_ref):
        rellink = '../sxr/sbt/Keys.scala.html#sbt.Keys.%s' % node.keyName
        newuri = relative_uri(fromTargetURI, rellink)
        refNode = nodes.reference('', node.keyName, internal=False, refuri=newuri)
        refNode['classes'].append('pre')
        refNode['title'] = node.description
        node.replace_self(refNode)
开发者ID:2m,项目名称:website,代码行数:10,代码来源:key.py

示例12: write_doc

    def write_doc(self, docname, doctree):
        destination = StringOutput(encoding='utf-8')
        doctree.settings = self.docsettings

        self.secnumbers = self.env.toc_secnumbers.get(docname, {})
        media_url = self.app.media_url
        self.imgpath = '{0}_images'.format(media_url)
        self.post_process_images(doctree)
        self.dlpath = relative_uri(self.get_target_uri(docname), '_downloads')
        self.docwriter.write(doctree, destination)
        self.docwriter.assemble_parts()
开发者ID:strogo,项目名称:djpcms,代码行数:11,代码来源:builders.py

示例13: 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=path.join(self.outdir, targetname)))
开发者ID:FMHelder,项目名称:rst2epub2,代码行数:15,代码来源:sphinxext.py

示例14: get_imagedir

def get_imagedir(app, docname):
    if hasattr(app.builder, 'imagedir'):  # Sphinx (>= 1.3.x)
        dirname = app.builder.imagedir
    elif hasattr(app.builder, 'imgpath') or app.builder.format == 'html':  # Sphinx (<= 1.2.x) and HTML writer
        dirname = '_images'
    else:
        dirname = ''

    if dirname:
        relpath = relative_uri(app.builder.get_target_uri(docname), dirname)
    else:
        relpath = ''

    abspath = os.path.join(app.builder.outdir, dirname)
    return (relpath, abspath)
开发者ID:tk0miya,项目名称:sphinxcontrib-imagehelper,代码行数:15,代码来源:utils.py

示例15: link

    def link(self, base, ext=".html"):
        """
        Returns a link for use as a href to refer to this document from a
        categories page. It assumes that the category pages are in a subdirectory
        of the root and that the item to be referenced is in the algorithms directory
        under the root.

        Arguments:
          base (str): The path to the referrer

        Returns:
          str: A string containing the link to reach this item
        """
        link = relative_uri(base=base, to=self.location)
        if not link.endswith(ext):
            link += ext
        return link
开发者ID:mkoennecke,项目名称:mantid,代码行数:17,代码来源:categories.py


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