本文整理汇总了Python中sphinx.util.nodes.split_explicit_title函数的典型用法代码示例。如果您正苦于以下问题:Python split_explicit_title函数的具体用法?Python split_explicit_title怎么用?Python split_explicit_title使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了split_explicit_title函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: indexmarkup_role
def indexmarkup_role(typ, rawtext, text, lineno, inliner,
options={}, content=[]):
"""Role for PEP/RFC references that generate an index entry."""
env = inliner.document.settings.env
if not typ:
typ = env.config.default_role
else:
typ = typ.lower()
has_explicit_title, title, target = split_explicit_title(text) # type: bool, unicode, unicode # NOQA
title = utils.unescape(title)
target = utils.unescape(target)
targetid = 'index-%s' % env.new_serialno('index')
indexnode = addnodes.index()
targetnode = nodes.target('', '', ids=[targetid])
inliner.document.note_explicit_target(targetnode)
if typ == 'pep':
indexnode['entries'] = [
('single', _('Python Enhancement Proposals; PEP %s') % target,
targetid, '', None)]
anchor = '' # type: unicode
anchorindex = target.find('#')
if anchorindex > 0:
target, anchor = target[:anchorindex], target[anchorindex:]
if not has_explicit_title:
title = "PEP " + utils.unescape(title)
try:
pepnum = int(target)
except ValueError:
msg = inliner.reporter.error('invalid PEP number %s' % target,
line=lineno)
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
ref = inliner.document.settings.pep_base_url + 'pep-%04d' % pepnum
sn = nodes.strong(title, title)
rn = nodes.reference('', '', internal=False, refuri=ref+anchor,
classes=[typ])
rn += sn
return [indexnode, targetnode, rn], []
elif typ == 'rfc':
indexnode['entries'] = [
('single', 'RFC; RFC %s' % target, targetid, '', None)]
anchor = ''
anchorindex = target.find('#')
if anchorindex > 0:
target, anchor = target[:anchorindex], target[anchorindex:]
if not has_explicit_title:
title = "RFC " + utils.unescape(title)
try:
rfcnum = int(target)
except ValueError:
msg = inliner.reporter.error('invalid RFC number %s' % target,
line=lineno)
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
ref = inliner.document.settings.rfc_base_url + inliner.rfc_url % rfcnum
sn = nodes.strong(title, title)
rn = nodes.reference('', '', internal=False, refuri=ref+anchor,
classes=[typ])
rn += sn
return [indexnode, targetnode, rn], []
开发者ID:JelteF,项目名称:sphinx,代码行数:60,代码来源:roles.py
示例2: wikipedia_role
def wikipedia_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
has_title, title, target = split_explicit_title(text)
title = utils.unescape(title)
target = utils.unescape(target)
target = target.replace(' ', '_')
refnode = nodes.reference(title, title, refuri=WIKIPEDIA_URI % target)
return [refnode], []
开发者ID:JamesLinus,项目名称:xinu,代码行数:7,代码来源:xinusource.py
示例3: __call__
def __call__(self, name, rawtext, text, lineno, inliner,
options={}, content=[]):
text = docutils.utils.unescape(text)
has_title, title, reftext = split_explicit_title(text)
warnings = []
try:
where, what = self.find_ref(reftext)
url = self.to_url(where, what)
if not has_title:
title = self.to_title(where, what)
except JavarefError as e:
url = None
warnings.append(e.reason)
if url:
# if no scheme, assume a local path relative to the src root
if not urlparse(url).scheme:
docdir = os.path.dirname(inliner.document.current_source)
if docdir != self.env.srcdir:
url = os.path.relpath(self.env.srcdir, docdir) + '/' + url
ref = docutils.nodes.reference('', '', internal=False, refuri=url)
ref.append(docutils.nodes.literal(rawsource=title, text=title))
else:
ref = docutils.nodes.literal(rawsource=title, text=title)
return [ref], [inliner.reporter.warning(w, line=lineno) for w in warnings]
开发者ID:rlepinski,项目名称:sphinx-javalink,代码行数:29,代码来源:ref.py
示例4: blogref_role
def blogref_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
"""
Inserts a reference to the blog entry of the specified date.
Instead of writing ``:doc:`/blog/2011/0406```
it is better to write ``:blogref:`20110406```
because the latter works between Sphinx trees and also supports archived blog entries.
"""
# thanks to http://docutils.sourceforge.net/docs/howto/rst-roles.html
# this code originally from roles.pep_reference_role
#~ print 20130315, rawtext, text, utils.unescape(text)
has_explicit_title, title, target = split_explicit_title(text)
try:
date = i2d(int(target))
except ValueError:
msg = inliner.reporter.error(
'Invalid text %r: must be an integer date of style "20130315" .'
% text, line=lineno)
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
#~ print repr(env)
#~ raise Exception(20130315)
#~ ref = inliner.document.settings.pep_base_url
#~ + inliner.document.settings.pep_file_url_template % date)
roles.set_classes(options)
#~ from django.conf import settings
#~ shown_text = settings.SITE.dtos(date)
env = inliner.document.settings.env
if not has_explicit_title:
title = date.strftime(env.settings.get('today_fmt', '%Y-%m-%d'))
title = utils.unescape(title)
return [nodes.reference(rawtext, title,
refuri=get_blog_url(date),
**options)], []
开发者ID:ManuelWeidmann,项目名称:atelier,代码行数:35,代码来源:base.py
示例5: user_role
def user_role(name, rawtext, text, lineno, inliner, options=None, content=None):
"""Sphinx role for linking to a user profile. Defaults to linking to
Github profiles, but the profile URIS can be configured via the
``issues_user_uri`` config value.
Examples: ::
:user:`sloria`
Anchor text also works: ::
:user:`Steven Loria <sloria>`
"""
options = options or {}
content = content or []
has_explicit_title, title, target = split_explicit_title(text)
target = utils.unescape(target).strip()
title = utils.unescape(title).strip()
config = inliner.document.settings.env.app.config
if config.issues_user_uri:
ref = config.issues_user_uri.format(user=target)
else:
ref = "https://github.com/{0}".format(target)
if has_explicit_title:
text = title
else:
text = "@{0}".format(target)
link = nodes.reference(text=text, refuri=ref, **options)
return [link], []
开发者ID:sloria,项目名称:sphinx-issues,代码行数:31,代码来源:sphinx_issues.py
示例6: coderef_role
def coderef_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
text = utils.unescape(text)
has_explicit_title, title, target = split_explicit_title(text)
try:
modname, name = target.rsplit('.', 1)
except ValueError:
raise Exception("Don't know how to import name %s" % target)
mod = import_module(modname)
try:
value = getattr(mod, name, None)
except AttributeError:
raise Exception("No name '%s' in module '%s'" % (name, modname))
#~ raise Exception("20130908 %s " % lines)
if isinstance(value, type):
if value.__module__ != modname:
raise Exception("20130908 %r != %r" % (value.__module__, modname))
url = srcref(mod)
lines, line_no = inspect.getsourcelines(value)
if line_no:
url += "#" + str(line_no)
if not has_explicit_title:
pass
pnode = nodes.reference(title, title, internal=False, refuri=url)
return [pnode], []
开发者ID:ManuelWeidmann,项目名称:atelier,代码行数:27,代码来源:base.py
示例7: blogref_role
def blogref_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
# thanks to http://docutils.sourceforge.net/docs/howto/rst-roles.html
# this code originally from roles.pep_reference_role
#~ print 20130315, rawtext, text, utils.unescape(text)
has_explicit_title, title, target = split_explicit_title(text)
try:
date = i2d(int(target))
except ValueError:
msg = inliner.reporter.error(
'Invalid text %r: must be an integer date of style "20130315" .'
% text, line=lineno)
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
#~ print repr(env)
#~ raise Exception(20130315)
#~ ref = inliner.document.settings.pep_base_url
#~ + inliner.document.settings.pep_file_url_template % date)
roles.set_classes(options)
#~ from django.conf import settings
#~ shown_text = settings.SITE.dtos(date)
env = inliner.document.settings.env
if not has_explicit_title:
title = date.strftime(env.settings.get('today_fmt', '%Y-%m-%d'))
title = utils.unescape(title)
return [nodes.reference(rawtext, title,
refuri=get_blog_url(env, date),
**options)], []
开发者ID:lino-framework,项目名称:atelier,代码行数:27,代码来源:base.py
示例8: php_class_role
def php_class_role(typ, rawtext, text, lineno, inliner, options={},
content=[]):
text = utils.unescape(text)
env = inliner.document.settings.env
base_url = env.app.config.api_url
has_explicit_title, title, full_class = split_explicit_title(text)
try:
full_url = base_url % full_class.replace('\\', '/') + '.html'
except (TypeError, ValueError):
env.warn(
env.docname, 'unable to expand %s api_url with base '
'URL %r, please make sure the base contains \'%%s\' '
'exactly once' % (typ, base_url))
full_url = base_url + utils.escape(full_class)
if not has_explicit_title:
class_name = full_class.lstrip('\\')
ns = class_name.rfind('\\')
if ns != -1:
class_name = class_name[ns + 1:]
title = class_name
list = [
nodes.reference(
title, title, internal=False, refuri=full_url, reftitle=full_class)
]
pnode = nodes.literal('', '', *list)
return [pnode], []
开发者ID:o,项目名称:DarkTranslationBundle,代码行数:27,代码来源:phpcode.py
示例9: php_phpfunction_role
def php_phpfunction_role(typ,
rawtext,
text,
lineno,
inliner,
options={},
content=[]):
text = utils.unescape(text)
has_explicit_title, title, full_function = split_explicit_title(text)
full_url = 'http://php.net/manual/en/function.%s.php' % lower(
full_function.replace('_', '-'))
if not has_explicit_title:
title = full_function
list = [
nodes.reference(
title,
title,
internal=False,
refuri=full_url,
reftitle=full_function)
]
pnode = nodes.literal('', '', *list)
return [pnode], []
开发者ID:o,项目名称:DarkTranslationBundle,代码行数:25,代码来源:phpcode.py
示例10: find_doxygen_link
def find_doxygen_link(name, rawtext, text, lineno, inliner, options={}, content=[]):
text = utils.unescape(text)
# from :name:`title <part>`
has_explicit_title, title, part = split_explicit_title(text)
warning_messages = []
if tag_file:
url = find_url(tag_file, part)
try:
url = find_url2(app.env.doxylink_cache[cache_name]['mapping'], part)
except LookupError as error:
warning_messages.append('Error while parsing `%s`. Is not a well-formed C++ function call or symbol. If this is not the case, it is a doxylink bug so please report it. Error reported was: %s' % (part, error))
if url:
#If it's an absolute path then the link will work regardless of the document directory
#Also check if it is a URL (i.e. it has a 'scheme' like 'http' or 'file')
if os.path.isabs(rootdir) or urlparse.urlparse(rootdir).scheme:
full_url = join(rootdir, url['file'])
#But otherwise we need to add the relative path of the current document to the root source directory to the link
else:
relative_path_to_docsrc = os.path.relpath(app.env.srcdir, os.path.dirname(inliner.document.current_source))
full_url = join(relative_path_to_docsrc, '/', rootdir, url['file']) #We always use the '/' here rather than os.sep since this is a web link avoids problems like documentation/.\../library/doc/ (mixed slashes)
if url['kind'] == 'function' and app.config.add_function_parentheses and not normalise(title)[1]:
title = join(title, '()')
pnode = nodes.reference(title, title, internal=False, refuri=full_url)
return [pnode], []
#By here, no match was found
warning_messages.append('Could not find match for `%s` in `%s` tag file' % (part, tag_filename))
else:
warning_messages.append('Could not find match for `%s` because tag file not found' % (part))
pnode = nodes.inline(rawsource=title, text=title)
return [pnode], [inliner.reporter.warning(message, line=lineno) for message in warning_messages]
开发者ID:ColinGilbert,项目名称:accidental-noise-library,代码行数:34,代码来源:doxylink.py
示例11: index_role
def index_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
# create new reference target
env = inliner.document.settings.env
targetid = 'index-%s' % env.new_serialno('index')
targetnode = nodes.target('', '', ids=[targetid])
# split text and target in role content
has_explicit_title, title, target = split_explicit_title(text)
title = utils.unescape(title)
target = utils.unescape(target)
# if an explicit target is given, we can process it as a full entry
if has_explicit_title:
entries = process_index_entry(target, targetid)
# otherwise we just create a "single" entry
else:
# but allow giving main entry
main = ''
if target.startswith('!'):
target = target[1:]
title = title[1:]
main = 'main'
entries = [('single', target, targetid, main)]
indexnode = addnodes.index()
indexnode['entries'] = entries
set_role_source_info(inliner, lineno, indexnode)
textnode = nodes.Text(title, title)
return [indexnode, targetnode, textnode], []
开发者ID:QuLogic,项目名称:sphinx,代码行数:26,代码来源:roles.py
示例12: arxiv_role
def arxiv_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
text = utils.unescape(text)
has_explicit_title, title, part = split_explicit_title(text)
full_url = 'https://arxiv.org/abs/' + part
if not has_explicit_title:
title = 'arXiv:' + part
pnode = nodes.reference(title, title, internal=False, refuri=full_url)
return [pnode], []
开发者ID:BranYang,项目名称:scipy,代码行数:8,代码来源:doi_role.py
示例13: role
def role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
text = utils.unescape(text)
has_explicit_title, symbol, title = split_explicit_title(text)
try:
kind, filename, anchor = lookup_url(app, tagfile, symbol)
except KeyError, e:
inliner.reporter.warning(unicode(e.args[0]), line=lineno)
return [nodes.Text(title)], []
开发者ID:erebot,项目名称:buildenv,代码行数:8,代码来源:doxylinks.py
示例14: gh_issue
def gh_issue(typ, rawtext, text, lineno, inliner, options={}, content=[]):
text = utils.unescape(text)
has_explicit_title, title, part = split_explicit_title(text)
if not has_explicit_title:
title = 'issue #%s' % part
full_url = 'https://github.com/cms-dev/cms/issues/%s' % part
retnode = nodes.reference(title, title, internal=False, refuri=full_url, **options)
return [retnode], []
开发者ID:PJeBeK,项目名称:cms,代码行数:9,代码来源:gh_links.py
示例15: gh_blob
def gh_blob(typ, rawtext, text, lineno, inliner, options={}, content=[]):
text = utils.unescape(text)
has_explicit_title, title, part = split_explicit_title(text)
if not has_explicit_title:
title = part
full_url = 'https://github.com/cms-dev/cms/blob/v%s/%s' % (app.config.release, part)
refnode = nodes.reference(title, title, internal=False, refuri=full_url, **options)
return [refnode], []
开发者ID:PJeBeK,项目名称:cms,代码行数:9,代码来源:gh_links.py
示例16: php_phpclass_role
def php_phpclass_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
text = utils.unescape(text)
has_explicit_title, title, full_class = split_explicit_title(text)
full_url = 'http://php.net/manual/en/class.%s.php' % string.lower(full_class)
if not has_explicit_title:
title = full_class
list = [nodes.reference(title, title, internal=False, refuri=full_url, reftitle=full_class)]
pnode = nodes.literal('', '', *list)
return [pnode], []
开发者ID:siciarek,项目名称:SiciarekJsTransBundle,代码行数:11,代码来源:phpcode.py
示例17: icon_role
def icon_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
has_explicit_title, label, target = split_explicit_title(text)
css_class = target
label = label if has_explicit_title else class_to_label(css_class)
config = inliner.document.settings.env.config
if config._raw_config['tags'].eval_condition('html'):
return [IconNode(css_class=css_class, label=label)], []
return [nodes.Text(label)], []
开发者ID:jdestefano-mongo,项目名称:docs-tools,代码行数:11,代码来源:icon.py
示例18: gh_tree
def gh_tree(typ, rawtext, text, lineno, inliner, options={}, content=[]):
text = utils.unescape(text)
has_explicit_title, title, part = split_explicit_title(text)
if not has_explicit_title:
title = part
full_url = 'https://github.com/cms-dev/cms/tree/v%s/%s' % (app.config.release, part)
refnode = nodes.reference(title, title, internal=False, refuri=full_url, **options)
retnode = nodes.literal(role=typ.lower(), classes=[typ])
retnode += refnode
return [retnode], []
开发者ID:Corea,项目名称:cms,代码行数:11,代码来源:gh_links.py
示例19: releaseref_role
def releaseref_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
config = inliner.document.settings.env.config
text = text.replace("|version|", config.version)
text = text.replace("|release|", config.release)
has_explicit_title, title, target = split_explicit_title(text)
if not has_explicit_title:
title = os.path.basename(target)
node = nodes.reference(rawtext, title, refuri=target, **options)
return [node], []
开发者ID:492580195,项目名称:livestreamer,代码行数:12,代码来源:ext_releaseref.py
示例20: role
def role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
has_explicit, title, other = split_explicit_title(utils.unescape(text))
args = [other]
if use_explicit:
args.append(has_explicit)
result = func(*args)
if isinstance(result, (list, tuple)):
url, title = result
else:
url = result
node = nodes.raw("", u"<a href='{url}'>{title}</a>".format(title=title, url=html_escape(url)), format="html")
return [node], []
开发者ID:AuggieH,项目名称:doc-kurento-readthedocs,代码行数:12,代码来源:__init__.py
注:本文中的sphinx.util.nodes.split_explicit_title函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论