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

Source link in expanded docstring redirect to Base #1374

Closed
lindnemi opened this issue Jul 20, 2020 · 8 comments
Closed

Source link in expanded docstring redirect to Base #1374

lindnemi opened this issue Jul 20, 2020 · 8 comments

Comments

@lindnemi
Copy link

Our packages has several submodules. In the documentation we have a "Library" subsection that shows the docstrings of all functions intended for public use. Some of the generated source links redirect to our github repo, others incorrectly link to Base. What's going on here?

The relevant page is here: https://fhell.github.io/NetworkDynamics.jl/dev/Library/

@mortenpi
Copy link
Member

It looks like it's the ones with Base.@kwdef. Julia probably does not store the correct location information for the docstring in that case. Would need some further investigation though.

@jonathan-laurent
Copy link

I have also seen this occurring.
To give another example, you can look at https://juliareinforcementlearning.org/ReinforcementLearning.jl/latest/rl_base/ and then click on the "Source" button for the first documented function.

@mortenpi
Copy link
Member

@jonathan-laurent It's also macros confusing the docsystem, just the @api one in your case:

"""
    (π::AbstractPolicy)(env) -> action
Policy is the most basic concept in reinforcement learning. A policy is a functional object which takes in an environemnt and generate an action.
"""
@api abstract type AbstractPolicy end

@jonathan-laurent
Copy link

@mortenpi Interesting. I think it would be good to fix this on Documenter's side as prefixing a declaration with a macro call is a pretty common pattern. I stumbled into the same problem in several of my packages and now I understand better why.

@mortenpi
Copy link
Member

I agree, but I have a hunch that it might be an upstream bug (the Julia docsystem attaching a wrong path to the docstring).

@mortenpi
Copy link
Member

mortenpi commented Aug 4, 2020

Just a quick follow-up: I believe the way to work around this is to attach the docstrings with the @doc macro. I.e. something like this:

@with_kw struct A
  a::Int = 6
  b::Float64 = -1.1
  c::UInt8
end

@doc """
    struct A
""" A

@bzinberg
Copy link

bzinberg commented Aug 9, 2020

As mentioned in JuliaLang/julia#36906 (comment), that workaround (which I have also been using for a while) is very helpful but loses field docstrings.

@mortenpi
Copy link
Member

This should be fixed on 1.6 JuliaLang/julia#37048, so no workaround should be necessary if you build the documentation on 1.6+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants