开发者

How to search for methods in Scaladoc, globally?

开发者 https://www.devze.com 2023-03-20 16:01 出处:网络
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

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, bu开发者_如何学Pythont apparently I'm unworthy...)


I don't think there is a general, built-in method. So if the scaladoc is online I use my friend Google. For instance to search for a method called left in the scala API, I use the query:

"def left" site:http://www.scala-lang.org/api/current/

If it's on my hard disk I use grep.


colladoc

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

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 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.

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 Alphabetical Index

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.


I use the alphabetic index in the top left under the search box. Would be nice if there were proper seach functionality though.

Would also be nice if the docs were available in Windows help format as they are for Java, which is much more convenient than the html javadoc, and lets you search on methods with almost zero latency.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号