You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I feel like this is the behavior we want. In your case it seems better to attach the docstring to the generic function instead of two methods, since the docstring is written to apply to both.
If this is the desired behavior, then I guess I will find another solution. FYI, I’m hesitant to write a docstring for the generic function, because I still want to document different behavior for different types of x, which I feel could get messy with a single docstring:
f(T::Type, x; kwargs...) =T(f(x; kwargs...))
f(x::Integer) = x+x
f(x::String; add1=false) =f(length(x)) + add1
""" f([T], x::Integer)do something for integers"""f(::Type, ::Integer), f(::Integer)
""" f([T], x::String; add1=false)do something different for strings, with an optional keyword argument"""f(::Type, ::String; kwargs...), f(::String; kwargs...)
However, I don’t see any good reason for the current behavior other than saving the computational time of removing duplicates after collecting the relevant docstrings. (IMO, showing the same docstring multiple times does not add value.)
When attaching one docstring to two or more methods of the same function, the docstring is shown multiple times when querying the generic function:
The easiest fix would probably be to remove duplicates from the list of docstrings that match a query before printing them.
The text was updated successfully, but these errors were encountered: