def type_menu(tree, type): """Return menu for type reference.""" qualname, kind = type['qualname'], type.get('kind') menu = [{'html': "Find declarations", 'title': "Find declarations of this class", 'href': search_url(tree, "+type-decl:%s" % quote(qualname)), 'icon': 'reference'}] if kind == 'class' or kind == 'struct': menu.append({'html': "Find subclasses", 'title': "Find subclasses of this class", 'href': search_url(tree, "+derived:%s" % quote(qualname)), 'icon': 'type'}) menu.append({'html': "Find base classes", 'title': "Find base classes of this class", 'href': search_url(tree, "+bases:%s" % quote(qualname)), 'icon': 'type'}) menu.append({'html': "Find members", 'title': "Find members of this class", 'href': search_url(tree, "+member:%s" % quote(qualname)), 'icon': 'members'}) menu.append({'html': "Find references", 'title': "Find references to this class", 'href': search_url(tree, "+type-ref:%s" % quote(qualname)), 'icon': 'reference'}) return menu
def function_menu(tree, func): """Build menu for a function.""" qualname = func['qualname'] isvirtual = 'override' in func # Things we can do with qualified name menu = [{'html': "Find declarations", 'title': "Find declarations of this function", 'href': search_url(tree, "+function-decl:%s" % quote(qualname)), 'icon': 'reference'}, {'html': "Find callers", 'title': "Find functions that call this function", 'href': search_url(tree, "+callers:%s" % quote(qualname)), 'icon': 'method'}, {'html': "Find references", 'title': "Find references to this function", 'href': search_url(tree, "+function-ref:%s" % quote(qualname)), 'icon': 'reference'}] if isvirtual: menu.append({'html': "Find overridden", 'title': "Find functions that this function overrides", 'href': search_url(tree, "+overridden:%s" % quote(qualname)), 'icon': 'method'}) menu.append({'html': "Find overrides", 'title': "Find overrides of this function", 'href': search_url(tree, "+overrides:%s" % quote(qualname)), 'icon': 'method'}) return menu
def function_menu_generic(tree, datum, tree_config): menu = [] menu.append({ 'html': "Find callers", 'title': "Find functions that call this function", 'href': search_url(tree_config, "+callers:%s" % quote(datum['qualname'])), 'icon': 'method' }) menu.append({ 'html': "Find callees", 'title': "Find functions that are called by this function", 'href': search_url(tree_config, "+called-by:%s" % quote(datum['qualname'])), 'icon': 'method' }) add_find_references(tree_config, menu, datum['qualname'], "function-ref", "function") return menu
def type_menu(tree, type): """Return menu for type reference.""" qualname, kind = type['qualname'], type.get('kind') menu = [{ 'html': "Find declarations", 'title': "Find declarations of this class", 'href': search_url(tree, "+type-decl:%s" % quote(qualname)), 'icon': 'reference' }] if kind == 'class' or kind == 'struct': menu.append({ 'html': "Find subclasses", 'title': "Find subclasses of this class", 'href': search_url(tree, "+derived:%s" % quote(qualname)), 'icon': 'type' }) menu.append({ 'html': "Find base classes", 'title': "Find base classes of this class", 'href': search_url(tree, "+bases:%s" % quote(qualname)), 'icon': 'type' }) menu.append({ 'html': "Find members", 'title': "Find members of this class", 'href': search_url(tree, "+member:%s" % quote(qualname)), 'icon': 'members' }) menu.append({ 'html': "Find references", 'title': "Find references to this class", 'href': search_url(tree, "+type-ref:%s" % quote(qualname)), 'icon': 'reference' }) return menu
def _more_menu_items(self): qualname, has_overriddens, has_overrides = self.menu_data[1:] qualname = quote(qualname) tree = self.tree.name yield {'html': "Find declarations", 'title': "Find declarations of this function", 'href': search_url(tree, "+function-decl:%s" % qualname), 'icon': 'reference'} yield {'html': "Find callers", 'title': "Find functions that call this function", 'href': search_url(tree, "+callers:%s" % qualname), 'icon': 'method'} yield {'html': "Find references", 'title': "Find references to this function", 'href': search_url(tree, "+function-ref:%s" % qualname), 'icon': 'reference'} if has_overriddens: yield {'html': "Find overridden", 'title': "Find functions that this function overrides", 'href': search_url(tree, "+overridden:%s" % qualname), 'icon': 'method'} if has_overrides: yield {'html': "Find overrides", 'title': "Find overrides of this function", 'href': search_url(tree, "+overrides:%s" % qualname), 'icon': 'method'}
def type_menu_generic(tree, datum, tree_config): menu = [] kind = datum['kind'] if kind == 'trait': menu.append({ 'html': "Find sub-traits", 'title': "Find sub-traits of this trait", 'href': search_url(tree_config, "+derived:%s" % quote(datum['qualname'])), 'icon': 'type' }) menu.append({ 'html': "Find super-traits", 'title': "Find super-traits of this trait", 'href': search_url(tree_config, "+bases:%s" % quote(datum['qualname'])), 'icon': 'type' }) if kind == 'struct' or kind == 'enum' or kind == 'trait': menu.append({ 'html': "Find impls", 'title': "Find impls which involve this " + kind, 'href': search_url(tree_config, "+impl:%s" % quote(datum['qualname'])), 'icon': 'reference' }) add_find_references(tree_config, menu, datum['qualname'], "type-ref", kind) return menu
class FunctionRef(_RefWithDefinition): """Ref for function definitions or references""" @classmethod def _condensed_menu_data(cls, tree, prop): return prop[ 'qualname'], 'has_overriddens' in prop, 'has_overrides' in prop def _more_menu_items(self, (qualname, has_overriddens, has_overrides)): yield { 'html': "Find declarations", 'title': "Find declarations of this function", 'href': search_url(self.tree.name, "+function-decl:%s" % quote(qualname)), 'icon': 'reference' } yield { 'html': "Find callers", 'title': "Find functions that call this function", 'href': search_url(self.tree.name, "+callers:%s" % quote(qualname)), 'icon': 'method' } yield { 'html': "Find references", 'title': "Find references to this function", 'href': search_url(self.tree.name, "+function-ref:%s" % quote(qualname)), 'icon': 'reference' } if has_overriddens: yield { 'html': "Find overridden", 'title': "Find functions that this function overrides", 'href': search_url(self.tree.name, "+overridden:%s" % quote(qualname)), 'icon': 'method' } if has_overrides: yield { 'html': "Find overrides", 'title': "Find overrides of this function", 'href': search_url(self.tree.name, "+overrides:%s" % quote(qualname)), 'icon': 'method' }
def call_menu(qualname, tree): return [{'html': "Find callers", 'title': "Find functions that call this function", 'href': search_url(tree, "+callers:%s" % quote(qualname)), 'icon': 'method'}, {'html': "Find callees", # TODO: Probably useless. Remove. 'title': "Find functions that are called by this function", 'href': search_url(tree, "+called-by:%s" % quote(qualname)), 'icon': 'method'}]
def menu_items(self): qualname = self.menu_data yield {'html': 'Find subclasses', 'title': 'Find subclasses of this class', 'href': search_url(self.tree, '+derived:' + qualname), 'icon': 'type'} yield {'html': 'Find base classes', 'title': 'Find base classes of this class', 'href': search_url(self.tree, '+bases:' + qualname), 'icon': 'type'}
class TypeRef(_QualnameRef): @classmethod def _condensed_menu_data(cls, tree, prop): return (super(TypeRef, cls)._condensed_menu_data(tree, prop) + (prop.get('kind', 'type'), 'has_subclass' in prop, 'has_base_class' in prop)) def _more_menu_items(self, (qualname, kind, has_subclass, has_base_class)): """Return menu for type reference.""" def kind_plural(): if kind == 'class': return 'classes' elif kind == 'struct': return 'structs' else: return 'types' yield { 'html': "Find declarations", 'title': "Find declarations of this %s" % kind, 'href': search_url(self.tree.name, "+type-decl:%s" % quote(qualname)), 'icon': 'reference' } if has_subclass: kinds = kind_plural() yield { 'html': "Find sub%s" % kinds, 'title': "Find sub%s of this %s" % (kinds, kind), 'href': search_url(self.tree.name, "+derived:%s" % quote(qualname)), 'icon': 'type' } if has_base_class: kinds = kind_plural() yield { 'html': "Find base %s" % kinds, 'title': "Find base %s of this %s" % (kinds, kind), 'href': search_url(self.tree.name, "+bases:%s" % quote(qualname)), 'icon': 'type' } yield { 'html': "Find members", 'title': "Find members of this %s" % kind, 'href': search_url(self.tree.name, "+member:%s" % quote(qualname)), 'icon': 'members' } yield { 'html': "Find references", 'title': "Find references to this %s" % kind, 'href': search_url(self.tree.name, "+type-ref:%s" % quote(qualname)), 'icon': 'reference' }
def variable_menu(tree, variable): """Build menu for a variable.""" qualname = variable['qualname'] return [{'html': "Find declarations", 'title': "Find declarations of this variable", 'href': search_url(tree, "+var-decl:%s" % quote(qualname)), 'icon': 'reference'}, {'html': "Find references", 'title': "Find reference to this variable", 'href': search_url(tree, "+var-ref:%s" % quote(qualname)), 'icon': 'field'}]
def namespace_menu(tree, namespace): """Build menu for a namespace.""" qualname = namespace['qualname'] return [{'html': "Find definitions", 'title': "Find definitions of this namespace", 'href': search_url(tree, "+namespace:%s" % quote(qualname)), 'icon': 'jump'}, {'html': "Find references", 'title': "Find references to this namespace", 'href': search_url(tree, "+namespace-ref:%s" % quote(qualname)), 'icon': 'reference'}]
def class_menu(tree, qualname): """Generate menu for a class definition.""" return [ {'html': 'Find subclasses', 'title': 'Find subclasses of this class', 'href': search_url(tree, '+derived:' + qualname), 'icon': 'type'}, {'html': 'Find base classes', 'title': 'Find base classes of this class', 'href': search_url(tree, '+bases:' + qualname), 'icon': 'type'}, ]
def menu_items(self): qualname = self.menu_data yield { "html": "Find subclasses", "title": "Find subclasses of this class", "href": search_url(self.tree.name, "+derived:" + qualname), "icon": "type", } yield { "html": "Find base classes", "title": "Find base classes of this class", "href": search_url(self.tree.name, "+bases:" + qualname), "icon": "type", }
def variable_menu(tree, variable): """Build menu for a variable.""" qualname = variable['qualname'] return [{ 'html': "Find declarations", 'title': "Find declarations of this variable", 'href': search_url(tree, "+var-decl:%s" % quote(qualname)), 'icon': 'reference' }, { 'html': "Find references", 'title': "Find reference to this variable", 'href': search_url(tree, "+var-ref:%s" % quote(qualname)), 'icon': 'field' }]
def menu_items(self): qualname = self.menu_data yield { 'html': 'Find subclasses', 'title': 'Find subclasses of this class', 'href': search_url(self.tree.name, '+derived:' + qualname), 'icon': 'type' } yield { 'html': 'Find base classes', 'title': 'Find base classes of this class', 'href': search_url(self.tree.name, '+bases:' + qualname), 'icon': 'type' }
def namespace_menu(tree, namespace): """Build menu for a namespace.""" qualname = namespace['qualname'] return [{ 'html': "Find definitions", 'title': "Find definitions of this namespace", 'href': search_url(tree, "+namespace:%s" % quote(qualname)), 'icon': 'jump' }, { 'html': "Find references", 'title': "Find references to this namespace", 'href': search_url(tree, "+namespace-ref:%s" % quote(qualname)), 'icon': 'reference' }]
def type_menu(tree_config, kind, qualname): if kind == 'trait': yield {'html': "Find sub-traits", 'title': "Find sub-traits of this trait", 'href': search_url(tree_config, "+derived:%s" % quote(qualname)), 'icon': 'type'} yield {'html': "Find super-traits", 'title': "Find super-traits of this trait", 'href': search_url(tree_config, "+bases:%s" % quote(qualname)), 'icon': 'type'} if kind == 'struct' or kind == 'enum' or kind == 'trait': yield {'html': "Find impls", 'title': "Find impls which involve this " + kind, 'href': search_url(tree_config, "+impl:%s" % quote(qualname)), 'icon': 'reference'}
def function_menu(tree, datum, tree_config): menu = function_menu_generic(tree, datum, tree_config) if 'declid' in datum and datum['declid'] in tree.data.functions: # it's an implementation, find the decl decl = tree.data.functions[datum['declid']] add_jump_definition(tree, tree_config, menu, decl, "Jump to trait method") else: # it's a decl, find implementations impls = tree.data.index('functions', 'declid') count = len(impls[datum['id']]) if datum['id'] in impls else 0 if count > 0: menu.append({ 'html': "Find implementations (%d)" % count, 'title': "Find implementations of this trait method", 'href': search_url(tree_config, "+fn-impls:%s" % quote(datum['qualname'])), 'icon': 'method' }) return Ref(menu)
def class_menu(tree, qualname): """Generate menu for a class definition.""" return [ { 'html': 'Find subclasses', 'title': 'Find subclasses of this class', 'href': search_url(tree, '+derived:' + qualname), 'icon': 'type' }, { 'html': 'Find base classes', 'title': 'Find base classes of this class', 'href': search_url(tree, '+bases:' + qualname), 'icon': 'type' }, ]
def typedef_menu(tree, typedef): """Build menu for typedef.""" qualname = typedef['qualname'] return [{'html': "Find references", 'title': "Find references to this typedef", 'href': search_url(tree, "+type-ref:%s" % quote(qualname)), 'icon': 'reference'}]
def test_search_url(self): """Test unicode of various widths, slashes, and spaces.""" with self.app().test_request_context(): eq_( search_url(u'tr éé', u'ev il:searcheß/ªre/bes†'), '/tr%20%C3%A9%C3%A9/search?q=ev+il%3Asearche%C3%9F%2F%C2%AAre%2Fbes%E2%80%A0' )
def macro_menu(tree, macro): """Return menu for macro reference.""" name = macro['name'] return [{'html': "Find references", 'title': "Find references to macros with this name", 'href': search_url(tree, "+macro-ref:%s" % name), 'icon': 'reference'}]
def namespace_alias_menu(tree, namespace_alias): """Build menu for a namespace.""" qualname = namespace_alias['qualname'] return [{'html': "Find references", 'title': "Find references to this namespace alias", 'href': search_url(tree, "+namespace-alias-ref:%s" % quote(qualname)), 'icon': 'reference'}]
class VariableRef(_QualnameRef): def _more_menu_items(self, (qualname, )): yield { 'html': "Find declarations", 'title': "Find declarations of this variable", 'href': search_url(self.tree.name, "+var-decl:%s" % quote(qualname)), 'icon': 'reference' } yield { 'html': "Find references", 'title': "Find reference to this variable", 'href': search_url(self.tree.name, "+var-ref:%s" % quote(qualname)), 'icon': 'field' }
def trait_impl_menu_item(tree_config, qualname, count): return { 'html': "Find implementations (%d)" % count, 'title': "Find implementations of this trait method", 'href': search_url(tree_config.name, "+fn-impls:%s" % quote(qualname)), 'icon': 'method' }
def trait_impl_menu_item(tree_config, qualname, count): return { "html": "Find implementations (%d)" % count, "title": "Find implementations of this trait method", "href": search_url(tree_config, "+fn-impls:%s" % quote(qualname)), "icon": "method", }
def call_menu(qualname, tree): return [{ 'html': "Find callers", 'title': "Find calls of this function", 'href': search_url(tree.name, "+callers:%s" % quote(qualname)), 'icon': 'method' }]
def use_items_menu_item(tree_config, qualname): return { "html": "Find use items", "title": "Find instances of this module in 'use' items", "href": search_url(tree_config, "+module-use:%s" % quote(qualname)), "icon": "reference", }
def add_find_references(tree_config, menu, qualname, search_term, kind): menu.append({ 'html': "Find references", 'title': "Find references to this " + kind, 'href': search_url(tree_config, "+" + search_term + ":%s" % quote(qualname)), 'icon': 'reference' })
def filtered_search_menu(self, filter_name, name, html='Find declaration', title='Search for declarations.', icon='class'): return { 'html': html, 'title': title, 'href': search_url(self.tree, '%s:%s' % (filter_name, name)), 'icon': icon }
def use_items_menu_item(tree_config, qualname): return { 'html': "Find use items", 'title': "Find instances of this module in 'use' items", 'href': search_url(tree_config.name, "+module-use:%s" % quote(qualname)), 'icon': 'reference' }
def filtered_search_menu(tree, term, html, title, filter_name, icon): """Return a menu for searching in given tree for a specific term using a filter.""" return { 'html': html, 'title': title, 'href': search_url(tree.name, '%s:%s' % (filter_name, term)), 'icon': icon }
def macro_menu(tree, macro): """Return menu for macro reference.""" name = macro['name'] return [{ 'html': "Find references", 'title': "Find references to macros with this name", 'href': search_url(tree, "+macro-ref:%s" % name), 'icon': 'reference' }]
def call_menu(qualname, tree): return [ { "html": "Find callers", "title": "Find calls of this function", "href": search_url(tree, "+callers:%s" % quote(qualname)), "icon": "method", } ]
class TypedefRef(_QualnameRef): def _more_menu_items(self, (qualname, )): yield { 'html': "Find references", 'title': "Find references to this typedef", 'href': search_url(self.tree.name, "+type-ref:%s" % quote(qualname)), 'icon': 'reference' }
def typedef_menu(tree, typedef): """Build menu for typedef.""" qualname = typedef['qualname'] return [{ 'html': "Find references", 'title': "Find references to this typedef", 'href': search_url(tree, "+type-ref:%s" % quote(qualname)), 'icon': 'reference' }]
class TypeRef(_QualnameRef): @classmethod def _condensed_menu_data(cls, tree, prop): """Hang onto qualname *and* kind.""" return (super(TypeRef, cls)._condensed_menu_data(tree, prop) + (prop.get('kind', ''), )) def _more_menu_items(self, (qualname, kind)): """Return menu for type reference.""" yield { 'html': "Find declarations", 'title': "Find declarations of this class", 'href': search_url(self.tree.name, "+type-decl:%s" % quote(qualname)), 'icon': 'reference' } if kind == 'class' or kind == 'struct': yield { 'html': "Find subclasses", 'title': "Find subclasses of this class", 'href': search_url(self.tree.name, "+derived:%s" % quote(qualname)), 'icon': 'type' } yield { 'html': "Find base classes", 'title': "Find base classes of this class", 'href': search_url(self.tree.name, "+bases:%s" % quote(qualname)), 'icon': 'type' } yield { 'html': "Find members", 'title': "Find members of this class", 'href': search_url(self.tree.name, "+member:%s" % quote(qualname)), 'icon': 'members' } yield { 'html': "Find references", 'title': "Find references to this class", 'href': search_url(self.tree.name, "+type-ref:%s" % quote(qualname)), 'icon': 'reference' }
def module_menu_generic(tree, datum, tree_config): menu = [] menu.append({ 'html': "Find use items", 'title': "Find instances of this module in 'use' items", 'href': search_url(tree_config, "+module-use:%s" % quote(datum['qualname'])), 'icon': 'reference' }) add_find_references(tree_config, menu, datum['qualname'], "module-ref", "module") return menu
class NamespaceRef(_QualnameRef): def _more_menu_items(self, (qualname, )): yield { 'html': "Find definitions", 'title': "Find definitions of this namespace", 'href': search_url(self.tree.name, "+namespace:%s" % quote(qualname)), 'icon': 'jump' } yield { 'html': "Find references", 'title': "Find references to this namespace", 'href': search_url(self.tree.name, "+namespace-ref:%s" % quote(qualname)), 'icon': 'reference' }
def find_references_menu_item(tree_config, qualname, filter_name, kind): """A sort of compound menu that handles finding various sorts of references Should be broken into several. """ return {'html': "Find references", 'title': "Find references to this " + kind, 'href': search_url(tree_config, "+" + filter_name + ":%s" % quote(qualname)), 'icon': 'reference'}
def menu_items(self): qualname, name, typename = self.menu_data for text, filtername, title, icon in [ ("Find definition of %s %s" % (typename, name), "id", "Find definition", "class"), ("Find references to %s %s" % (typename, name), "ref", "Find references", "method"), ]: yield { "html": text, "title": title, "href": search_url(self.tree.name, '+%s:"%s"' % (filtername, qualname)), "icon": icon, }
def type_menu(tree_config, kind, qualname): if kind == "trait": yield { "html": "Find sub-traits", "title": "Find sub-traits of this trait", "href": search_url(tree_config, "+derived:%s" % quote(qualname)), "icon": "type", } yield { "html": "Find super-traits", "title": "Find super-traits of this trait", "href": search_url(tree_config, "+bases:%s" % quote(qualname)), "icon": "type", } if kind == "struct" or kind == "enum" or kind == "trait": yield { "html": "Find impls", "title": "Find impls which involve this " + kind, "href": search_url(tree_config, "+impl:%s" % quote(qualname)), "icon": "reference", }
def find_references_menu_item(tree_config, qualname, filter_name, kind): """A sort of compound menu that handles finding various sorts of references Should be broken into several. """ return { "html": "Find references", "title": "Find references to this " + kind, "href": search_url(tree_config, "+" + filter_name + ":%s" % quote(qualname)), "icon": "reference", }
def menu_items(self): search_for_def, qualname = self.menu_data[:2] if search_for_def: menu = [{'html': "Jump to definition", 'title': "Jump to definition", 'href': '%s&%s' % (search_url(self.tree.name, '+function:%s' % quote(qualname)), 'redirect=true'), 'icon': 'jump'}] else: menu = [] menu.extend(self._more_menu_items()) return menu
def function_menu(tree, func): """Build menu for a function.""" qualname = func['qualname'] isvirtual = 'override' in func # Things we can do with qualified name menu = [{ 'html': "Find declarations", 'title': "Find declarations of this function", 'href': search_url(tree, "+function-decl:%s" % quote(qualname)), 'icon': 'reference' }, { 'html': "Find callers", 'title': "Find functions that call this function", 'href': search_url(tree, "+callers:%s" % quote(qualname)), 'icon': 'method' }, { 'html': "Find references", 'title': "Find references to this function", 'href': search_url(tree, "+function-ref:%s" % quote(qualname)), 'icon': 'reference' }] if isvirtual: menu.append({ 'html': "Find overridden", 'title': "Find functions that this function overrides", 'href': search_url(tree, "+overridden:%s" % quote(qualname)), 'icon': 'method' }) menu.append({ 'html': "Find overrides", 'title': "Find overrides of this function", 'href': search_url(tree, "+overrides:%s" % quote(qualname)), 'icon': 'method' }) return menu
def namespace_alias_menu(tree, namespace_alias): """Build menu for a namespace.""" qualname = namespace_alias['qualname'] return [{ 'html': "Find references", 'title': "Find references to this namespace alias", 'href': search_url(tree, "+namespace-alias-ref:%s" % quote(qualname)), 'icon': 'reference' }]
def type_menu(tree_config, kind, qualname): if kind == 'trait': yield { 'html': "Find sub-traits", 'title': "Find sub-traits of this trait", 'href': search_url(tree_config.name, "+derived:%s" % quote(qualname)), 'icon': 'type' } yield { 'html': "Find super-traits", 'title': "Find super-traits of this trait", 'href': search_url(tree_config.name, "+bases:%s" % quote(qualname)), 'icon': 'type' } if kind == 'struct' or kind == 'enum' or kind == 'trait': yield { 'html': "Find impls", 'title': "Find impls which involve this " + kind, 'href': search_url(tree_config.name, "+impl:%s" % quote(qualname)), 'icon': 'reference' }
class NamespaceAliasRef(_QualnameRef): def _more_menu_items(self, (qualname, )): """Build menu for a namespace.""" yield { 'html': "Find references", 'title': "Find references to this namespace alias", 'href': search_url(self.tree.name, "+namespace-alias-ref:%s" % quote(qualname)), 'icon': 'reference' }
def _more_menu_items(self): qualname, has_overriddens, has_overrides = self.menu_data[1:] qualname = quote(qualname) tree = self.tree.name yield { 'html': "Find declarations", 'title': "Find declarations of this function", 'href': search_url(tree, "+function-decl:%s" % qualname), 'icon': 'reference' } yield { 'html': "Find callers", 'title': "Find functions that call this function", 'href': search_url(tree, "+callers:%s" % qualname), 'icon': 'method' } yield { 'html': "Find references", 'title': "Find references to this function", 'href': search_url(tree, "+function-ref:%s" % qualname), 'icon': 'reference' } if has_overriddens: yield { 'html': "Find overridden", 'title': "Find functions that this function overrides", 'href': search_url(tree, "+overridden:%s" % qualname), 'icon': 'method' } if has_overrides: yield { 'html': "Find overrides", 'title': "Find overrides of this function", 'href': search_url(tree, "+overrides:%s" % qualname), 'icon': 'method' }
def menu_items(self): search_for_def, qualname = self.menu_data[:2] if search_for_def: menu = [{ 'html': "Jump to definition", 'title': "Jump to definition", 'href': '%s&%s' % (search_url(self.tree.name, '+function:%s' % quote(qualname)), 'redirect=true'), 'icon': 'jump' }] else: menu = [] menu.extend(self._more_menu_items()) return menu
def function_menu(tree, datum, tree_config): menu = function_menu_generic(tree, datum, tree_config) if 'declid' in datum and datum['declid'] in tree.data.functions: # it's an implementation, find the decl decl = tree.data.functions[datum['declid']] add_jump_definition(tree, tree_config, menu, decl, "Jump to trait method") else: # it's a decl, find implementations impls = tree.data.index('functions', 'declid') count = len(impls[datum['id']]) if datum['id'] in impls else 0 if count > 0: menu.append({ 'html': "Find implementations (%d)"%count, 'title': "Find implementations of this trait method", 'href': search_url(tree_config, "+fn-impls:%s" % quote(datum['qualname'])), 'icon': 'method' }) return Ref(menu)
def search(self, query): """ Auxiliary function for getting the search url for query """ return search_url(self.tree.config.wwwroot, self.tree.name, query)
def use_items_menu_item(tree_config, qualname): return {'html': "Find use items", 'title': "Find instances of this module in 'use' items", 'href': search_url(tree_config, "+module-use:%s" % quote(qualname)), 'icon': 'reference'}
def trait_impl_menu_item(tree_config, qualname, count): return {'html': "Find implementations (%d)" % count, 'title': "Find implementations of this trait method", 'href': search_url(tree_config, "+fn-impls:%s" % quote(qualname)), 'icon': 'method'}