• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python nodes.make_refnode函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sphinx.util.nodes.make_refnode函数的典型用法代码示例。如果您正苦于以下问题:Python make_refnode函数的具体用法?Python make_refnode怎么用?Python make_refnode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: resolve_xref

	def resolve_xref(self, env, fromdocname, builder,
					typ, target, node, contnode):
		#print 'resolve_xref(%s)'%node
		if typ == 'module' and target in self.data['modules']:
			docname, synopsis, deprecated = self.data['modules'].get(target, ('','',''))
			if docname:
				return make_refnode(builder, fromdocname, docname, target, contnode, synopsis)
			else:
				return None
		#if typ == 'query' and target in self.data['modules']:
		#	docname, synopsis, deprecated = self.data['modules'].get(target, ('','',''))
		#	if not docname:
		#		return None
		#	else:
		#		title = '%s%s' % (synopsis, (deprecated and ' (deprecated)' or ''))
		#		return make_refnode(builder, fromdocname, docname,
		#							'module-' + target, contnode, title)
		else:
			modname = node.get('nscp:module')
			command = node.get('nscp:command')
			confpath = node.get('nscp:confpath')
			name, obj = self._find_obj(env, modname, command, confpath, target, typ)
			if not obj:
				return None
			else:
				return make_refnode(builder, fromdocname, obj, name,
									contnode, name)
开发者ID:lazyfrosch,项目名称:nscp,代码行数:27,代码来源:nscp.py


示例2: resolve_xref

    def resolve_xref(self, env, fromdocname, builder,
                     type, target, node, contnode):
        modname = node.get('py:module')
        clsname = node.get('py:class')
        searchmode = node.hasattr('refspecific') and 1 or 0
        matches = self.find_obj(env, modname, clsname, target,
                                type, searchmode)
        if not matches:
            return None
        elif len(matches) > 1:
            env.warn_node(
                'more than one target found for cross-reference '
                '%r: %s' % (target, ', '.join(match[0] for match in matches)),
                node)
        name, obj = matches[0]

        if obj[1] == 'module':
            # get additional info for modules
            docname, synopsis, platform, deprecated = self.data['modules'][name]
            assert docname == obj[0]
            title = name
            if synopsis:
                title += ': ' + synopsis
            if deprecated:
                title += _(' (deprecated)')
            if platform:
                title += ' (' + platform + ')'
            return make_refnode(builder, fromdocname, docname,
                                'module-' + name, contnode, title)
        else:
            return make_refnode(builder, fromdocname, obj[0], name,
                                contnode, name)
开发者ID:zsiddiqui2,项目名称:sphinxGit,代码行数:32,代码来源:python.py


示例3: resolve_xref

    def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):
        objects = self.data['objects']
        objtypes = self.objtypes_for_role(typ) or []

        for objtype in objtypes:
            for (typ, clspath) in objects:
                # Look up using the full classpath
                if (objtype, target) == (typ, clspath):
                    return make_refnode(
                        builder,
                        fromdocname,
                        objects[typ, clspath],
                        objtype + '-' + target,
                        contnode,
                        target + ' ' + objtype
                    )

                # Try looking it up by the class name--this lets people use
                # shorthand in their roles
                if '.' in clspath:
                    modname, clsname = split_clspath(clspath)
                    if (objtype, target) == (typ, clsname):
                        return make_refnode(
                            builder,
                            fromdocname,
                            objects[typ, clspath],
                            objtype + '-' + clspath,
                            contnode,
                            target + ' ' + objtype
                        )
开发者ID:willkg,项目名称:everett,代码行数:30,代码来源:sphinxext.py


示例4: resolve_xref

	def resolve_xref(self, env, fromdocname, builder,
					typ, target, node, contnode):
		#print 'resolve_xref(%s)'%node
		if typ == 'module' and target in self.data['modules']:
			docname, synopsis, deprecated = self.data['modules'].get(target, ('','',''))
			if docname:
				return make_refnode(builder, fromdocname, docname, target, contnode, synopsis)
			else:
				return None
		if typ == 'query' and target in self.data['modules']:
			docname, synopsis, deprecated = self.data['modules'].get(target, ('','',''))
			if not docname:
				return None
			else:
				title = '%s%s' % (synopsis, (deprecated and ' (deprecated)' or ''))
				return make_refnode(builder, fromdocname, docname,
									'module-' + target, contnode, title)
		else:
			modname = node.get('nscp:module')
			searchorder = node.hasattr('refspecific') and 1 or 0
			name, obj = self._find_obj(env, modname, target, typ, searchorder)
			if not obj:
				return None
			else:
				return make_refnode(builder, fromdocname, obj, name,
									contnode, name)
开发者ID:Vilse1202,项目名称:nscp,代码行数:26,代码来源:nscp.py


示例5: resolve_xref

 def resolve_xref(self, env, fromdocname, builder,
                  type, target, node, contnode):
     if (type == 'mod' or
         type == 'obj' and target in self.data['modules']):
         docname, synopsis, platform, deprecated = \
             self.data['modules'].get(target, ('','','', ''))
         if not docname:
             return None
         else:
             title = '%s%s%s' % ((platform and '(%s) ' % platform),
                                 synopsis,
                                 (deprecated and ' (deprecated)' or ''))
             return make_refnode(builder, fromdocname, docname,
                                 'module-' + target, contnode, title)
     else:
         modname = node.get('tcpip:module')
         clsname = node.get('tcpip:class')
         searchorder = node.hasattr('refspecific') and 1 or 0
         matches = self.find_obj(env, modname, clsname, target,
                                 type, searchorder)
         if not matches:
             return None
         elif len(matches) > 1:
             env.warn(fromdocname,
                      'more than one target found for cross-reference '
                      '%r: %s' % (target,
                                  ', '.join(match[0] for match in matches)),
                      node.line)
         name, obj = matches[0]
         return make_refnode(builder, fromdocname, obj[0], name,
                             contnode, name)
开发者ID:flyeven,项目名称:doc,代码行数:31,代码来源:tcpipdomain.py


示例6: resolve_xref

 def resolve_xref(self, env, fromdocname, builder,
                  typ, target, node, contnode):
     if (typ == 'mod' or
         typ == 'obj' and target in self.data['modules']):
         docname, synopsis, platform, deprecated = \
             self.data['modules'].get(target, ('','','', ''))
         if not docname:
             return None
         else:
             title = '%s%s%s' % ((platform and '(%s) ' % platform),
                                 synopsis,
                                 (deprecated and ' (deprecated)' or ''))
             return make_refnode(builder, fromdocname, docname,
                                 'module-' + target, contnode, title)
     else:
         modname = node.get('rb:module')
         clsname = node.get('rb:class')
         searchorder = node.hasattr('refspecific') and 1 or 0
         name, obj = self.find_obj(env, modname, clsname,
                                   target, typ, searchorder)
         if not obj:
             return None
         else:
             return make_refnode(builder, fromdocname, obj[0], name,
                                 contnode, name)
开发者ID:torcolvin,项目名称:sphinx-contrib,代码行数:25,代码来源:rubydomain.py


示例7: resolve_xref

    def resolve_xref(self, env, fromdocname, builder, type, target, node, contnode):
        modname = node.get("lua:module")
        clsname = node.get("lua:class")
        searchmode = node.hasattr("refspecific") and 1 or 0
        matches = self.find_obj(env, modname, clsname, target, type, searchmode)
        if not matches:
            return None
        elif len(matches) > 1:
            env.warn_node(
                "more than one target found for cross-reference "
                "%r: %s" % (target, ", ".join(match[0] for match in matches)),
                node,
            )
        name, obj = matches[0]

        if obj[1] == "module":
            # get additional info for modules
            docname, synopsis, platform, deprecated = self.data["modules"][name]
            assert docname == obj[0]
            title = name
            if synopsis:
                title += ": " + synopsis
            if deprecated:
                title += _(" (deprecated)")
            if platform:
                title += " (" + platform + ")"
            return make_refnode(builder, fromdocname, docname, "module-" + name, contnode, title)
        else:
            return make_refnode(builder, fromdocname, obj[0], name, contnode, name)
开发者ID:jd28,项目名称:sphinx-lua,代码行数:29,代码来源:lua.py


示例8: envy_resolve

def envy_resolve(app, doctree, fromdocname):
    objects = app.env.domaindata['envy']['objects']

    # add uplink info
    for holder in doctree.traverse(uplink_placeholder):
        obj = objects[holder.name]
        links = []
        for sp, pos, name, variants in obj.uplinks:
            signode = addnodes.desc_signature('', '')
            signode['first'] = False
            signode += make_refnode(app.builder, fromdocname, sp.docname, sp.iname + '-' + sp.name, addnodes.desc_addname(sp.name, sp.name), sp.name)
            text = ' {}: {}'.format(pos, name)
            signode += addnodes.desc_name(text, text)
            if variants is not None:
                text = ' [{}]'.format(variants)
                signode += addnodes.desc_annotation(text, text)
            links.append(signode)
        holder.replace_self(links)

    # add subnode list
    for holder in doctree.traverse(sub_placeholder):
        obj = objects[holder.name]
        add_variant = False
        for pos, name, child, variants in obj.subs:
            if variants is not None:
                add_variant = True
        table = nodes.table()
        headers = [(1, 'Address'), (1, 'Name'), (10, 'Description')]
        if add_variant:
            headers.insert(1, (1, 'Variants'))
        tgroup = nodes.tgroup(cols=len(headers))
        table += tgroup
        for colwidth, header in headers:
            tgroup += nodes.colspec(colwidth=colwidth)
        thead = nodes.thead()
        tgroup += thead
        headrow = nodes.row()
        for colwidth, header in headers:
            entry = nodes.entry()
            para = nodes.paragraph()
            entry += para
            para += nodes.Text(header, header)
            headrow += entry
        thead += headrow
        tbody = nodes.tbody()
        tgroup += tbody
        for pos, name, child, variants in obj.subs:
            row = nodes.row()
            row += wrap_text_entry(pos)
            if add_variant:
                row += wrap_text_entry('all' if variants is None else variants)
            row += wrap_text_entry(name)
            entry = nodes.entry()
            para = nodes.paragraph()
            entry += para
            para += make_refnode(app.builder, fromdocname, child.docname, child.iname + '-' + child.name, nodes.Text(child.brief, child.brief), obj.brief)
            row += entry
            tbody += row
        holder.replace_self([table])
开发者ID:plaes,项目名称:envytools,代码行数:59,代码来源:envy.py


示例9: resolve_xref

 def resolve_xref(self, env, fromdocname, builder,
                  typ, target, node, contnode):
     if typ == 'ref':
         if node['refexplicit']:
             # reference to anonymous label; the reference uses
             # the supplied link caption
             docname, labelid = self.data['anonlabels'].get(target, ('',''))
             sectname = node.astext()
         else:
             # reference to named label; the final node will
             # contain the section name after the label
             docname, labelid, sectname = self.data['labels'].get(target,
                                                                  ('','',''))
         if not docname:
             return None
         newnode = nodes.reference('', '', internal=True)
         innernode = nodes.emphasis(sectname, sectname)
         if docname == fromdocname:
             newnode['refid'] = labelid
         else:
             # set more info in contnode; in case the
             # get_relative_uri call raises NoUri,
             # the builder will then have to resolve these
             contnode = addnodes.pending_xref('')
             contnode['refdocname'] = docname
             contnode['refsectname'] = sectname
             newnode['refuri'] = builder.get_relative_uri(
                 fromdocname, docname)
             if labelid:
                 newnode['refuri'] += '#' + labelid
         newnode.append(innernode)
         return newnode
     elif typ == 'keyword':
         # keywords are oddballs: they are referenced by named labels
         docname, labelid, _ = self.data['labels'].get(target, ('','',''))
         if not docname:
             return None
         return make_refnode(builder, fromdocname, docname,
                             labelid, contnode)
     elif typ == 'option':
         progname = node['refprogram']
         docname, labelid = self.data['progoptions'].get((progname, target),
                                                         ('', ''))
         if not docname:
             return None
         return make_refnode(builder, fromdocname, docname,
                             labelid, contnode)
     else:
         objtypes = self.objtypes_for_role(typ) or []
         for objtype in objtypes:
             if (objtype, target) in self.data['objects']:
                 docname, labelid = self.data['objects'][objtype, target]
                 break
         else:
             docname, labelid = '', ''
         if not docname:
             return None
         return make_refnode(builder, fromdocname, docname,
                             labelid, contnode)
开发者ID:qsnake,项目名称:sphinx,代码行数:59,代码来源:std.py


示例10: resolve_xref

 def resolve_xref(self, env, fromdocname, builder, type, target, node, contnode):
     if type == 'obj':
         obj = self.data['objects'].get(target)
         if obj is not None:
             return make_refnode(builder, fromdocname, obj.docname, obj.iname + '-' + obj.name, contnode, obj.brief)
     else:
         obj = self.data['genobjs'].get(target)
         if obj is not None:
             return make_refnode(builder, fromdocname, obj.docname, target, contnode, obj.brief)
开发者ID:envytools,项目名称:envytools,代码行数:9,代码来源:envy.py


示例11: resolve_xref

    def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):
        if typ == 'ref':
            nodeargs = self.data['refnodes'].get(target, None)
            if nodeargs is not None:
                todocname = nodeargs[0]
                targetid = nodeargs[1]
                return make_refnode(builder, fromdocname, todocname, targetid, contnode)

        if typ in ['lib', 'mod', 'class', 'var', 'const', 'func', 'gf', 'meth', 'macro', 'type']:
            # Target will have been transformed to the standard ID format:
            # no spaces and <> changed to []. Additionally, the node will have
            # dylan_curlibrary and dylan_curmodule set if possible. This is all
            # done by the role processing function and the DylanXRefRole class.
            colons = target.count(':')
            fulltarget = None

            if hasattr(node, "dylan_curlibrary"):
                library = node.dylan_curlibrary
            else:
                library = None

            if hasattr(node, "dylan_curmodule"):
                module = node.dylan_curmodule
            else:
                module = None

            # Use current library and module
            if colons == 2:
                fulltarget = target
            elif library is not None:
                library_id = name_to_id(library)
                if colons == 1:
                    fulltarget = "{0}:{1}".format(library_id, target)
                elif module is not None:
                    module_id = name_to_id(module)
                    if colons == 0:
                        fulltarget = "{0}:{1}:{2}".format(library_id, module_id, target)

            # Fetch link info based on current library and module and passed target
            nodeargs = self.data['objects'].get(fulltarget, None)

            # Can't find it that way; check the unique shortname list
            if nodeargs is None and colons == 0:
                targlist = self.data['fullids'].get(target, [])
                if len(targlist) == 1:
                    fulltarget = targlist[0]
                    nodeargs = self.data['objects'].get(fulltarget, None)

            # Found it; make a link.
            if nodeargs is not None:
                todocname = nodeargs[0]
                return make_refnode(builder, fromdocname, todocname, fulltarget, contnode)

        return None
开发者ID:iglennrogers,项目名称:sphinx-extensions,代码行数:54,代码来源:dylandomain.py


示例12: resolve_xref

 def resolve_xref(self, env, fromdocname, builder, role, targetname, node, contnode):
     # ‘target’ is the name that was written in the document
     # ‘role’ is where this xref comes from; it's exactly one of our subdomains
     if role == 'index':
         index = CoqDomain.find_index_by_name(targetname)
         if index:
             return make_refnode(builder, fromdocname, "coq-" + index.name, '', contnode, index.localname)
     else:
         resolved = self.data['objects'][role].get(targetname)
         if resolved:
             (todocname, _, targetid) = resolved
             return make_refnode(builder, fromdocname, todocname, targetid, contnode, targetname)
开发者ID:cpitclaudel,项目名称:coq-rst,代码行数:12,代码来源:coqdomain.py


示例13: resolve_xref

 def resolve_xref(self, env, fromdocname, builder,
                  typ, target, node, contnode):
     
     parent = node.get('idl:parent')
     if parent:
         ptarget = parent + '.' + target
     if parent and (ptarget in self.data['objects']):
         obj = self.data['objects'][ptarget]
         return make_refnode(builder, fromdocname, obj[0], ptarget,
                             contnode, ptarget)
     elif target in self.data['objects']:
         obj = self.data['objects'][target]
         return make_refnode(builder, fromdocname, obj[0], target,
                             contnode, target)
     return None
开发者ID:alexrudy,项目名称:sphinx-idl,代码行数:15,代码来源:domain.py


示例14: resolve_xref

 def resolve_xref(self, env, fromdocname, builder, type, target, node, contnode):
     if target[0] == '~':
         target = target[1:]
     doc, _ = self.data['objects'].get(target, (None, None))
     if doc:
         return make_refnode(builder, fromdocname, doc, target, contnode,
                             target)
开发者ID:AusIV,项目名称:coffee-sphinx,代码行数:7,代码来源:domain.py


示例15: resolve_xref

 def resolve_xref(self, env, fromdoc, builder, objtype, target, node,
                  content):
     if target not in self.data['objects']:
         return None
     docname, _ = self.data['objects'][target]
     return make_refnode(builder, fromdoc, docname,
                         'flyc:'+target, content, target)
开发者ID:huonw,项目名称:flycheck,代码行数:7,代码来源:flycheck.py


示例16: resolve_xref

    def resolve_xref(self, env, fromdocname, builder, typ, target, node,
                     contnode):
        objectname = node.get('mongodb:object')
        searchorder = node.hasattr('refspecific') and 1 or 0
        name, obj = self.find_obj(env, objectname, target, typ, searchorder)

        if obj is None:
            name, obj = self.find_obj(env, 'iddup.' + name, target, typ, searchorder)
            if obj is None:
                # print names and info from the node object at this
                # point to report on links that fail to resolve
                return None

        if name.startswith('bin.'):
            name = name.split('.', 1)[1]
        elif name.startswith('dbcmd.'):
            name = name.split('.', 1)[1]
        elif name.startswith('iddup.'):
            name = name.split('.', 1)[1]
        elif name.startswith('op.'):
            name = name.split('.', 1)[1]
        elif name.startswith('prj.'):
            name = name.split('.', 1)[1]
        

        return make_refnode(builder, fromdocname, obj[0],
                            name.replace('$', '_S_'), contnode, name)
开发者ID:procter-hoc,项目名称:docs,代码行数:27,代码来源:mongodb_domain.py


示例17: resolve_xref

    def resolve_xref(self, env, fromdocname, builder, type, target, node, contnode):
        sdkname = node.get('qbs:sdk')
        pkgname = node.get('qbs:package')
        modname = node.get('qbs:module')
        itemname = node.get('qbs:item')
        searchmode = node.hasattr('refspecific')

        matches = self.find_objects(env, sdkname, modname, pkgname, itemname, target, type,
                                    searchmode)

        if not matches:
            return None
        elif len(matches) > 1:
            env.warn_node('more than one target found for cross-reference %r: %s' %
                          (target, ', '.join(match[0] for match in matches)), node)

        name, obj = matches[0]

        if obj[1] == 'sdk':
            return self._make_sdk_refnode(builder, fromdocname, name, contnode)
        elif obj[1] == 'package':
            return self._make_package_refnode(builder, fromdocname, name, contnode)
        elif obj[1] == 'module':
            return self._make_module_refnode(builder, fromdocname, name, contnode)
        elif obj[1] == 'item':
            return self._make_item_refnode(builder, fromdocname, name, contnode)
        else:
            return make_refnode(builder, fromdocname, obj[0], name, contnode, name)
开发者ID:StoiridhProject,项目名称:StoiridhTools,代码行数:28,代码来源:qbs.py


示例18: resolve_required_by_xrefs

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,代码行数:25,代码来源:sphinxext.py


示例19: _make_sdk_refnode

 def _make_sdk_refnode(self, builder, fromdocname, name, contnode):
     """Make a reference node for a Qbs SDK."""
     docname, synopsis = self.data['sdks'][name]
     title = name
     if synopsis:
         title += ': ' + synopsis
     return make_refnode(builder, fromdocname, docname, 'sdk-' + name, contnode, title)
开发者ID:StoiridhProject,项目名称:StoiridhTools,代码行数:7,代码来源:qbs.py


示例20: resolve_xref

    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 None

            if fromdocname not in _doctree_cache:
                _doctree_cache[fromdocname] = env.get_doctree(fromdocname)
            doctree = _doctree_cache[fromdocname]

            resnode = role.result_nodes(doctree, env, node, None)[0][0]
            if isinstance(resnode, addnodes.pending_xref):
                text = node[0][0]
                reporter = doctree.reporter
                reporter.warning('Cannot resolve reference to %r' % text,
                                 line=node.line)
                return None
            return resnode
        else:
            anchor = http_resource_anchor(typ, target)
            title = typ.upper() + ' ' + target
            return make_refnode(builder, fromdocname, info[0], anchor,
                                contnode, title)
开发者ID:Lemma1,项目名称:MINAMI,代码行数:27,代码来源:httpdomain.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python nodes.nested_parse_with_titles函数代码示例发布时间:2022-05-27
下一篇:
Python nodes.inline_all_toctrees函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap