Access docstring within a macro


Is there any way to access the docstring accompanying a macro at call place? It would be something like this:

macro MyMacro(arg)
# Do something with my docs
# It does not mean that I want to append the outer doc to some inner object using Main.@__doc__

"I want to access this docstring"
@MyMacro argument

I have seen this topic, which is closely related, but no response was given:


1 Like

Did you find an answer? I’d be interested in this too…

I tried to use a combination of @__doc__ and @doc, but that didn’t work, presumably due to scheduling issues. (The idea was to label a variable within the macro using @__doc__, so that the docstring is attached to this variable. Then, hypothetically, one could call@doc on the same variable to retrieve the docstring again. However, when doing so I always get “No documentation found” because the “binding variable does not exist”.)

@mike, you wrote most of the doc system, can you help us out?

(For more context, I’m working on this issue).

Yes, I was able to advance a little bit further, though not much because my day job is taking all my time.

It gets super complicated, but the scheduling issue is solved calling Doc undocumented methods manually over the created object. The undocumented methods are a mess because they use as parameters undocumented features (IdDicts and more) and access module-level undocumented fields directly and such.

I’m on my phone so I can’t say much else, sorry

I’ve left a comment on how to go about adding basic support for it in the case of @agent in the linked issue. Hopefully that helps :slight_smile:

Fantastic, thanks so much for this quick help!

For posterity: In my case, the problem was that the macro I’m working on creates a struct that I wanted to be able to document. However, the struct has to be created inside a double quote, and therefore one can’t simply apply @__doc__ to it. However, one can subsequently simply apply @__doc__ to the symbol that names the new struct, thus obviating the need for any more fancy metaprorgamming.