Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Added anchor links to admonition blocks, making it possible to create direct links to specific admonitions. ([#2505], [#2676], [#2688])
* Added different banners for dev and unreleased docs ([#2382], [#2682])

### Fixed

* In Julia v1.12, the queries used by `clear_module!` will now be versioned by world, allowing the deleting of bindings to work correctly. ([#2693])

## Version [v1.10.2] - 2025-04-25

### Fixed
Expand Down Expand Up @@ -2029,6 +2033,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#2676]: https://github.com/JuliaDocs/Documenter.jl/issues/2676
[#2682]: https://github.com/JuliaDocs/Documenter.jl/issues/2682
[#2685]: https://github.com/JuliaDocs/Documenter.jl/issues/2685
[#2693]: https://github.com/JuliaDocs/Documenter.jl/issues/2693
[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
Expand Down
30 changes: 20 additions & 10 deletions src/expander_pipeline.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
# Defines node "expanders" that transform nodes from the parsed markdown files.

function clear_global!(M::Module, name::Symbol)
isconst(M, name) && return
if VERSION >= v"1.9"
Nothing <: Core.get_binding_type(M, name) || return
setglobal!(M, name, nothing)
else
Core.eval(M, :($name = $nothing))
end
return nothing
end

# helper for "cleaning up" content of modules to enable garbage collection.
# See also <https://github.com/JuliaDocs/Documenter.jl/issues/2640>.
function clear_module!(M::Module)
# we need `invokelatest` here for Julia >= 1.12 (or 1.13?)
for name in Base.invokelatest(names, M, all = true)
if !isconst(M, name)
# see, e.g https://github.com/JuliaDocs/Documenter.jl/issues/2673
# it is not possible to set `nothing` to variables, which are strongly typed
# still attempt to set it, but ignore any errors
try
@eval M $name = $nothing
catch err
@debug "Could not clear variable `$name` by assigning `nothing`" err
end
for name in Base.invokelatest(names, M, all = true)::Vector{Symbol}
# see, e.g https://github.com/JuliaDocs/Documenter.jl/issues/2673
# it is not possible to set `nothing` to variables, which are strongly typed
# still attempt to set it, but ignore any errors
try
Base.invokelatest(clear_global!, M, name::Symbol)
catch err
@debug "Could not clear variable `$name` by assigning `nothing`" err

Check warning on line 25 in src/expander_pipeline.jl

View check run for this annotation

Codecov / codecov/patch

src/expander_pipeline.jl#L25

Added line #L25 was not covered by tests
end
VERSION >= v"1.12" && Base.delete_binding(M, name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a chance for this to be slow, I'd definitely would want to check this in the Oscar manual were a slowdown in this function caused us major pain before.

end
return
end
Expand Down
Loading