-
Notifications
You must be signed in to change notification settings - Fork 485
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
Filtering included docstrings #839
Comments
I am not sure what the intended logic currently is, but I think I would expect it to get all the docstrings that are more specific than the signature specified. So IMO
Additionally:
I also initially thought that it should be consistent with the REPL Whereas in Documenter I think we can assume that the doc author knows exactly which methods they want to document, so it should match "downwards". And if the author specifies the signature, they probably want to filter out unrelated more general docstrings. Thoughts on this would be very welcome though. |
Thanks for the feedback. Note that with JuliaLang/julia#29102 the REPL behavior will change. In particular But I agree that Documenter should not do the same as the REPL. I thought some time about this issues and at the beginning I came up with the same rules as you. But I think It must be possible to pull in only a specific dostring. For this reason, I think that Documenter should try to match only equal docstrings, no downwards or upwards. At the moment Documenter is trying to do exactly this, but it is confused in the presence of parametric types and some other situations. |
You are right -- we should only match exactly, not pull in multiple ones. As you say, it should be possible to splice both just general signatures and just specific signatures. For every line in an at-docs block, there should be a single docstring in the output. I think we should define the at-docs block to be a "low level" way of splicing docstrings. So it should allow you to be precise at the expense of additional verbosity. If we want a feature for pulling in multiple docstrings based on some type matching rules, that should be a feature of e.g. at-autodocs. As you say, this is how it appears to be working already. Just the parametric type thing needs to be fixed. That said, right now it seems that, when there is no exact match available, Documenter will do the same "dispatch" as Julia. So, for |
I like the idea of letting at-docs blocks be the "low level" way of splicing dosstrings. Regarding what to do, if there is no signature equal to the one queried (like in the I think The interesting question is, what should |
Yeah, I think that would be the way to do. I don't think this would affect that many builds either.. I find it unlikely that people would use this more specific type to specify their docstrings at the moment, so it would be a relatively harmless change to do.
Yup, just like should be doing right now.
I would've said "just throw docstring not found", but you can actually define a method like that (even though it can not be called). So I'd say if the user defines a method like this and refers to it, it should just work.. even though it should never come up in practice. |
What are the rules for filtering docstrings? Consider the following function
It is clear that
@docs foo(::Real)
and@docs foo(::Number)
should return#1
and#2
respectively (and they do). But what about the following?@docs foo(::A{T} where {T})
give#3
?@docs foo(::A{Int})
give#4
?@docs foo(::Int)
do?@docs foo(::A{Float64})
do?Now here is what is currently happening:
#1
and#3
.#4
.#1
,#2
,#3
.#1
and#3
.P.S.: You can check the above yourself by doing
Documenter.DocSystem.getdocs(Documenter.DocSystem.binding(Main, :foo), Tuple{A{T} where {T}})
.The text was updated successfully, but these errors were encountered: