Since I’m the last person ( hopefully not the last one alive
), who did some significant work on EDoc, I think I can share some of my impressions.
Exactly. Generally speaking, everything that existed in the language when EDoc was created has good, though sometimes messy/redundant, support. Everything that got added after it has been created had poor/hacky or nonexistent support. This meant:
- behaviours / callbacks
- types and specs
- possibly also records
It’s evident upon inspecting the code, no doubts about that. Implementing EEP-48 changed some of that, but to make it happen it had to significantly modify some core parts, too, yet keep the erl_docgen
integration with the OTP build system intact, which was a major pain in the neck. Trailing comments on types are an example of this poor & hacky support.
There were some discussions going on before [1], during [2], and after [3] the EEP-48 implementation happened, as well as some next steps [4] listed. I don’t think all of these “next steps” have been addressed until today (even though the issue is now closed), but I don’t think that effort should be put on the shoulders of a single unpaid volunteer either (be it me or anyone else).
The TL;DR of the above links is that:
-
types can have trailing comments and since Erlang 24 callbacks can have trailing comments, too:
-callback f() -> ok.
%% This is a callback doc comment.
-
however, due to the reasons described in [3] comments on callbacks and types are limited to plain text and cannot have any tags, so no @since
, no @deprecated
, no @see
, etc
-
if we use rebar3 ex_doc
then doc chunks are put under _build/docs/lib/<the-app>/doc/chunks
, so to access them in the Erlang shell we have to run the shell via rebar3 as docs shell
; otherwise we might be surprised that there are no docs in the shell, though there are doc comments in the source
-
it’s possible to generate ExDoc docs for some OTP libs; with some effort it would be possible to upload them to https://hexdocs.pm
-
some formatting options like plain text lists don’t get rendered by EDoc as we would, having got used to Markdown, expect them to be; this means we have to resort to HTML tags
-
but only the set of HTML tags supported by the shell_docs
renderer is supported in the chunks; this means, for example, no tables
-
it’s possible to link to various entities using the EDoc link syntax: {@link //app/mod:fun/arity}
-
there are some EDoc tags which could be removed:
@spec
and @type
which since Erlang 24 are deprecated and superseded by Dialyzer/Gradualizer -spec
and -type
attributes; EDoc already supports the attributes and prioritises them over the old-style tags if both are present
@deprecated
which seems to be better handled by Xref -deprecated
attribute; EDoc could also recognise this attribute and report accordingly; on the other hand, if @deprecated
could be used also on types or callbacks it would be a use case not possible with Xref -deprecated

There’s a recent PR to ExDoc to fix that, but I believe it should rather be addressed upstream in EDoc. I’ve volunteered to prepare a patch, but anyone should feel free to beat me to it 
Generally, I think there’s still quite a bit to improve. But how can we do it? By chipping in!
If you’re an individual, then scratch your own itch. Pick your biggest EDoc / rebar3_ex_doc pain point and send a PR fixing it.
If you represent a company, sketch a grant/bounty plan or at least signal interest and I think something will happen under the EEF umbrella if there’s sufficient interest.
I’m happy to mentor newcomers willing to work on EDoc or get my hands dirty again if there’s a wish for bigger documentation improvements.