Skip to content

Commit

Permalink
suppress warning for redefining docstrings if the symbol is in Main (#…
Browse files Browse the repository at this point in the history
…23019)

suppress warning for redefining docstrings if the symbol is in Main (fixes #23011)

(cherry picked from commit 4d4bdc1)
  • Loading branch information
stevengj authored and ararslan committed Sep 16, 2017
1 parent 8411cb8 commit 7f10a4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions base/docs/Docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ function doc!(b::Binding, str::DocStr, sig::ANY = Union{})
m = get!(meta(), b, MultiDoc())
if haskey(m.docs, sig)
# We allow for docstrings to be updated, but print a warning since it is possible
# that over-writing a docstring *may* have been accidental.
s = "replacing docs for '$b :: $sig' in module '$(current_module())'."
isdefined(Base, :STDERR) ? warn(s) : ccall(:jl_, Void, (Any,), "WARNING: $s")
# that over-writing a docstring *may* have been accidental. The warning
# is suppressed for symbols in Main, for interactive use (#23011).
current_module() == Main || warn("replacing docs for '$b :: $sig' in module '$(current_module())'.")
else
# The ordering of docstrings for each Binding is defined by the order in which they
# are initially added. Replacing a specific docstring does not change it's ordering.
Expand Down
7 changes: 7 additions & 0 deletions test/docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1010,3 +1010,10 @@ end
"""
)

# issue #23011
@test_nowarn @eval Main begin
@doc "first" f23011() = 1
@doc "second" f23011() = 2
end
@test Main.f23011() == 2
@test docstrings_equal(@doc(Main.f23011), doc"second")

0 comments on commit 7f10a4c

Please sign in to comment.