art-w / sherlodoc

Fuzzy type search for OCaml documentation
MIT License
70 stars 6 forks source link

Filter results by kind #27

Open panglesd opened 7 months ago

panglesd commented 7 months ago

It would be nice to search for a specific kind (value, type, module, ...).

I take the opportunity of suggesting a syntax for this :)

val x : t (** word *)

Search a value with name containing x and type containing t and docstring containing work (the "docstring" search is not really part of the proposal for this particular issue, but I could not resist having a "complete" example!)

Some other examples with different kinds:

type name
module Module_name
module type Module_type_name
type t = Constructor_name : int -> t
type _ = Constructor_name
type _ = { field_name }
type _ = { field_name : int -> int }
exception Exception_name
exception Exception_name : string -> string
class class_name
class type class_type_name
method method_name : t

More complex but very satisfying syntax for me!

art-w commented 7 months ago

Ha yes that would be cool! Perhaps we could start with the prefix kind syntax? (the constructors / record fields will be harder to support, but are also less likely to be useful (?))

One thing to keep in mind is that some keywords might be useful search terms (for example print exception to find Printexc), what do you think of toggling this only when the keyword is at the very beginning of the query? (such that a savvy user can always prefix them with a space to recover a text query, e.g. type)