My experience with documentation is a world of pain. Having to deal with manually formatting your documentation with careful placement of ///
is driving me crazy. Whenever I want to improve documentation, I have the following problem:
/// aaaaaaaaaaaaaaaaaa
/// bbbbbbbbbbbbbbbbbb
/// cccccccccccccccccc
is my initial documentation. Now I add another sentence:
/// aaaaaaaaaaaaaaaaaaddddddddd
/// bbbbbbbbbbbbbbbbbb
/// cccccccccccccccccc
and now begins the painful part:
/// aaaaaaaaaaaaaaaaaa
ddddddddd
/// bbbbbbbbbbbbbbbbbb
/// cccccccccccccccccc
/// aaaaaaaaaaaaaaaaaa
/// ddddddddd
/// bbbbbbbbbbbbbbbbbb
/// cccccccccccccccccc
/// aaaaaaaaaaaaaaaaaa
/// dddddddddbbbbbbbbbbbbbbbbbb
/// cccccccccccccccccc
/// aaaaaaaaaaaaaaaaaa
/// dddddddddbbbbbbbbb
bbbbbbbbb
/// cccccccccccccccccc
/// aaaaaaaaaaaaaaaaaa
/// dddddddddbbbbbbbbb
/// bbbbbbbbb
/// cccccccccccccccccc
/// aaaaaaaaaaaaaaaaaa
/// dddddddddbbbbbbbbb
/// bbbbbbbbbcccccccccccccccccc
/// aaaaaaaaaaaaaaaaaa
/// dddddddddbbbbbbbbb
/// bbbbbbbbbccccccccc
ccccccccc
/// aaaaaaaaaaaaaaaaaa
/// dddddddddbbbbbbbbb
/// bbbbbbbbbccccccccc
/// ccccccccc
I wish I could do //* … *//
(multi-line doc comment) and have cargo-fmt
take care of the line length for me, so I only have to worry about the documentation part, not the formatting.
IMO, stuffing the complete documentation into the source code files is terrible. Documentation is important, but when I'm looking through some code, I don't want to be bothered by ⅔ of an *.rs
file bloated with doc comments (looking at you, std
). I'd much rather put only summary (one sentence to describe the module/struct/function), error/panic and safety doc comments in the source code directly and everything else in a *.rsdoc
file or similar, which would not have to be plastered with //!
and ///
everywhere.
If I want to read the complete documentation nicely formatted, I use cargo-doc
.