Skip to content

Commit 120183c

Browse files
committed
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
1 parent 6abd828 commit 120183c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
44
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6+
## Unreleased
7+
8+
### Fixed
9+
10+
* `DocMeta` has been updated to respect world-age semantics for bindings, introduced in Julia 1.12. ([#2624])
11+
612
## Version [v1.8.0] - 2024-11-07
713

814
### Changed
@@ -1916,6 +1922,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
19161922
[#2571]: https://github.com/JuliaDocs/Documenter.jl/issues/2571
19171923
[#2592]: https://github.com/JuliaDocs/Documenter.jl/issues/2592
19181924
[#2593]: https://github.com/JuliaDocs/Documenter.jl/issues/2593
1925+
[#2624]: https://github.com/JuliaDocs/Documenter.jl/issues/2624
19191926
[JuliaLang/julia#36953]: https://github.com/JuliaLang/julia/issues/36953
19201927
[JuliaLang/julia#38054]: https://github.com/JuliaLang/julia/issues/38054
19211928
[JuliaLang/julia#39841]: https://github.com/JuliaLang/julia/issues/39841

src/DocMeta.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module — a special variable is created in each module that has documentation m
1515
"""
1616
module DocMeta
1717
import ..Documenter
18+
import Base: invokelatest
1819

1920
"The unique `Symbol` that is used to store the metadata dictionary in each module."
2021
const META = gensym(:docmeta)
@@ -31,14 +32,14 @@ const VALIDMETA = Dict{Symbol, Type}(:DocTestSetup => Union{Expr, Symbol})
3132
"""
3233
"""
3334
function 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)
4243
end
4344

4445
"""
@@ -48,7 +49,7 @@ Returns the documentation metadata dictionary for the module `m`. The dictionary
4849
considered immutable and assigning values to it is not well-defined. To set documentation
4950
metadata 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

Comments
 (0)