Stream: helpdesk (published)

Topic: ✔ Trouble documenting a macro


view this post on Zulip Timothy (Mar 07 2022 at 16:01):

I have a string macro I'd like to document after-the-fact.

Looking at the @doc docs I see the section where it says to try @doc "..." :(mystr"") or @doc "..." :(@Module.macro) however I haven't had any success with either of those forms. Looking at Docs.jl I see

# For the special `:@mac` / `:(Base.@mac)` syntax for documenting a macro after definition.
isquotedmacrocall(@nospecialize x) =
    isexpr(x, :copyast, 1) &&
    isa(x.args[1], QuoteNode) &&
    isexpr(x.args[1].value, :macrocall, 2)

However isquotedmacrocall seems to return false for both of the forms mentioned in that comment (@mac, :(Base.@mac)), and so I'm at bit of a loss.

view this post on Zulip Fredrik Ekre (Mar 07 2022 at 16:14):

Does the syntax

"""
    name"..."

Something something.
"""
:(@name_str)

work? See https://docs.julialang.org/en/v1/manual/documentation/#Macros.

view this post on Zulip Timothy (Mar 07 2022 at 16:23):

This is quite odd. That did work, but going through my edit history I've already tried that before. I wonder if this could have been Revise.jl / state mutation -related weirdness.

In a fresh Julia session :(@name_str) is fine, but in my original session I tried all of the following without success:

view this post on Zulip Notification Bot (Mar 07 2022 at 16:26):

Timothy has marked this topic as resolved.


Last updated: Nov 22 2024 at 04:41 UTC