Skip to content

Commit 3826279

Browse files
authored
Update module docstrings (fix #29432) (#37626)
1 parent 73413fc commit 3826279

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

base/docs/Docs.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ end
219219
Adds a new docstring `str` to the docsystem of `__module__` for `binding` and signature `sig`.
220220
"""
221221
function doc!(__module__::Module, b::Binding, str::DocStr, @nospecialize sig = Union{})
222+
# Module docstrings are in the module itself
223+
if defined(b)
224+
obj = resolve(b)
225+
if isa(obj, Module)
226+
__module__ = obj
227+
end
228+
end
222229
initmeta(__module__)
223230
m = get!(meta(__module__), b, MultiDoc())
224231
if haskey(m.docs, sig)

doc/make.jl

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

209209
makedocs(
210210
build = joinpath(buildroot, "doc", "_build", (render_pdf ? "pdf" : "html"), "en"),
211-
modules = [Base, Core, [Base.root_module(Base, stdlib.stdlib) for stdlib in STDLIB_DOCS]...],
211+
modules = [Main, Base, Core, [Base.root_module(Base, stdlib.stdlib) for stdlib in STDLIB_DOCS]...],
212212
clean = true,
213213
doctest = ("doctest=fix" in ARGS) ? (:fix) : ("doctest=only" in ARGS) ? (:only) : ("doctest=true" in ARGS) ? true : false,
214214
linkcheck = "linkcheck=true" in ARGS,

test/docs.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,3 +1224,10 @@ end
12241224
end
12251225
@test M27832.xs == ":(\$(Expr(:\$, :fn)))"
12261226
Core.atdoc!(_last_atdoc)
1227+
1228+
# issue #29432
1229+
"First docstring" module Module29432 end
1230+
Test.collect_test_logs() do # suppress printing of any warning
1231+
eval(quote "Second docstring" Module29432 end) # requires toplevel
1232+
end
1233+
@test docstrings_equal(@doc(Module29432), doc"Second docstring")

0 commit comments

Comments
 (0)