From 4d4bdc1831ac0a9eba19b073bc36e7d4ffcb05d1 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Mon, 31 Jul 2017 15:26:35 -0400 Subject: [PATCH] suppress warning for redefining docstrings if the symbol is in Main (#23019) suppress warning for redefining docstrings if the symbol is in Main (fixes #23011) --- base/docs/Docs.jl | 5 +++-- test/docs.jl | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/base/docs/Docs.jl b/base/docs/Docs.jl index 14cbe174b7a7d..ef69e30962ff4 100644 --- a/base/docs/Docs.jl +++ b/base/docs/Docs.jl @@ -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. diff --git a/test/docs.jl b/test/docs.jl index e80801dbbd82b..7b2d34dc289c2 100644 --- a/test/docs.jl +++ b/test/docs.jl @@ -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")