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


Python addnodes.pending_xref方法代码示例

本文整理汇总了Python中sphinx.addnodes.pending_xref方法的典型用法代码示例。如果您正苦于以下问题:Python addnodes.pending_xref方法的具体用法?Python addnodes.pending_xref怎么用?Python addnodes.pending_xref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sphinx.addnodes的用法示例。


在下文中一共展示了addnodes.pending_xref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: resolve_required_by_xrefs

# 需要导入模块: from sphinx import addnodes [as 别名]
# 或者: from sphinx.addnodes import pending_xref [as 别名]
def resolve_required_by_xrefs(app, env, node, contnode):
    """Now that all recipes and packages have been parsed, we are called here
    for each ``pending_xref`` node that sphinx has not been able to resolve.

    We handle specifically the ``requiredby`` reftype created by the
    `RequiredByField` fieldtype allowed in ``conda:package::``
    directives, where we replace the ``pending_ref`` node with a bullet
    list of reference nodes pointing to the package pages that
    "depended" on the package.
    """
    if node['reftype'] == 'requiredby' and node['refdomain'] == 'conda':
        target = node['reftarget']
        docname = node['refdoc']
        backrefs = env.domains['conda'].data['backrefs'].get(target, set())
        listnode = nodes.bullet_list()
        for back_docname, back_target in backrefs:
            par = nodes.paragraph()
            name_node = addnodes.literal_strong(back_target, back_target,
                                      classes=['xref', 'backref'])
            refnode = make_refnode(app.builder, docname,
                                   back_docname, back_target, name_node)
            refnode.set_class('conda-package')
            par += refnode
            listnode += nodes.list_item('', par)
        return listnode 
开发者ID:bioconda,项目名称:bioconda-utils,代码行数:27,代码来源:sphinxext.py

示例2: resolve_xref

# 需要导入模块: from sphinx import addnodes [as 别名]
# 或者: from sphinx.addnodes import pending_xref [as 别名]
def resolve_xref(self, env: BuildEnvironment, fromdocname: str,
                     builder, role, target, node, contnode):
        """Resolve the ``pending_xref`` **node** with the given **role** and **target**."""
        for objtype in self.objtypes_for_role(role) or []:
            if (objtype, target) in self.data['objects']:
                node = make_refnode(
                    builder, fromdocname,
                    self.data['objects'][objtype, target][0],
                    self.data['objects'][objtype, target][1],
                    contnode, target + ' ' + objtype)
                node.set_class('conda-package')
                return node

            if objtype == "package":
                for channel, urlformat in env.app.config.bioconda_other_channels.items():
                    if RepoData().get_package_data(channels=channel, name=target):
                        uri = urlformat.format(target)
                        node = nodes.reference('', '', internal=False,
                                               refuri=uri, classes=[channel])
                        node += contnode
                        return node

        return None  # triggers missing-reference 
开发者ID:bioconda,项目名称:bioconda-utils,代码行数:25,代码来源:sphinxext.py

示例3: make_xref

# 需要导入模块: from sphinx import addnodes [as 别名]
# 或者: from sphinx.addnodes import pending_xref [as 别名]
def make_xref(self, rolename, domain, target,
                  innernode=d_nodes.emphasis, contnode=None, env=None):

        if not rolename:
            return contnode or innernode(target, target)

        title = target
        if domain == 'eql' and rolename == 'type':
            target = EQLTypeXRef.filter_target(target)
            if target in EQLTypedField.ignored_types:
                return d_nodes.Text(title)

        refnode = s_nodes.pending_xref('', refdomain=domain,
                                       refexplicit=title != target,
                                       reftype=rolename, reftarget=target)
        refnode += contnode or innernode(title, title)
        if env:
            env.domains[domain].process_field_xref(refnode)

        refnode['eql-auto-link'] = True
        return refnode 
开发者ID:edgedb,项目名称:edgedb,代码行数:23,代码来源:eql.py

示例4: mps_ref_role

# 需要导入模块: from sphinx import addnodes [as 别名]
# 或者: from sphinx.addnodes import pending_xref [as 别名]
def mps_ref_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
    textnode = nodes.Text(text)
    if text.startswith('.'):
        # Tag is relative to current prefix and so points elsewhere
        # in this document, so create reference node.
        try:
            targetid = inliner.document.mps_tag_prefix + text
            refnode = nodes.reference('', '', refid=targetid, *[textnode])
        except AttributeError:
            return [textnode], [inliner.document.reporter.warning
                                (':mps:ref without mps:prefix', line=lineno)]
    else:
        # Tag is absolute: need to create pending_xref node.
        refnode = addnodes.pending_xref('', refdomain='std', reftarget=text,
                                        reftype='view')
        refnode += textnode
    return [refnode], [] 
开发者ID:georgia-tech-db,项目名称:eva,代码行数:19,代码来源:__init__.py

示例5: add_class_def

# 需要导入模块: from sphinx import addnodes [as 别名]
# 或者: from sphinx.addnodes import pending_xref [as 别名]
def add_class_def(node, classDef):
    """Add reference on classDef to node """

    ref = addnodes.pending_xref(
        reftarget=classDef,
        reftype="class",
        refdomain="py",  # py:class="None" py:module="altair" refdoc="user_guide/marks"
        refexplicit=False,
        # refdoc="",
        refwarn=False,
    )
    ref["py:class"] = "None"
    ref["py:module"] = "altair"

    ref += nodes.literal(text=classDef, classes=["xref", "py", "py-class"])
    node += ref
    return node 
开发者ID:altair-viz,项目名称:altair,代码行数:19,代码来源:schematable.py

示例6: resolve_xref

# 需要导入模块: from sphinx import addnodes [as 别名]
# 或者: from sphinx.addnodes import pending_xref [as 别名]
def resolve_xref(self, env, fromdocname, builder, typ, target,
                     node, contnode):
        try:
            info = self.data[str(typ)][target]
        except KeyError:
            text = contnode.rawsource
            role = self.roles.get(typ)
            if role is None:
                return nodes.emphasis(text, text)
            resnode = role.result_nodes(env.get_doctree(fromdocname),
                                        env, node, None)[0][0]
            if isinstance(resnode, addnodes.pending_xref):
                text = node[0][0]
                reporter = env.get_doctree(fromdocname).reporter
                reporter.error('Cannot resolve reference to %r' % text,
                               line=node.line)
                return nodes.problematic(text, text)
            return resnode
        else:
            anchor = http_resource_anchor(typ, target)
            title = typ.upper() + ' ' + target
            return make_refnode(builder, fromdocname, info[0], anchor,
                                contnode, title) 
开发者ID:preems,项目名称:nltk-server,代码行数:25,代码来源:httpdomain.py

示例7: label_ref_node

# 需要导入模块: from sphinx import addnodes [as 别名]
# 或者: from sphinx.addnodes import pending_xref [as 别名]
def label_ref_node(docname, ref_to, title):
    """Generate a node that references a label"""
    txt = Text(title, rawsource=title)
    newchild = inline(
        ':ref:`%s`' % ref_to,
        '',
        txt,
        classes=['xref', 'std', 'std-ref']
    )
    newnode = pending_xref(
        ':ref:`%s`' % ref_to,
        newchild,
        reftype='ref',
        refwarn='True',
        reftarget=ref_to,
        refexplicit='False',
        refdomain='std',
        refdoc=docname
    )
    return newnode 
开发者ID:jantman,项目名称:awslimitchecker,代码行数:22,代码来源:conf.py

示例8: meth_ref_node

# 需要导入模块: from sphinx import addnodes [as 别名]
# 或者: from sphinx.addnodes import pending_xref [as 别名]
def meth_ref_node(docname, ref_to, title=None):
    """Generate a node that references a :py:meth:"""
    if title is None:
        title = ref_to
    txt = Text(title, rawsource=title)
    newchild = literal(
        ':py:meth:`%s`' % ref_to,
        '',
        txt,
        classes=['xref', 'py', 'py-meth']
    )
    newnode = pending_xref(
        ':py:meth:`%s`' % ref_to,
        newchild,
        reftype='meth',
        refwarn='True',
        reftarget=ref_to,
        refexplicit='False',
        refdomain='py',
        refdoc=docname
    )
    return newnode 
开发者ID:jantman,项目名称:awslimitchecker,代码行数:24,代码来源:conf.py

示例9: append_type

# 需要导入模块: from sphinx import addnodes [as 别名]
# 或者: from sphinx.addnodes import pending_xref [as 别名]
def append_type(self, node, typ):
        typ, generic_types, is_array = parse_type_signature(typ)
        tnode = addnodes.pending_xref(
            '', refdomain='csharp', reftype='type',
            reftarget=typ, modname=None, classname=None)
        if not self.has_parent():
            tnode['csharp:parent'] = None
        else:
            tnode['csharp:parent'] = self.get_parent()
        tnode += nodes.Text(shorten_type(typ))
        node += tnode
        if generic_types:
            node += nodes.Text('<')
            for i, typ_param in enumerate(generic_types):
                self.append_type(node, typ_param)
                if i != len(generic_types)-1:
                    node += nodes.Text(', ')
            node += nodes.Text('>')
        if is_array:
            node += nodes.Text('[]') 
开发者ID:djungelorm,项目名称:sphinx-csharp,代码行数:22,代码来源:csharp.py

示例10: transform_content

# 需要导入模块: from sphinx import addnodes [as 别名]
# 或者: from sphinx.addnodes import pending_xref [as 别名]
def transform_content(self, contentnode):
        config = self.env.ref_context['cfg:config']
        if 'nolist' not in self.options:
            contentnode.insert(0, cfgconfig(config, self.env.ref_context['cfg:context']))
        else:
            par = nodes.paragraph('')
            par += nodes.Text("See ")
            par += addnodes.pending_xref(config,
                                         nodes.Text(config),
                                         refdomain='cfg',
                                         reftype='config',
                                         reftarget=config)
            par += nodes.Text(" for a list of further options.")
            contentnode.insert(0, par)
        super().transform_content(contentnode) 
开发者ID:tenpy,项目名称:tenpy,代码行数:17,代码来源:sphinx_cfg_options.py

示例11: handle_signature

# 需要导入模块: from sphinx import addnodes [as 别名]
# 或者: from sphinx.addnodes import pending_xref [as 别名]
def handle_signature(self, sig, signode):
        name = sig
        config = self.options.get('config', self.env.ref_context.get('cfg:config', ""))
        if not config:
            logger.warning("config option with unknown config", location=signode)
            config = "UNKNOWN"
        fullname = config + '.' + name

        signode += addnodes.desc_annotation('option ', 'option ')
        if not self.env.ref_context.get('cfg:in-config', False):
            signode += addnodes.pending_xref(sig,
                                             addnodes.desc_addname(config, config),
                                             refdomain='cfg',
                                             reftype='config',
                                             reftarget=config)
            signode += addnodes.desc_addname('', '.')

        signode += addnodes.desc_name(sig, '', nodes.Text(sig))

        typ = self.options.get('type')
        if typ:
            type_node = addnodes.desc_annotation(': ', ': ')
            info = self.content.parent.info(1)  # might be off by a few lines...
            type_node.extend(_parse_inline(self.state, typ, info))
            signode += type_node

        defaultvalue = self.options.get('default')
        if defaultvalue:
            val_node = addnodes.desc_annotation(' = ', ' = ')
            val_node += nodes.literal(defaultvalue, defaultvalue)
            signode += val_node

        return fullname, config 
开发者ID:tenpy,项目名称:tenpy,代码行数:35,代码来源:sphinx_cfg_options.py

示例12: make_field

# 需要导入模块: from sphinx import addnodes [as 别名]
# 或者: from sphinx.addnodes import pending_xref [as 别名]
def make_field(self, types, domain, item, env=None):
        fieldname = nodes.field_name('', self.label)
        backref = addnodes.pending_xref(
            '',
            refdomain="conda",
            reftype='requiredby', refexplicit=False,
            reftarget=env.ref_context['conda:package'],
            refdoc=env.docname
        )
        backref += nodes.inline('', '')
        fieldbody = nodes.field_body('', backref)
        return nodes.field('', fieldname, fieldbody) 
开发者ID:bioconda,项目名称:bioconda-utils,代码行数:14,代码来源:sphinxext.py

示例13: create_node

# 需要导入模块: from sphinx import addnodes [as 别名]
# 或者: from sphinx.addnodes import pending_xref [as 别名]
def create_node(env, relative_path, show_button):
    """
    Creates documentation node for example include.

    :param env: environment of the documentation
    :param relative_path: path of the code
    :param show_button: whether to show "view code" button
    :return paragraph with the node
    """
    pagename = "_modules/" + relative_path[:-3]

    header_classes = ["example-header"]
    if show_button:
        header_classes += ["example-header--with-button"]
    paragraph = nodes.paragraph(relative_path, classes=header_classes)
    paragraph += nodes.inline("", relative_path, classes=["example-title"])
    if show_button:
        pending_ref = addnodes.pending_xref(
            "",
            reftype="viewcode",
            refdomain="std",
            refexplicit=False,
            reftarget=pagename,
            refid="",
            refdoc=env.docname,
            classes=["example-header-button viewcode-button"],
        )
        pending_ref += nodes.inline("", _("View Source"))
        paragraph += pending_ref

    return paragraph


# noinspection PyProtectedMember
# pylint: disable=protected-access 
开发者ID:apache,项目名称:airflow,代码行数:37,代码来源:exampleinclude.py

示例14: run

# 需要导入模块: from sphinx import addnodes [as 别名]
# 或者: from sphinx.addnodes import pending_xref [as 别名]
def run(self):
        ad = super(PluralDirective, self).run()
        refs = sum(1 for node in ad[0][0]
                   if isinstance(node, (addnodes.pending_xref,
                                        nodes.Referential)))
        if refs > 1:
            ad[0].plural = True
        return ad 
开发者ID:georgia-tech-db,项目名称:eva,代码行数:10,代码来源:__init__.py

示例15: replace_pending_xref_refdoc

# 需要导入模块: from sphinx import addnodes [as 别名]
# 或者: from sphinx.addnodes import pending_xref [as 别名]
def replace_pending_xref_refdoc(node, new_refdoc):
    """
    Overwrites the refdoc attribute of all pending_xref nodes.
    This is needed, if a doctree with references gets copied used somewhereelse in the documentation.
    What is the normal case when using needextract.
    :param node: doctree
    :param new_refdoc: string, should be an existing docname
    :return: None
    """
    from sphinx.addnodes import pending_xref
    if isinstance(node, pending_xref):
        node.attributes['refdoc'] = new_refdoc
    else:
        for child in node.children:
            replace_pending_xref_refdoc(child, new_refdoc) 
开发者ID:useblocks,项目名称:sphinxcontrib-needs,代码行数:17,代码来源:layout.py


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