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


Python nodes.split_explicit_title方法代码示例

本文整理汇总了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 
开发者ID:Kurento,项目名称:doc-kurento,代码行数:19,代码来源:wikipedia.py

示例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], [] 
开发者ID:scikit-multiflow,项目名称:scikit-multiflow,代码行数:30,代码来源:sphinx_issues.py

示例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], [] 
开发者ID:streamlink,项目名称:streamlink,代码行数:14,代码来源:ext_releaseref.py

示例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], [] 
开发者ID:future-architect,项目名称:typescript-guide,代码行数:13,代码来源:numdoc.py

示例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], [] 
开发者ID:future-architect,项目名称:typescript-guide,代码行数:10,代码来源:rawlatex.py

示例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], [] 
开发者ID:scikit-optimize,项目名称:scikit-optimize,代码行数:29,代码来源:sphinx_issues.py

示例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], [] 
开发者ID:scikit-optimize,项目名称:scikit-optimize,代码行数:17,代码来源:sphinx_issues.py

示例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], [] 
开发者ID:paris-saclay-cds,项目名称:ramp-workflow,代码行数:30,代码来源:sphinx_issues.py

示例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], [] 
开发者ID:facebookresearch,项目名称:detectron2,代码行数:31,代码来源:conf.py

示例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], [] 
开发者ID:pytroll,项目名称:satpy,代码行数:10,代码来源:doi_role.py

示例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], [] 
开发者ID:pytroll,项目名称:satpy,代码行数:10,代码来源:doi_role.py

示例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], [] 
开发者ID:casact,项目名称:chainladder-python,代码行数:30,代码来源:sphinx_issues.py


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