Igor Chubin
Igor Chubin

Reputation: 64563

Is there a way to get a "docstring" of a function?

To get a footprint of a function/module, I can do:

module type S = module type of Stack;;

What should I do to get a description/docstring of some function?

Upvotes: 1

Views: 674

Answers (2)

Richard-Degenne
Richard-Degenne

Reputation: 2949

You can use ocp-browser, which provides a command-line interface to browse all packages you have installed.

It has a search feature, and by pressing the space bar, you can see the documentation associated to a function.

Here's a example with the Stack module.

ocp-browser

Update: June 22, 2017

A few days ago, a package named ocp-index-top was published on OPAM, allowing you to see the documentation inside of an OCaml toplevel.

enter image description here

Upvotes: 4

Lhooq
Lhooq

Reputation: 4441

I don't think it's possible to do so. Actually, the signature should give you a good insight of what the function is supposed to do and if you're not sure you'll have to read the description in the manual.

As a side note, there's an easier way to look at the signature of anything (function, module, exception ...) which is

# #show ident;;

As written here,

At start-up, the toplevel system contains implementations for all the modules in the the standard library.

I understand it as only the .cm* files are loaded and in these files you won't find the comments that document the functions. I'm, then, almost sure that you can't read the documentation of a function from the toplevel.

But, really, I think you get used to understanding the purpose of a function from its name and signature

Upvotes: 2

Related Questions