當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。