Previous: Refactoring, Up: Programming Aids

2.5 Documentation

Browsing of the OTP documentation is provided by an Erlang program called otp_doc. The OTP html docs are scanned on-the-fly, and for each M:F/A two pieces of data are extracted (and cached): the signature and the link.

The signature is a string describing the functions name, arguments and return value; lists:usort(List1) -> List2 Signature(s) are printed in the mini-buffer by the erl-find-sig functions. Note that there is implicit wildcarding; running erl-find-sig on "li:fl" will print this in the mini-buffer;

     lib:flush_receive() -> void()
     lists:flatlength(DeepList) -> int()
     lists:flatmap(Fun, List1) -> List2
     lists:flatten(DeepList, Tail) -> List
     lists:flatten(DeepList) -> List

The link is used by the erl-find-doc functions to display the full documentation in Emacs (requires the w3m package.) If there is more than one match (see above), a list of candidates will be written in the mini-buffer;

     candidates: lib:flush_receive/0, lists:flatlength/1, lists:flatmap/2,
     lists:flatten/2, lists:flatten/1

Simple online Erlang documentation is provided via an Erlang program called fdoc. The documentation is automatically scanned out of source files by building a searchable database of the comments appearing before each function. Naturally, the quality of documentation provided by this scheme will depend on the style in which the source files are commented.

C-c C-d d
Describe an Erlang module or function by name. (erl-fdoc-describe)
C-c C-d a
Show apropos information about Erlang functions, by regular expression. All functions whose names or comments match the regexp are displayed. (erl-fdoc-apropos)

With a prefix argument, these commands rebuild the fdoc database before searching. This is useful after (re)loading a lot of modules, since fdoc only scans the currently loaded modules for documentation when it builds the database.