本文整理汇总了Python中sphinx.util.osutil.relative_uri函数的典型用法代码示例。如果您正苦于以下问题:Python relative_uri函数的具体用法?Python relative_uri怎么用?Python relative_uri使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了relative_uri函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: write_doc
def write_doc(self, docname, doctree):
self.imgpath = relative_uri(self.get_target_uri(docname), '_images')
self.post_process_images(doctree)
self.current_docname = docname
return TextBuilder.write_doc(self, docname, doctree)
开发者ID:nishio,项目名称:rst2inao,代码行数:5,代码来源:builder.py
示例17: 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)
# Merge this page's metadata with the repo-wide data.
meta = self.deconst_config.meta.copy()
meta.update(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)
unsearchable = meta.get('deconstunsearchable',
self.config.deconst_default_unsearchable)
if unsearchable is not None:
unsearchable = unsearchable in ("true", True)
rendered_body = self.write_body(doctree)
if self.git_root != None and self.deconst_config.github_url != "":
# current_page_name has no extension, and it _might_ not be .rst
fileglob = path.join(
os.getcwd(), self.env.srcdir, self.config.master_doc + ".*"
)
edit_segments = [
self.deconst_config.github_url,
"edit",
self.deconst_config.github_branch,
path.relpath(glob.glob(fileglob)[0], self.git_root)
]
meta["github_edit_url"] = '/'.join(segment.strip('/') for segment in edit_segments)
envelope = {
"title": meta.get('deconsttitle', rendered_title),
"body": rendered_body,
"toc": rendered_toc,
"layout_key": layout_key,
"meta": dict(meta)
}
if unsearchable is not None:
envelope["unsearchable"] = unsearchable
page_cats = meta.get('deconstcategories')
global_cats = self.config.deconst_categories
if page_cats is not None or global_cats is not None:
cats = set()
if page_cats is not None:
cats.update(re.split("\s*,\s*", page_cats))
cats.update(global_cats or [])
envelope["categories"] = list(cats)
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:annegentle,项目名称:preparer-sphinx,代码行数:85,代码来源:single.py
示例18: write_doc_serialized
def write_doc_serialized(self, docname, doctree):
self.imgpath = relative_uri(self.get_target_uri(docname), self.imagedir)
self.post_process_images(doctree)
title = self.env.longtitles.get(docname)
title = title and self.render_partial(title)['title'] or ''
self.index_page(docname, doctree, title)
开发者ID:Titan-C,项目名称:sphinx,代码行数:6,代码来源:html.py
示例19: traverse
def traverse(self, node, owner):
"""
If an API description is nested in another description,
lookup the child in the context of the parent
"""
# nodes.Text iterates over characters, not children
for child in node.children:
if isinstance(child, addnodes.desc):
for desc_child in child.children:
if isinstance(desc_child, addnodes.desc_signature):
# Get the name of the object. An owner in the signature
# overrides an owner from a parent description.
signature_owner = None
for child in desc_child.children:
if isinstance(child, addnodes.desc_addname):
# An owner in the signature ends with ::
signature_owner = child.astext()[:-2]
elif isinstance(child, addnodes.desc_name):
name = child.astext()
break
# Lookup the object in the Doxygen index
try:
compound, = index.xpath('descendant::compound[(not($owner) or name[text() = $owner]) and descendant::name[text() = $name]][1]', owner=signature_owner or owner, name=name)
except ValueError:
continue
filename = compound.get('refid') + '.xml'
if filename not in cache:
cache[filename] = etree.parse('xml/' + filename)
# An enumvalue has no location
memberdef, = cache[filename].xpath('descendant::compounddef[compoundname[text() = $name]]', name=name) or cache[filename].xpath('descendant::memberdef[name[text() = $name] | enumvalue[name[text() = $name]]]', name=name)
# Append the link after the object's signature.
# Get the source file and line number from Doxygen and use
# them to construct the link.
location = memberdef.find('location')
filename = path.basename(location.get('file'))
# Declarations have no bodystart
line = location.get('bodystart') or location.get('line')
emphasis = nodes.emphasis('', ' ' + filename + ' line ' + line)
# Use a relative link if the output is HTML, otherwise fall
# back on an absolute link to Read the Docs. I haven't
# figured out how to get the page name for e.g. a struct
# from the XML files so ape Doxygen escapeCharsInString()
# instead.
refuri = 'api/' + escape(filename) + '_source.html#l' + line.rjust(5, '0')
if self.app.builder.name == 'html':
refuri = osutil.relative_uri(self.app.builder.get_target_uri(self.docname), refuri)
else:
refuri = 'http://docs.trafficserver.apache.org/en/latest/' + refuri
reference = nodes.reference('', '', emphasis, classes=['viewcode-link'], reftitle='Source code', refuri=refuri)
desc_child += reference
# Style the links
self.has_link = True
else:
self.traverse(desc_child, name)
else:
self.traverse(child, owner)
开发者ID:25311753,项目名称:trafficserver,代码行数:74,代码来源:doxygen.py
注:本文中的sphinx.util.osutil.relative_uri函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论