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


Python nodes.make_refnode函数代码示例

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


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


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