2 ms·
That’s actually one of the reasons I like Elixirs approach to inline documentation so much. If you include a code example, the example is run as part of the tes
by brightball 9y ago
That’s actually one of the reasons I like Elixirs approach to inline documentation so much. If you include a code example, the example is run as part of the test suite. Makes is dead simple to automatically include simple unit tests right where the code is along with documentation that had to remain up to date.
http://whatdidilearn.info/2017/10/23/writing-documentation-in-elixir.html http://whatdidilearn.info/2017/10/23/writing-documentation-i...
- floatboth 9y agoThis is also somewhat popular in Python, Haskell and Rust. Nice, but doesn't seem applicable to all the situations. Works quite well for collections of simple independent functions e.g. I did that for a regex library https://github.com/myfreeweb/pcre-heavy/blob/9873fb019873340b212780d12595c0f66ec88613/library/Text/Regex/PCRE/Heavy.hs#L177-L196 https://github.com/myfreeweb/pcre-heavy/blob/9873fb019873340... — but didn't use much for other projects…
- brightball 9y agoYea, definitely not for everything. It's more of a complement to the rest of the test suite and also verifies that the documentation/examples in code comments are still accurate.