Elixir wants to warn me that my @doc
annotations won't get copied to the beam file:
warning: function foo/1 is private, @doc's are always discarded for private functions
lib/hello/world.ex:12
But I'd rather use @doc
for all my function documentation instead of switching between @doc
and #
.
How can I tell the compiler to stop warning me about this?
There is no way to silence compiler warnings.
In the past, people have asked about documenting private functions for use with ExDoc or DocTest. However, this not possible. Per José:
It is worth remembering that a private function does not exist outside of the module that defines it. You cannot test private functions because you can't invoke a private function outside of the module that defines it.
In fact, the compiler may even remove the private function entirely during compilation. This means a private function only exists when looking at the code and, if you need to look at the code to read it, then it is not documentation.
A private function is, for all purposes, exactly what you defined code comments to be: a temporary or semi-permanent blob which is aimed directly at developers. There is no guarantee it will exist tomorrow, which is why it is private.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With