scaladoc/resources/dotty_res/scripts/inkuire.md
Inkuire is a Hoogle-like search engine for Scala 3 (and Kotlin).
To include Inkuire in scaladoc one should add -Ygenerate-inkuire flag. This will allow the usage of Inkuire for generated Scaladoc with project sources and available sources from external-mappings.
The Inkuire worker works in Scaladoc searchbar. It is triggered once an input containing => is detected in searchbar. There is 1s debounce on searches with Inkuire.
When including -Ygenerate-inkuire flag database for project sources and a config should be generated. Which are namely files: inkuire-db.json and scripts/inkuire-config.json. Config file includes addresses of possible inkuire-db files. There always is at least one - generated one. But also links for external mappings are addes on relative path ../inkuire-db.json.
inkuire-db.json contains a json with Inkuire engine's representation of:
The source code is available here.
Important parts are:
Since Inkuire has quite a lot of dependencies it's sources cannot be easily integrated into Scaladoc.
That is why Inkuire is included as a resource, namely inkuire.js file and loaded as Web Worker.
Web worker accepts String messages. Each message should be a requested signature. Web worker can send different messages:
msg) - After processing a single signature has finished. msg is optional and contains an error to be displayed.ResultFormat - resulting function found with some additional information, like package location and documentation link.Signature format accepted by Inkuire is pretty much a Scala curried function. With some minor changes:
_ is treated as sort of wildcard, so matches to any type on any position. So searching for any one-argument function from Int can be done like this: Int => _.Some example signatures with expected (not exclusive)results:
Seq[Int] => (Int => Long) => Seq[Long] -> IterableOps.map(A, B) => A -> Product2._1Set[Long] => Long => Boolean -> SetOps.containsBigDecimal => Byte -> ScalaNumericAnyConversions.toByteInt => Long => Int -> Function.constString => Int => Char -> StringOps.applySome improvements done on engine side:
A and a function with the first parameter as A (provided other parameters and return type are the same).Int => String => String matches Function.const, even though the arguments are switched.