Expand __MODULE__ inside moduledocs?

I just tried it out (on Elixir 1.10.4) and using the __MODULE__ special form inside a moduledoc block doesn’t expand correctly. Is there another way to avoid having to hard code the module name inside the documentation block?

This is what I tried specifically:

@moduledoc """
   This is the __MODULE__ module and therefore this should expand!
"""

Module docs are just regular strings, so you can use regular string interpolation:

@moduledoc """
Foo #{inspect(__MODULE__)}
"""
5 Likes

Thanks so much for that! That’s a great tip!