Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't warn about redefining docstrings in Main #23011

Closed
stevengj opened this issue Jul 28, 2017 · 6 comments · Fixed by #23019
Closed

don't warn about redefining docstrings in Main #23011

stevengj opened this issue Jul 28, 2017 · 6 comments · Fixed by #23019
Labels
docsystem The documentation building system

Comments

@stevengj
Copy link
Member

Similar to #18725, it came up on discourse that we shouldn't emit a warning when redefining docstrings during interactive use, i.e. for definitions in Main:

julia> @doc "foo" f(x) = x+1
f

julia> @doc "foo" f(x) = x+1
WARNING: replacing docs for 'f :: Tuple{Any}' in module 'Main'.
f
@stevengj stevengj added the docsystem The documentation building system label Jul 28, 2017
@stevengj
Copy link
Member Author

Looks like an easy patch should do it:

diff --git a/base/docs/Docs.jl b/base/docs/Docs.jl
index 14cbe17..2bd791f 100644
--- a/base/docs/Docs.jl
+++ b/base/docs/Docs.jl
@@ -232,7 +232,7 @@ Adds a new docstring `str` to the docsystem of `__module__` for `binding` and si
 function doc!(__module__::Module, b::Binding, str::DocStr, @nospecialize sig = Union{})
     initmeta(__module__)
     m = get!(meta(__module__), b, MultiDoc())
-    if haskey(m.docs, sig)
+    if haskey(m.docs, sig) && __module__ != Main
         # 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__)'.")

@stevengj
Copy link
Member Author

stevengj commented Jul 28, 2017

Or we could just delete the warning entirely. We already have a warning for redefining methods that are not in Main, and this seems somewhat redundant with that.

@JeffBezanson
Copy link
Sponsor Member

I believe it's possible to replace docs without redefining the method, e.g. by just writing the function name (?). So the warning might still be useful.

@fredrikekre
Copy link
Member

I believe it's possible to replace docs without redefining the method, e.g. by just writing the function name (?). So the warning might still be useful.

Yes that has happened to me several times, the warning about overwriting docs is very useful actually.

@zhangliye
Copy link

zhangliye commented Jul 29, 2017

I always edit functions in Juno and call them in IJulia to check the results. And then revise the code in Juno and "include()" the code file in IJulia again to check the results. In this situation, every time I saw a lot of warnings of redefining docstrings. When there are a lot of functions, the IJulia notebook is occupied by the warnings.

Although this warning would be helpful in some other situations, it is still convenient for the users to suppress the warnings when they want.

@stevengj
Copy link
Member Author

We definitely shouldn't have a warning for redefining docstrings in Main, at least, similar to #19888. Redefining things in interactive use is expected and shouldn't trigger warnings.

JeffBezanson pushed a commit that referenced this issue Jul 31, 2017
…23019)

suppress warning for redefining docstrings if the symbol is in Main (fixes #23011)
ararslan pushed a commit that referenced this issue Sep 11, 2017
…23019)

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

Ref #23019
(cherry picked from commit 4d4bdc1)
ararslan pushed a commit that referenced this issue Sep 13, 2017
…23019)

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

(cherry picked from commit 4d4bdc1)
vtjnash pushed a commit that referenced this issue Sep 14, 2017
…23019)

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

(cherry picked from commit 4d4bdc1)
ararslan pushed a commit that referenced this issue Sep 15, 2017
…23019)

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

(cherry picked from commit 4d4bdc1)
ararslan pushed a commit that referenced this issue Sep 16, 2017
…23019)

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

(cherry picked from commit 4d4bdc1)
ararslan pushed a commit that referenced this issue Sep 18, 2017
…23019)

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

(cherry picked from commit 4d4bdc1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docsystem The documentation building system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants