如何在 Scaladoc 中全局搜索方法? [英] How to search for methods in Scaladoc, globally?

查看:38
本文介绍了如何在 Scaladoc 中全局搜索方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是否有可能通过 Scala 文档在全局范围内搜索类、特征或对象中的方法?示例:我有一个方法名称,但我不知道它属于哪个类,因此我可以在一些 scaladoc 搜索中键入它,它会向我显示包含具有给定名称的方法的类.(PS:我会添加标签scaladoc,但显然我不配......)

Is there any possibility that i can search for a method in a class, trait or object via scala doc, globally? Example: I have a method name and I don't know which class it belongs to so i can type it in some scaladoc search and it will show me classes containing a method with the given name. (PS: i would have added the tag scaladoc, but apparently I'm unworthy...)

推荐答案

colladoc

colladoc 工具比标准的 scaladoc 工具具有更有用的 scaladoc 搜索界面.

The colladoc tool has a more useful search interface to the scaladocs than the standard scaladoc tool.

您可以通过在搜索字符串前加上def"前缀来将搜索限制为方法名称,如def hiddenly".如果您点击搜索框旁边的放大镜,搜索字符串为空,您将获得以下方便的示例查询列表:

You can restrict the search to method names by prefixing the search string with "def", as in "def implicitly". If you click on the magnifying glass next to the search box, with an empty search string, you'll get the following handy list of sample queries:

  • any 搜索名称、定义或注释中包含 any 一词的所有内容
  • any_ 搜索以 any
  • 开头的所有内容
  • //_any 搜索包含以 any
  • 结尾的单词的所有评论
  • class AnyRef 搜索名称为 AnyRef 的所有类
  • trait _ 搜索所有特征
  • object _ 搜索所有对象
  • class A_ ||class B_ 搜索所有以 A 或 B 开头的类
  • class _ extends _ with _ 搜索所有扩展类并实现特征的类
  • var _: Int 搜索所有 Int 类型的值或变量,vars 显示在 vals 之前
  • def toString 搜索名称为 toString 的所有方法
  • def toString : String 搜索名称为 toString 且返回类型为 String 的所有方法
  • def _(_) : Boolean 使用一个参数和 returnType Boolean 搜索所有方法
  • def _(Int, _) 搜索所有带参数的方法,第一个是 Int 类型
  • def _(_, *) 搜索带有一个或多个参数的所有方法
  • def _(Iterable[_]):Int 搜索所有采用 Iterable 并返回 Int 的方法
  • (Iterable[_]) =>Int 等价于上述,lambda 语法也可用于搜索方法.
  • <代码>=>(_, _) 搜索所有返回包含两个元素的元组的方法.
  • def _((_) => _) 搜索所有将一个方法作为第一个参数的方法,该方法接受并返回任何值.
  • any searches for everything that has the word any in its name, definition or comment
  • any_ searches for everything that starts with any
  • //_any searches for all comments that contain a word that ends with any
  • class AnyRef searches for all classes with name AnyRef
  • trait _ searches for all traits
  • object _ searches for all objects
  • class A_ || class B_ searches for all classes that starts with A or B
  • class _ extends _ with _ searches for all classes that extend a class and implement a trait
  • var _: Int searches for all values or variables of type Int, vars are displayed before the vals
  • def toString searches for all methods with name toString
  • def toString : String searches for all methods with name toString and return type String
  • def _(_) : Boolean searches for all methods with one argument and returnType Boolean
  • def _(Int, _) searches for all methods with arguments and the first is of type Int
  • def _(_, *) searches for all methods with one or more arguments
  • def _(Iterable[_]):Int searches for all methods that take an Iterable and return Int
  • (Iterable[_]) => Int equvalent to the above, lambda syntax can also be used for searching for methods.
  • => (_, _) searches for all methods that return a tuple with two elements.
  • def _((_) => _) searches for all methods that have one as first parameter a method that takes and returns any value.

不幸的是,colladoc 的搜索结果可能令人生畏.如果一个成员由于继承而存在于许多特征/类中(例如集合 API 中的 sum 方法),则所有类都会列在结果中.

Unfortunately, colladoc's search results can be daunting. If a member exists in many traits/classes due to inheritance (e.g. the sum method in the collections API), all of the classes are listed in the results.

scaladoc 字母索引

scaladoc 本身没有这样的搜索,但是有一个包含类/对象/特征成员的字母索引.只需单击左上角搜索栏下方的字母之一,您就会看到一个列表,其中包含以该字母开头的类、对象、特征和成员(或符号,如果您点击链接).然后您可以使用浏览器的查找功能来查找您感兴趣的成员.

There's no such search in scaladoc itself, but there is an alphabetic index that contains class/object/trait members. Just click on one of the letters below the search bar in the top left corner, and you'll see a list containing classes, objects, traits, and members starting with that letter (or symbols, if you click on the "#" link). Then you can use your browser's find function to look for the member you're interested in.

这篇关于如何在 Scaladoc 中全局搜索方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆