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

Copying docstrings with @doc macro in packages doesn't work on master #52141

Closed
jmert opened this issue Nov 13, 2023 · 0 comments · Fixed by #54499
Closed

Copying docstrings with @doc macro in packages doesn't work on master #52141

jmert opened this issue Nov 13, 2023 · 0 comments · Fixed by #54499

Comments

@jmert
Copy link
Contributor

jmert commented Nov 13, 2023

Accessing the documentation attached to a binding with @doc name seems to return nothing inside a package, so doing something like copying a docstring from one binding to another no longer works.

For example, with a new package:

$ julia -e 'using Pkg; Pkg.generate("CopyDocs")'
  Generating  project CopyDocs:
    CopyDocs/Project.toml
    CopyDocs/src/CopyDocs.jl
$ cd CopyDocs

and writing the module

$ cat - > src/CopyDocs.jl <<EOF
module CopyDocs
export A, B
"My docstring" function A end
@doc (@doc A) function B end
end
EOF

The docstring for B exists on Julia 1.10 and prior ...

$ julia +1.10 --quiet --project
julia> VERSION
v"1.10.0-rc1"

julia> using CopyDocs

help?> A
search: A as Any any all abs ARGS ans axes atan asin asec any! all! acsc acot acos abs2 Array atanh atand asinh asind asech asecd

  My docstring

help?> B
search: B Bool big Base bind break begin bswap BitSet BigInt BitArray BigFloat binomial basename Broadcast BitVector BitMatrix

  My docstring

but appears to be nothing on master:

$ julia-dev --quiet --project
julia> VERSION
v"1.11.0-DEV.890"

julia> using CopyDocs

help?> A
search: A

  My docstring

help?> B
search: B

After some digging through the Docs code, I've found the pair of PRs #48594 and #51399 that effect Base.Docs.docm(). The former was merged before 1.10 was branched, so that doesn't appear to be the cause — therefore I'm guessing the movement of REPL out of the system image impacted this, though I haven't bisected to be sure.

Using the guess that @doc needs REPL to function, I tried adding it to the package dependencies and loading inside the package, and it does appear to fix the problem with the docstring not copying:

$ sed -i '1 a using REPL' src/CopyDocs.jl
$ julia-dev --project -e 'using Pkg; Pkg.add("REPL")'
...

and then

$ julia-dev --quiet --project
julia> VERSION
v"1.11.0-DEV.890"

julia> using CopyDocs

help?> B
search: B

  My docstring

Of course, I'd rather not have to add a dependency on the REPL.

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

Successfully merging a pull request may close this issue.

1 participant