Skip to content

Don't use the Module(...) constructor to create a module #2683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

* Added anchor links to admonition blocks, making it possible to create direct links to specific admonitions. ([#2505], [#2676])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your changelog changes seem wrong, duplicating some existing entries


## Fixed

* `@meta`, `@setup`, and `@docs` blocks no longer generate spurious entries in the search index. ([#1929], [#2675])
* Modules for `@example` environments are now generated by `eval`'ing an expression, rather than invoking the `Module` constructor,
which is not recommended. (#2683)
* 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])

Expand Down Expand Up @@ -2025,6 +2032,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#2659]: https://github.com/JuliaDocs/Documenter.jl/issues/2659
[#2662]: https://github.com/JuliaDocs/Documenter.jl/issues/2662
[#2674]: https://github.com/JuliaDocs/Documenter.jl/issues/2674
[#2683]: https://github.com/JuliaDocs/Documenter.jl/pull/2683
[#2675]: https://github.com/JuliaDocs/Documenter.jl/issues/2675
[#2676]: https://github.com/JuliaDocs/Documenter.jl/issues/2676
[#2682]: https://github.com/JuliaDocs/Documenter.jl/issues/2682
Expand Down
14 changes: 8 additions & 6 deletions src/utilities/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -618,12 +618,14 @@ function get_sandbox_module!(meta, prefix, name = nothing; share_default_module
# Either fetch and return an existing sandbox from the meta dictionary (based on the generated name),
# or initialize a new clean one, which gets stored in meta for future re-use.
return get!(meta, sym) do
# If the module does not exists already, we need to construct a new one.
m = Module(sym)
# eval(expr) is available in the REPL (i.e. Main) so we emulate that for the sandbox
Core.eval(m, :(eval(x) = Core.eval($m, x)))
# modules created with Module() does not have include defined
Core.eval(m, :(include(x) = Base.include($m, abspath(x))))
# If the module does not exist already, we need to construct a new one.
m = Core.eval(Main, :(
module $sym
end
)
)
# Because this was eval'ed in using module creation syntax, `eval`, `include` and `Base`
# already exist in the scope of this module.
return m
end
end
Expand Down
Loading