diff --git a/CHANGELOG.md b/CHANGELOG.md index d9bcc7e9c8..1dfa86dce1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +* `DocMeta` has been updated to respect world-age semantics for bindings, introduced in Julia 1.12. ([#2621], [#2622], [#2624]) + ## Version [v1.8.0] - 2024-11-07 ### Changed @@ -1916,6 +1922,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#2571]: https://github.com/JuliaDocs/Documenter.jl/issues/2571 [#2592]: https://github.com/JuliaDocs/Documenter.jl/issues/2592 [#2593]: https://github.com/JuliaDocs/Documenter.jl/issues/2593 +[#2621]: https://github.com/JuliaDocs/Documenter.jl/issues/2621 +[#2622]: https://github.com/JuliaDocs/Documenter.jl/issues/2622 +[#2624]: https://github.com/JuliaDocs/Documenter.jl/issues/2624 [JuliaLang/julia#36953]: https://github.com/JuliaLang/julia/issues/36953 [JuliaLang/julia#38054]: https://github.com/JuliaLang/julia/issues/38054 [JuliaLang/julia#39841]: https://github.com/JuliaLang/julia/issues/39841 diff --git a/src/DocMeta.jl b/src/DocMeta.jl index 5c5ac1bf00..99d86f3a6c 100644 --- a/src/DocMeta.jl +++ b/src/DocMeta.jl @@ -15,6 +15,7 @@ module — a special variable is created in each module that has documentation m """ module DocMeta import ..Documenter +import Base: invokelatest "The unique `Symbol` that is used to store the metadata dictionary in each module." const META = gensym(:docmeta) @@ -31,14 +32,14 @@ const VALIDMETA = Dict{Symbol, Type}(:DocTestSetup => Union{Expr, Symbol}) """ """ function initdocmeta!(m::Module) - if !isdefined(m, META) + if !invokelatest(isdefined, m, META) @debug "Creating documentation metadata dictionary (META=$META) in $m" Core.eval(m, :(const $META = $(METATYPE()))) push!(METAMODULES, m) else @warn "Existing documentation metadata dictionary (META=$META) in $m. Ignoring." end - return getfield(m, META) + return invokelatest(getfield, m, META) end """ @@ -48,7 +49,7 @@ Returns the documentation metadata dictionary for the module `m`. The dictionary considered immutable and assigning values to it is not well-defined. To set documentation metadata values, [`DocMeta.setdocmeta!`](@ref) should be used instead. """ -getdocmeta(m::Module) = isdefined(m, META) ? getfield(m, META) : METATYPE() +getdocmeta(m::Module) = invokelatest(isdefined, m, META) ? invokelatest(getfield, m, META) : METATYPE() """ getdocmeta(m::Module, key::Symbol, default=nothing) @@ -74,7 +75,7 @@ function setdocmeta!(m::Module, key::Symbol, value; warn = true, recursive = fal setdocmeta!(mod, key, value; warn = warn, recursive = false) end else - isdefined(m, META) || initdocmeta!(m) + invokelatest(isdefined, m, META) || initdocmeta!(m) meta = getdocmeta(m) if warn && haskey(meta, key) @warn "$(key) already set for module $m. Overwriting."