@@ -15,6 +15,7 @@ module — a special variable is created in each module that has documentation m
1515"""
1616module DocMeta
1717import .. Documenter
18+ import Base: invokelatest
1819
1920" The unique `Symbol` that is used to store the metadata dictionary in each module."
2021const META = gensym (:docmeta )
@@ -31,14 +32,14 @@ const VALIDMETA = Dict{Symbol, Type}(:DocTestSetup => Union{Expr, Symbol})
3132"""
3233"""
3334function initdocmeta! (m:: Module )
34- if ! isdefined ( m, META)
35+ if ! invokelatest (isdefined, m, META)
3536 @debug " Creating documentation metadata dictionary (META=$META ) in $m "
3637 Core. eval (m, :(const $ META = $ (METATYPE ())))
3738 push! (METAMODULES, m)
3839 else
3940 @warn " Existing documentation metadata dictionary (META=$META ) in $m . Ignoring."
4041 end
41- return getfield ( m, META)
42+ return invokelatest (getfield, m, META)
4243end
4344
4445"""
@@ -48,7 +49,7 @@ Returns the documentation metadata dictionary for the module `m`. The dictionary
4849considered immutable and assigning values to it is not well-defined. To set documentation
4950metadata values, [`DocMeta.setdocmeta!`](@ref) should be used instead.
5051"""
51- getdocmeta (m:: Module ) = isdefined ( m, META) ? getfield ( m, META) : METATYPE ()
52+ getdocmeta (m:: Module ) = invokelatest (isdefined, m, META) ? invokelatest (getfield, m, META) : METATYPE ()
5253
5354"""
5455 getdocmeta(m::Module, key::Symbol, default=nothing)
@@ -74,7 +75,7 @@ function setdocmeta!(m::Module, key::Symbol, value; warn = true, recursive = fal
7475 setdocmeta! (mod, key, value; warn = warn, recursive = false )
7576 end
7677 else
77- isdefined ( m, META) || initdocmeta! (m)
78+ invokelatest (isdefined, m, META) || initdocmeta! (m)
7879 meta = getdocmeta (m)
7980 if warn && haskey (meta, key)
8081 @warn " $(key) already set for module $m . Overwriting."
0 commit comments