Skip to content

Commit

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

suppress warning for redefining docstrings if the symbol is in Main (fixes JuliaLang#23011)
  • Loading branch information
stevengj authored and JeffBezanson committed Jul 31, 2017
1 parent ba9d8ac commit 4d4bdc1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions base/docs/Docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,9 @@ function doc!(__module__::Module, b::Binding, str::DocStr, @nospecialize sig = U
m = get!(meta(__module__), 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.
warn("replacing docs for '$b :: $sig' in module '$(__module__)'.")
# that over-writing a docstring *may* have been accidental. The warning
# is suppressed for symbols in Main, for interactive use (#23011).
__module__ == Main || warn("replacing docs for '$b :: $sig' in module '$(__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
8 changes: 8 additions & 0 deletions test/docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1047,3 +1047,11 @@ let foo_docs = meta(I22105)[@var(I22105.foo)].docs
@test docstr.data[:typesig] === Union{}
@test docstr.data[:binding] == Binding(I22105, :foo)
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 4d4bdc1

Please sign in to comment.