[erlang-questions] Best practice for defining functions with edoc,erlc,eunit and the dialyzer

Frank Mueller frank@REDACTED
Wed Dec 2 12:08:46 CET 2009

> Best practice for writing documenting and testing code
> I'd like to try and define "best practice" for writing documenting and
> testing Erlang code. I want to use:
>     - only the tools supplied in the OTP release
> So I use:
>     - eunit for unit testing
>     - the dialyzer for checking my code
>     - edoc for documenting things
>     - type specifications for specifying types

> Now for questions.
>     1) Does this represent best practice? Is this the best way to
>        write code? - can anybody improve on this?

It almost fits for me. I'm only separating functional and test code into different modules (I've
allways done so in other languages before, so just called it a habit.). And I use the module
documentation more. Take a look at
http://code.google.com/p/tideland-cel/source/browse/trunk/src/celjob.erl and

I'll change all my function comments to use the -spec notation.

>     3) Does anything else have to be fixed?

I'm not happy with the mixed notation in comments or using -spec. So it should be @spec in a
comment or -doc handled like -spec.

>     4) Improvements..
>        I can think of one. I have some code to convert .erl to
>        .html with correctly colored code and hyperlinks etc.
>        So I can "surf" the code. It would be nice to have hooks
>        into edoc so I can call this code

Sounds great, yes.

Warm regards


** Frank Mueller / Oldenburg / Germany

More information about the erlang-questions mailing list