@@ -170,6 +170,12 @@ Base.nameof(frame) = isa(frame.code.scope, Method) ? frame.code.scope.name : nam
170
170
171
171
is_loc_meta (expr, kind) = isexpr (expr, :meta ) && length (expr. args) >= 1 && expr. args[1 ] === kind
172
172
173
+ """
174
+ isglobalref(g, mod, name)
175
+
176
+ Tests whether `g` is equal to `GlobalRef(mod, name)`.
177
+ """
178
+ isglobalref (g, mod, name) = isa (g, GlobalRef) && g. mod === mod && g. name == name
173
179
174
180
function to_function (x)
175
181
if isa (x, GlobalRef)
@@ -434,7 +440,24 @@ function prepare_toplevel(mod::Module, expr::Expr; filename=nothing, kwargs...)
434
440
return prepare_toplevel! (modexs, docexprs, mod, expr; filename= filename, kwargs... )
435
441
end
436
442
437
- isdocexpr (ex) = isexpr (ex, :macrocall ) && (a = ex. args[1 ]; a isa GlobalRef && a. mod == Core && a. name == Symbol (" @doc" ))
443
+ """
444
+ isdocexpr(ex)
445
+
446
+ Test whether expression `ex` is a `@doc` expression.
447
+ """
448
+ function isdocexpr (ex)
449
+ docsym = Symbol (" @doc" )
450
+ if isexpr (ex, :macrocall )
451
+ a = ex. args[1 ]
452
+ isglobalref (a, Core, docsym) && return true
453
+ isa (a, Symbol) && a == docsym && return true
454
+ if isexpr (a, :.)
455
+ mod, name = a. args[1 ], a. args[2 ]
456
+ return mod === :Core && isa (name, QuoteNode) && name. value == docsym
457
+ end
458
+ end
459
+ return false
460
+ end
438
461
439
462
prepare_toplevel! (modexs, docexprs, mod:: Module , ex:: Expr ; kwargs... ) =
440
463
prepare_toplevel! (modexs, docexprs, Expr (:block ), mod, ex; kwargs... )
0 commit comments