Skip to content

Commit 1e2e482

Browse files
authored
Remote restriction on documenting empty baremodules (#38998)
Replaces and closes #13109. The underlying bug here appears to have been fixed and the restriction here was never triggered since lowering now always inserts LineNumberNodes, but we might as well remove the restriction since the bug is fixed.
1 parent 560676d commit 1e2e482

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

base/docs/Docs.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,7 @@ function moduledoc(__source__, __module__, meta, def, def′::Expr)
406406
def = unblock(def)
407407
block = def.args[3].args
408408
if !def.args[1]
409-
isempty(block) && error("empty baremodules are not documentable.")
410-
insert!(block, 2, :(import Base: @doc))
409+
pushfirst!(block, :(import Base: @doc))
411410
end
412411
push!(block, docex)
413412
esc(Expr(:toplevel, def))

doc/src/manual/documentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ end
496496

497497
Documenting a `baremodule` by placing a docstring above the expression automatically imports
498498
`@doc` into the module. These imports must be done manually when the module expression is not
499-
documented. Empty `baremodule`s cannot be documented.
499+
documented.
500500

501501
### Global Variables
502502

test/docs.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,3 +1236,7 @@ Test.collect_test_logs() do # suppress printing of any
12361236
eval(quote "Second docstring" Module29432 end) # requires toplevel
12371237
end
12381238
@test docstrings_equal(@doc(Module29432), doc"Second docstring")
1239+
1240+
# Issue #13109
1241+
eval(Expr(:block, Expr(:macrocall, GlobalRef(Core, Symbol("@doc")), nothing, "...", Expr(:module, false, :MBareModuleEmpty, Expr(:block)))))
1242+
@test docstrings_equal(@doc(MBareModuleEmpty), doc"...")

0 commit comments

Comments
 (0)