Skip to content

Commit 4328aec

Browse files
authored
Fix cleaning of the modules (JuliaDocs#2674)
1 parent 8781520 commit 4328aec

File tree

4 files changed

+49
-5
lines changed

4 files changed

+49
-5
lines changed

CHANGELOG.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@
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-
# Version [v1.10.0] - 2025-03-31
6+
## Version [v1.10.1] - 2025-03-31
77

8-
## Changed
8+
### Fixed
9+
10+
* Fixed a bug in the cleaning of `@example` blocks with `a::SomeType = somevalue` typed declarations. ([#2674])
11+
12+
## Version [v1.10.0] - 2025-03-31
13+
14+
### Changed
915

1016
* Now the cursor remain focused on search box even after selecting the filter. ([#2410])
1117
* The "sandbox" modules used for running the code (doctests, examples) are now cleared after a page has been processed, allowing the garbage collector to reclaim memory and therefore reducing memory usage. ([#2640], [#2662])
1218
* Show file paths in error messages relative to the current working directory instead of relative to the document root. ([#2659])
1319

14-
## Fixed
20+
### Fixed
1521

1622
* Don't require custom themes to set a color for the 'todo' admonition. ([#2576])
1723
* Entries in `@repl` blocks that were hidden with `# hide` no longer produce erroneous empty lines ([#1521], [#2054], [#2399])
@@ -1999,6 +2005,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
19992005
[#2658]: https://github.com/JuliaDocs/Documenter.jl/issues/2658
20002006
[#2659]: https://github.com/JuliaDocs/Documenter.jl/issues/2659
20012007
[#2662]: https://github.com/JuliaDocs/Documenter.jl/issues/2662
2008+
[#2674]: https://github.com/JuliaDocs/Documenter.jl/issues/2674
20022009
[JuliaLang/julia#36953]: https://github.com/JuliaLang/julia/issues/36953
20032010
[JuliaLang/julia#38054]: https://github.com/JuliaLang/julia/issues/38054
20042011
[JuliaLang/julia#39841]: https://github.com/JuliaLang/julia/issues/39841

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Documenter"
22
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3-
version = "1.10.0"
3+
version = "1.10.1"
44

55
[deps]
66
ANSIColoredPrinters = "a4c015fc-c6ff-483c-b24f-f7ea428134e9"

src/expander_pipeline.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ function clear_module!(M::Module)
66
# we need `invokelatest` here for Julia >= 1.12 (or 1.13?)
77
for name in Base.invokelatest(names, M, all = true)
88
if !isconst(M, name)
9-
@eval M $name = $nothing
9+
# see, e.g https://github.com/JuliaDocs/Documenter.jl/issues/2673
10+
# it is not possible to set `nothing` to variables, which are strongly typed
11+
# still attempt to set it, but ignore any errors
12+
try
13+
@eval M $name = $nothing
14+
catch err
15+
@debug "Could not clear variable `$name` by assigning `nothing`" err
16+
end
1017
end
1118
end
1219
return

test/clear_module/src/index.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,33 @@ a = MyMutableStruct(1)
2121
Once Documenter is finished processing this page, it should remove the
2222
reference to the object `a` and a subsequent garbage collection should free
2323
it, which we can later test by observing the value of `Main.finalizer_count`.
24+
25+
# Example blocks
26+
27+
```@example example-1
28+
a = 1 # simple assignment
29+
```
30+
31+
```@example example-2
32+
nothing = 1 # it is possible to use `nothing` as a variable name
33+
a = 2
34+
```
35+
36+
```@example example-3
37+
nothing() = 3 # it is possible to use `nothing` as a function name
38+
a = nothing()
39+
```
40+
41+
```@example example-4
42+
@static if VERSION >= v"1.8"
43+
typed::String = "string" # it is possible to use `::` to specify the type of a variable
44+
end
45+
```
46+
47+
```@example example-5
48+
const a = 5 # it is possible to use `const` to define a constant
49+
```
50+
51+
Once Documenter is finished processing this page, it attempts to remove the
52+
variables defined in the example blocks. Documenter should not error when
53+
processing those example blocks even if it cannot remove the variables.

0 commit comments

Comments
 (0)