本文整理汇总了Python中sphinx.util.nodes.split_explicit_title方法的典型用法代码示例。如果您正苦于以下问题:Python nodes.split_explicit_title方法的具体用法?Python nodes.split_explicit_title怎么用?Python nodes.split_explicit_title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sphinx.util.nodes
的用法示例。
在下文中一共展示了nodes.split_explicit_title方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: gen_role
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import split_explicit_title [as 别名]
def gen_role(func, use_explicit=False):
@wraps(func)
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], []
return role
示例2: user_role
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import split_explicit_title [as 别名]
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.
Example: ::
:user:`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], []
示例3: releaseref_role
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import split_explicit_title [as 别名]
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], []
示例4: numdoc_role
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import split_explicit_title [as 别名]
def numdoc_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
"""Role for making latex ref to the doc head."""
env = inliner.document.settings.env
text = utils.unescape(text)
has_explicit, title, target = split_explicit_title(text)
pnode = nodes.inline(rawtext, title, classes=['xref','doc'])
pnode['reftarget'] = target
return [pnode], []
示例5: tex_role
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import split_explicit_title [as 别名]
def tex_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
"""Role for inserting latex code as is."""
text = utils.unescape(text, restore_backslashes=True)
has_explicit, texsnipet, target = split_explicit_title(text)
pnode = nodes.raw(rawtext, texsnipet, format='latex')
return [pnode], []
示例6: user_role
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import split_explicit_title [as 别名]
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], []
示例7: cve_role
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import split_explicit_title [as 别名]
def cve_role(name, rawtext, text, lineno, inliner, options=None, content=None):
"""Sphinx role for linking to a CVE on https://cve.mitre.org.
Examples: ::
:cve:`CVE-2018-17175`
"""
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()
ref = "https://cve.mitre.org/cgi-bin/cvename.cgi?name={0}".format(target)
text = title if has_explicit_title else target
link = nodes.reference(text=text, refuri=ref, **options)
return [link], []
示例8: user_role
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import split_explicit_title [as 别名]
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.
Example: ::
:user:`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/{}'.format(target)
if has_explicit_title:
text = title
else:
text = '@{}'.format(target)
link = nodes.reference(text=text, refuri=ref, **options)
return [link], []
示例9: paper_ref_role
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import split_explicit_title [as 别名]
def paper_ref_role(
typ: str,
rawtext: str,
text: str,
lineno: int,
inliner,
options: Dict = {},
content: List[str] = [],
):
"""
Parse :paper:`xxx`. Similar to the "extlinks" sphinx extension.
"""
from docutils import nodes, utils
from sphinx.util.nodes import split_explicit_title
text = utils.unescape(text)
has_explicit_title, title, link = split_explicit_title(text)
link = link.lower()
if link not in _PAPER_DATA:
inliner.reporter.warning("Cannot find paper " + link)
paper_url, paper_title = "#", link
else:
paper_url, paper_title = _PAPER_DATA[link]
if "/" not in paper_url:
paper_url = "https://arxiv.org/abs/" + paper_url
if not has_explicit_title:
title = paper_title
pnode = nodes.reference(title, title, internal=False, refuri=paper_url)
return [pnode], []
示例10: doi_role
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import split_explicit_title [as 别名]
def doi_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
text = utils.unescape(text)
has_explicit_title, title, part = split_explicit_title(text)
full_url = 'https://doi.org/' + part
if not has_explicit_title:
title = 'DOI:' + part
pnode = nodes.reference(title, title, internal=False, refuri=full_url)
return [pnode], []
示例11: arxiv_role
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import split_explicit_title [as 别名]
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], []
示例12: user_role
# 需要导入模块: from sphinx.util import nodes [as 别名]
# 或者: from sphinx.util.nodes import split_explicit_title [as 别名]
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.
Example: ::
:user:`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], []