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

Documenting methods for the same function in different modules #13068

Closed
andreasnoack opened this issue Sep 11, 2015 · 1 comment
Closed

Documenting methods for the same function in different modules #13068

andreasnoack opened this issue Sep 11, 2015 · 1 comment
Labels
docsystem The documentation building system

Comments

@andreasnoack
Copy link
Member

There seems to be a problem with documenting the same function in different module. I think this should work in general and is important for linear algebra documentation strings where methods for the function are often defined in LinAlg and SparseMatrix. An example of the problem is

module A

export foo

doc"""
foo from A
"""
foo(::Int) = 1

end

module B

import A: foo

export foo

doc"""
foo from B
"""
foo(::Float64) = 2

end

julia> using B

julia> foo(1)
1

julia> foo(1.0)
2

help?> foo
search: foo floor ifloor pointer_from_objref OverflowError RoundFromZero FloatingPoint FileMonitor functionloc functionlocs StackOverflowError Factorization OutOfMemoryError unsafe_pointer_to_objref

  foo from A
@andreasnoack andreasnoack added the docsystem The documentation building system label Sep 11, 2015
@MichaelHatherly
Copy link
Member

All the docs are still being captured. The problem is here where only the first module that has docs is returned. Something like the following would fix it:

diff --git a/base/docs/Docs.jl b/base/docs/Docs.jl
index f248ace..970915e 100644
--- a/base/docs/Docs.jl
+++ b/base/docs/Docs.jl
@@ -238,6 +238,7 @@ doc(f::Function) = doc(f, Tuple)

 function doc(f::Function, sig::Type)
     isgeneric(f) && isempty(methods(f,sig)) && return nothing
+    docs = []
     for mod in modules
         if (haskey(meta(mod),f) && isa(meta(mod)[f],FuncDoc))
             fd = meta(mod)[f]
@@ -250,14 +251,14 @@ function doc(f::Function, sig::Type)
             end
             # if all method signatures are Union{} ( ⊥ ), concat all docstrings
             if isempty(results)
-                return catdoc([fd.meta[msig] for msig in reverse(fd.order)]...)
+                push!(docs, catdoc([fd.meta[msig] for msig in reverse(fd.order)]...))
             else
                 sort!(results, lt=(a,b)->type_morespecific(first(a),first(b)))
-                return catdoc([last(r) for r in results]...)
+                push!(docs, catdoc([last(r) for r in results]...))
             end
         end
     end
-    return nothing
+    isempty(docs) ? nothing : catdoc(docs...)
 end
 doc(f::Function,args::Any...) = doc(f, Tuple{args...})

MichaelHatherly added a commit to MichaelHatherly/julia that referenced this issue Sep 11, 2015
Searching for function documentation only checked the first module
that had any documentation for the `Function`, other candidate modules
were ignored.

Fixes JuliaLang#13068.
tkelman pushed a commit that referenced this issue Sep 11, 2015
Searching for function documentation only checked the first module
that had any documentation for the `Function`, other candidate modules
were ignored.

Fixes #13068.

(cherry picked from commit 2acf56d)
ref #13070
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

No branches or pull requests

2 participants