How to use edoc?

Generating Erlang documentation by edoc

For entire application (use atom for your application name to avoid problems):

edoc:application(myapp, ["."], [{dir, "doc"}]).

For single file:

edoc:run([], ["src/mymodule.erl"], [{dir, "doc"}]).

Documenting module:

%%% @doc Mathematical algorithms.
%%% <p>Compututing prime numbers, greater common denominator and factorial</p>
%%% @author J. Random

If you put your name in the header of module you will feel responsible for the code and a few words describing the module force me to rethink what I supposed to do.

For exported method:

%% @spec factorial(MaxNumber, FactorialSoFar) -> integer() 
%% @doc Find factorial for given number.

While documenting methods I found useful to define result type and meaningful names for parameters. It’s worth to note that first sentence will be used as short description of method, and paragraphs should be defined by <p> rather than simple line breaks.

The documentation about edoc tags is easy to find. But I have to read whole internet twice and spend some time with Erlang REPL to discover working combination of parameters.

Have fun generating Erlang docs 🙂

This entry was posted in Erlang. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s