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

Fix 'docstrings potentially missing' warnings #72

Closed
schillic opened this issue Dec 9, 2017 · 11 comments
Closed

Fix 'docstrings potentially missing' warnings #72

schillic opened this issue Dec 9, 2017 · 11 comments
Assignees
Labels
external 📤 Related to external packages

Comments

@schillic
Copy link
Member

schillic commented Dec 9, 2017

Creating the documentation warns about potentially missing docstrings.
However, they are defined and occur properly in the final documentation.

Most notably:

  • LazySets.σ
  • LazySets.apply_recipe

For the non-apply_recipe functions the problem is related to type parameters.

@schillic schillic added the documentation 📖 Documentation and manual label Dec 9, 2017
@schillic schillic self-assigned this Dec 9, 2017
@schillic
Copy link
Member Author

schillic commented Dec 9, 2017

I had a look at the Documenter.jl code where this warning is printed.

Use case: σ for BallInf:
We have this function signature in the source code:

σ(d::AbstractVector{<:Real}, B::BallInf)

and this doc signature:

σ(::AbstractVector{Float64}, ::BallInf)

In Documenter.jl in the above-mentioned function this results in the following object:

object == LazySets.σ-Tuple{AbstractArray{Float64,1},LazySets.BallInf}
object.binding == LazySets.σ
object.signature == Tuple{AbstractArray{Float64,1},LazySets.BallInf}

So far so good. Now let us see what signature is stored in signatures:

signatures == Set(Type[ ..., Tuple{AbstractArray{#s9,1} where #s9<:Real,LazySets.BallInf}, ...])

(The identifier #s9 changes with each run.)

Documenter.jl cannot match this. So let us change the doc signature the way it seems to be expected.

σ(::AbstractVector{N} where N<:Real, ::BallInf)

This still does not help. It seems that Documenter.jl does not understand where phrases.

@schillic
Copy link
Member Author

schillic commented Dec 9, 2017

Even worse: How can we resolve the warnings for shared type parameters such as in HPolygon.jl?

addconstraint!(P::HPolygon{N}, constraint::LinearConstraint{N}) where {N<:Real}

Current docs signature:

addconstraint!(::HPolygon{Float64}, ::LinearConstraint{Float64})

The following does not work because it is not even found in an earlier phase of Documenter.jl.

addconstraint!(::HPolygon{<:Real}, ::LinearConstraint{<:Real})

Note that the expected docs signature has a strange Union type where the first entry is as expected and the second entry is just a 1-Tuple of the parametric type N:

signatures == Set(Type[ Union{Tuple{LazySets.HPolygon{N},LazySets.LinearConstraint{N}}, Tuple{N}} where N<:Real, ... ])

@schillic
Copy link
Member Author

schillic commented Dec 9, 2017

Another comment:
The reason why we do not see this warning for some other functions such as

intersection(L1::Line{N}, L2::Line{N})::Vector{N} where {N<:Real}

in LinearConstraints.jl is that Documenter.jl simply assumes the following:
If there is only one function with the given binding (i.e., function name) left, then it is the function we want.
This is also why sometimes a warning might not occur in one run and pop up in the next run again because in the first run it was the last function of its kind (depends on the iteration order of the files, which is "nondeterministic"). I saw this several times for

Base.:* :: Tuple{AbstractArray{#s13,2} where #s13<:Real,LazySets.LazySet}

@schillic
Copy link
Member Author

schillic commented Dec 9, 2017

I am now certain that this is a problem with Documenter.jl. See the following example for HPolygonOpt.jl's function:

Tuple{AbstractArray{#s1,1} where #s1<:Real,LazySets.HPolygonOpt}

This is the object that is created from the doc string. The array of signatures for this function contains the following:

Tuple{AbstractArray{#s13,1} where #s13<:Real,LazySets.HPolygonOpt}

Clearly the two tuples are identical up to renaming of the type parameter. But a == comparison returns false.

@schillic schillic removed their assignment Dec 10, 2017
@schillic
Copy link
Member Author

schillic commented Dec 10, 2017

Another issue: The hyperlinks in the HTML documentation do not work if we include default values. See, e.g., norm for BallInf and Hyperrectangle - they point to the same entry (probably the first one, in this case BallInf).

By removing =Inf the hyperlinks are corrected, but we get more warnings...

@mforets
Copy link
Member

mforets commented Dec 10, 2017

i dunno.. once i tried to reproduce warnings starting from a very simple example that has say two different functions and uses where and stuff and it was ok.. so, i didn't get a minimal (non-working) example to raise an issue in Documenter.jl

@schillic
Copy link
Member Author

The problem occurs as soon as you have two methods with the same name, see here.

@mforets
Copy link
Member

mforets commented Dec 10, 2017

then it would be nice to know if this is a known bug in documenter or not.

@schillic
Copy link
Member Author

schillic commented Dec 11, 2017

Here is a minimal example to reproduce the main problem (uses our LazySets module).
I also pushed it to this branch.

test.jl contains:

export foo

"""
This is a very nice function.
"""
function foo(::Vector{N}, ::N) where {N<:Signed}
    println("foo_signed")
end

"""
This is a very poor function.
"""
function foo(::Vector{N}, ::N) where {N<:AbstractFloat}
    println("foo_float")
end

Then in LazySets.jl include this file into the module:

include("test.jl")

Then in some docs file add (with \ removed):

\```@docs
foo(::Vector{N}, ::N) where {N<:Signed}
foo(::Vector{N}, ::N) where {N<:AbstractFloat}
\```

(Using concrete types will not help, either.)


Result:

!! XX docstrings potentially missing:
...
    LazySets.foo :: Union{Tuple{Array{N,1},N}, Tuple{N}} where N<:Signed                        
    LazySets.foo :: Union{Tuple{Array{N,1},N}, Tuple{N}} where N<:AbstractFloat
...

However, the URLs in the HTML output are created correctly:
LazySets/docs/build/lib/operations.html#LazySets.foo-Union{Tuple{Array{N,1},N},%20Tuple{N}}%20where%20N%3C:Signed

@schillic
Copy link
Member Author

I have asked about this in the Documenter.jl repo.

@mforets mforets mentioned this issue Dec 28, 2017
11 tasks
schillic added a commit that referenced this issue Aug 2, 2018
@schillic schillic added the external 📤 Related to external packages label Aug 11, 2018
@schillic schillic removed the documentation 📖 Documentation and manual label Aug 28, 2018
@schillic schillic self-assigned this Nov 22, 2018
@schillic
Copy link
Member Author

This is now more or less supported. I will send a PR in the near future.

schillic added a commit that referenced this issue Nov 29, 2018
#72 - Fix 'where' syntax in doc references
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external 📤 Related to external packages
Projects
None yet
Development

No branches or pull requests

2 participants