I’m using ApiDoc to create a documentation for my API with this hex: https://github.com/sldab/mix_apidoc
So I define many
@apidoc module attributes for few modules. As they are never used inside functions I’m getting a warning:
module attribute @apidoc was set but never used. Which is not a big deal, but a bit annoying.
Is there any way to suppress these warnings for a whole application?
Yes, consume the attributes or do not set them. This warning was introduced with Elixir 1.4 as far as I remember, so sldab had a lot of time to react on this change.
Elixir wise you can not do anything about the warning except for fixing it.
You might be able to create a macro
api_doc with the
generated: true option to declare the attribute?
I solved the problem.
It’s possible to use
@before_compile hook and invoke
Module.delete_attribute(env.module, :apidoc) inside it. So it removes all attributes before a compilation.
In my case, I use Phoenix controllers.
So I put in
my_project_web.ex inside quote:
def controller quote do @before_compile MyProjectWeb # ... end end
and in the root of
MyProjectWeb module added function:
def __before_compile__(env) do Module.delete_attribute(env.module, :apidoc) end