<p dir="auto">On Julia master (so the conditional below evaluates as <code class="notranslate">true</code>).</p>
<p dir="auto">This works:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; module MyMod

       &quot;&quot;&quot;
       A docstring
       &quot;&quot;&quot;
       macro mymac(ex)
           return esc(ex)
       end

       end
Main.MyMod

help?&gt; MyMod.@mymac
  A docstring
"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-k">module</span> MyMod

       <span class="pl-s"><span class="pl-pds">"""</span></span>
<span class="pl-s">       A docstring</span>
<span class="pl-s">       <span class="pl-pds">"""</span></span>
       <span class="pl-k">macro</span> <span class="pl-en">mymac</span>(ex)
           <span class="pl-k">return</span> <span class="pl-c1">esc</span>(ex)
       <span class="pl-k">end</span>

       <span class="pl-k">end</span>
Main<span class="pl-k">.</span>MyMod

help?<span class="pl-k">&gt;</span> MyMod<span class="pl-k">.</span><span class="pl-c1">@mymac</span>
  A docstring
</pre></div>
<p dir="auto">But it doesn't if we put it inside a conditional expression (e.g., dependent on the Julia version):</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; module MyMod

       if VERSION &gt;= v&quot;1.2.0&quot;
       &quot;&quot;&quot;
       A docstring
       &quot;&quot;&quot;
       macro mymac(ex)
           return esc(ex)
       end
       end

       end
WARNING: replacing module MyMod.
Main.MyMod

help?&gt; MyMod.@mymac
  No documentation found.

  Main.MyMod.@mymac is a macro.

  # 1 method for macro &quot;@mymac&quot;:
  [1] @mymac(__source__::LineNumberNode, __module__::Module, ex) in Main.MyMod at REPL[3]:8"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-k">module</span> MyMod

       <span class="pl-k">if</span> <span class="pl-c1">VERSION</span> <span class="pl-k">&gt;=</span> <span class="pl-s"><span class="pl-pds"><span class="pl-c1">v</span>"</span>1.2.0<span class="pl-pds">"</span></span>
       <span class="pl-s"><span class="pl-pds">"""</span></span>
<span class="pl-s">       A docstring</span>
<span class="pl-s">       <span class="pl-pds">"""</span></span>
       <span class="pl-k">macro</span> <span class="pl-en">mymac</span>(ex)
           <span class="pl-k">return</span> <span class="pl-c1">esc</span>(ex)
       <span class="pl-k">end</span>
       <span class="pl-k">end</span>

       <span class="pl-k">end</span>
WARNING<span class="pl-k">:</span> replacing <span class="pl-k">module</span> MyMod.
Main<span class="pl-k">.</span>MyMod

help?<span class="pl-k">&gt;</span> MyMod<span class="pl-k">.</span><span class="pl-c1">@mymac</span>
  No documentation found.

  Main<span class="pl-k">.</span>MyMod<span class="pl-k">.</span><span class="pl-c1">@mymac</span> is a <span class="pl-k">macro</span>.

  <span class="pl-c"><span class="pl-c">#</span> 1 method for macro "@mymac":</span>
  [<span class="pl-c1">1</span>] <span class="pl-c1">@mymac</span>(__source__<span class="pl-k">::</span><span class="pl-c1">LineNumberNode</span>, __module__<span class="pl-k">::</span><span class="pl-c1">Module</span>, ex) <span class="pl-k">in</span> Main<span class="pl-k">.</span>MyMod at REPL[<span class="pl-c1">3</span>]<span class="pl-k">:</span><span class="pl-c1">8</span></pre></div>
<p dir="auto">However we can fix it with the post-hoc <code class="notranslate">@doc</code> mechanism:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; module MyMod

       if VERSION &gt;= v&quot;1.2.0&quot;
       macro mymac(ex)
           return esc(ex)
       end
       @doc &quot;A docstring&quot; :(MyMod.@mymac)
       end

       end
WARNING: replacing module MyMod.
Main.MyMod

help?&gt; MyMod.@mymac
  A docstring
"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-k">module</span> MyMod

       <span class="pl-k">if</span> <span class="pl-c1">VERSION</span> <span class="pl-k">&gt;=</span> <span class="pl-s"><span class="pl-pds"><span class="pl-c1">v</span>"</span>1.2.0<span class="pl-pds">"</span></span>
       <span class="pl-k">macro</span> <span class="pl-en">mymac</span>(ex)
           <span class="pl-k">return</span> <span class="pl-c1">esc</span>(ex)
       <span class="pl-k">end</span>
       <span class="pl-c1">@doc</span> <span class="pl-s"><span class="pl-pds">"</span>A docstring<span class="pl-pds">"</span></span> :(MyMod<span class="pl-k">.</span><span class="pl-c1">@mymac</span>)
       <span class="pl-k">end</span>

       <span class="pl-k">end</span>
WARNING<span class="pl-k">:</span> replacing <span class="pl-k">module</span> MyMod.
Main<span class="pl-k">.</span>MyMod

help?<span class="pl-k">&gt;</span> MyMod<span class="pl-k">.</span><span class="pl-c1">@mymac</span>
  A docstring
</pre></div>
<p dir="auto">Noted during  <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="239772670" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/22631" data-hovercard-type="pull_request" data-hovercard-url="/JuliaLang/julia/pull/22631/hovercard" href="https://github.com/JuliaLang/julia/pull/22631">#22631</a></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Meta.@lower begin
       if true
         &quot;&quot;&quot;
            hello
         &quot;&quot;&quot;
         h() = 1
       end
       end
:($(Expr(:thunk, CodeInfo(
2 1 ─      goto #3 if not true                                                                                        │
6 2 ─      $(Expr(:method, :h))                                                                                       │
  │   %3 = (Core.Typeof)(h)                                                                                           │
  │   %4 = (Core.svec)(%3)                                                                                            │
  │   %5 = (Core.svec)()                                                                                              │
  │   %6 = (Core.svec)(%4, %5)                                                                                        │
  │        $(Expr(:method, :h, :(%6), CodeInfo(quote                                                                  │
    return 1
end)))
  └──      return h                                                                                                   │
  3 ─      return                                                                                                     │
))))"><pre class="notranslate"><code class="notranslate">Meta.@lower begin
       if true
         """
            hello
         """
         h() = 1
       end
       end
:($(Expr(:thunk, CodeInfo(
2 1 ─      goto #3 if not true                                                                                        │
6 2 ─      $(Expr(:method, :h))                                                                                       │
  │   %3 = (Core.Typeof)(h)                                                                                           │
  │   %4 = (Core.svec)(%3)                                                                                            │
  │   %5 = (Core.svec)()                                                                                              │
  │   %6 = (Core.svec)(%4, %5)                                                                                        │
  │        $(Expr(:method, :h, :(%6), CodeInfo(quote                                                                  │
    return 1
end)))
  └──      return h                                                                                                   │
  3 ─      return                                                                                                     │
))))
</code></pre></div>
<p dir="auto">vs</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Meta.@lower begin
         &quot;&quot;&quot;
            hello
         &quot;&quot;&quot;
         h() =1
       end
:($(Expr(:thunk, CodeInfo(
2 1 ─       $(Expr(:method, :h))                                                                                      │
  │   %2  = (Core.Typeof)(h)                                                                                          │
  │   %3  = (Core.svec)(%2)                                                                                           │
  │   %4  = (Core.svec)()                                                                                             │
  │   %5  = (Core.svec)(%3, %4)                                                                                       │
  │         $(Expr(:method, :h, :(%5), CodeInfo(quote                                                                 │
    return 1
end)))
  │   %7  = (Base.Docs.Binding)(Main, :h)                                                                             │
  │   %8  = (Core.svec)(&quot;   hello\n&quot;)                                                                                 │
  │   %9  = (Dict)(:path =&gt; &quot;REPL[3]&quot;, :linenumber =&gt; 2, :module =&gt; Main)                                             │
  │   %10 = (Base.Docs.docstr)(%8, %9)                                                                                │
  │   %11 = (Core.apply_type)(Tuple)                                                                                  │
  │   %12 = (Core.apply_type)(Union, %11)                                                                             │
  │   %13 = (Base.Docs.doc!)(Main, %7, %10, %12)                                                                      │
  └──       return %13                                                                                                │
))))"><pre class="notranslate"><code class="notranslate">Meta.@lower begin
         """
            hello
         """
         h() =1
       end
:($(Expr(:thunk, CodeInfo(
2 1 ─       $(Expr(:method, :h))                                                                                      │
  │   %2  = (Core.Typeof)(h)                                                                                          │
  │   %3  = (Core.svec)(%2)                                                                                           │
  │   %4  = (Core.svec)()                                                                                             │
  │   %5  = (Core.svec)(%3, %4)                                                                                       │
  │         $(Expr(:method, :h, :(%5), CodeInfo(quote                                                                 │
    return 1
end)))
  │   %7  = (Base.Docs.Binding)(Main, :h)                                                                             │
  │   %8  = (Core.svec)("   hello\n")                                                                                 │
  │   %9  = (Dict)(:path =&gt; "REPL[3]", :linenumber =&gt; 2, :module =&gt; Main)                                             │
  │   %10 = (Base.Docs.docstr)(%8, %9)                                                                                │
  │   %11 = (Core.apply_type)(Tuple)                                                                                  │
  │   %12 = (Core.apply_type)(Union, %11)                                                                             │
  │   %13 = (Base.Docs.doc!)(Main, %7, %10, %12)                                                                      │
  └──       return %13                                                                                                │
))))
</code></pre></div>