From 120183c28841f14eaab40b4046ec83e986baeaad Mon Sep 17 00:00:00 2001 From: Cody Tapscott Date: Mon, 10 Feb 2025 17:51:13 -0500 Subject: [PATCH 1/2] DocMeta: Access META binding through `invokelatest` Starting in Julia 1.12, global bindings have strict world-age semantics so this change is required to avoid the warning introduced by JuliaLang/julia#57133 --- CHANGELOG.md | 7 +++++++ src/DocMeta.jl | 9 +++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9bcc7e9c8..d0c6bb923e 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. ([#2624]) + ## Version [v1.8.0] - 2024-11-07 ### Changed @@ -1916,6 +1922,7 @@ 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 +[#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." From b849f742d7fe1ec53d8be0a5e9c9d8aaf3ca3df5 Mon Sep 17 00:00:00 2001 From: Morten Piibeleht Date: Tue, 11 Feb 2025 19:19:36 +1300 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0c6bb923e..1dfa86dce1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -* `DocMeta` has been updated to respect world-age semantics for bindings, introduced in Julia 1.12. ([#2624]) +* `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 @@ -1922,6 +1922,8 @@ 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