Reference a static variable in function docs

Hi all,

Earlier I found a resource that mentioned you can reference a static variable in function documents, but I’m unable to find the resource again to see how they did it.

How do you do it?

I’ve tried the following without success:

@doc """
  Starts up the ets table (with name @cache_name)
  yada yada yada
  """

and

@doc """
  Starts up the ets table (with name #{@cache_name})
  yada yada yada
"""

Can you show a full example? The latter should work fine. Notably these are “module attributes” not static variables.

1 Like

Doh, yes Module Attributes.

I just upgraded to 1.8.0 and tried again. This time #{@cache_name} worked. I don’t think the resource I found earlier was for 1.8.0 though.

I don’t think anything related to this changed in 1.8.0

If you used the ~S sigil to define the docs earlier, it ignores string interpolation. Only using the triple double-quotes allows it.

Or using ~s.