Docstrings from package extensions in Documenter.jl

Say I have a package MyPackage

module MyPackage

"""
Standard behavior.
"""
function do_something(x::Vector)
    x .^ 3
end

end # module

with a CUDA extension:

module CUDAExt

import MyPackage: do_something

"""
Special CUDA behavior with such-and-such extra info for usage
"""
function do_something(x::CuVector)
    x .^ 3
end

end # module

Obviously, I now want a page in my docs explaining the extra info regarding CUDA, including the CUDA-specific docstring. Is there an accepted way to do this?

In the “standard” docstring. Include a discussion like “If CUDA is loaded…”

You can load the extensions in the docs as well (we tried to even make it safe for earlier Julia versions here I think) see

That way all function definitions (and their docs) from the extension should be loaded when rendering the docs, so you can add them.

But as Michael wrote – a remark in the “standard docstring” is probably also a good idea.

1 Like