Suggestions for ocaml documentation

I have just processed the “Compiler API”:
https://sanette.github.io/ocaml-api/compilerlibref/

So, I think that now the complete manual has been processed!
I will now work to integrate everything in the ocaml.org site.

3 Likes

Batteries would very welcome such a searchable OCaml documentation.
Our ocamldoc is here currently:
https://ocaml-batteries-team.github.io/batteries-included/hdoc2/

This is much better.
Thanks a lot, type searches are so useful!!!

it is certainly possible to adapt what I’m doing for the OCaml Manual/API as an ocamldoc plugin or postprocessor for any library.

done ! (well, only a PR :wink: )

8 Likes

Can we have the same thing for batteries?
I am a very big fan of the search by type signature thing.
Maybe the Jane Street people will be interested too, they have quite a lot
of open source libraries which are not easy to search into!

@UnixJunkie, of course, it is possible to transpose this to any library. It should not be very difficult. But it takes time… I’ll let you know if I can work into this.

This is very cool! It’s already been helpful for me.

A couple of things I noticed:

  • When I search int -> string, I get results like Unix.getservbyport : int -> string -> service_entry and Format.pp_print_as : formatter -> int -> string -> unit listed above some functions that return strings. Especially for immutable types, I’d care quite a lot about the return type more than the string match distance alone.

  • M.t types seem to be listed as t -> *, thus preventing searches such as Bytes.t -> string

good idea, I’ll try to implement this.

Mmm, this looks more complicated — at first sight, at least. I would like to keep a good tradeoff between features and simplicity of the code (the latter mainly for ensuring it’s fast enough on all computers)

1 Like

I’ve changed the ranking following this idea. Can you give it a try? (you might need to force reloading the page)

This is great, thanks!

maybe some special characters, like ^ and $, could be supported.
For example:
^int -> int: will match only type signatures which start like this
-> int$: would match only signatures which end like that.

this is now implemented, you may try it.

4 Likes

It just works ™. Fantastic!
https://sanette.github.io/ocaml-api/4.08/index.html

2 Likes

What I can do is replace all anonymous “t”'s by the fully qualified “Module.t” in the search index. This means that searching for “int ->t” would now produce no result. Would this be a good solution?

I think that would work. These t types are very common, and you’d always qualify them when searching anyways.

1 Like

The speed of the search is amazing! Especially compared with the modern websites.

2 Likes

OK this is now implemented. Can you try?

3 Likes

Works great and covers all my daily needs, thank you!

Anything else I could think of are probably trickier, like type variables and type equalities.

Type equalities like 'a 'b Result.t = 'a 'b result would be nice to cover but at least with Stdlib it seems easy to find what you are looking for without such logic.

Type variables might work with simply ignoring the variable altogether for search purposes, i.e. Bytes.t -> Seq.t gets you Bytes.to_seq : t -> char Seq.t and Bytes.to_seqi : t -> (int * char) Seq.t.

1 Like

This a bomb :boom:. Very nice. Thanks for this. :+1:

1 Like