`Base.Docs.doc` failing with 1.11.0

We are using the following function to modify docstrings of some of our types to “dynamically” add information:

function _finalize_docstring(datatype::Type)
    binding = Base.Docs.aliasof(datatype, typeof(datatype))
    multidoc = Base.Docs.meta(@__MODULE__)[binding]
    old_data = multidoc.docs[Union{}].data

    multidoc.docs[Union{}] = Base.Docs.docstr("""
    $(Base.Docs.doc(datatype))

    adding other stuff
    """)
    multidoc.docs[Union{}].data = old_data

    return nothing
end

which is called right after defining it

"""
Base documentation.
"""
struct Foo
    # ...
end

_finalize_docstring(Foo)

I tried updating to Julia 1.11 and now get the following error during precompilation:

ERROR: LoadError: MethodError: no method matching doc(::Type{MyModule.Foo})
The function `doc` exists, but no method is defined for this combination of argument types.

Does anyone have an idea what changed since 1.10.5 (where it is working perfectly)? Wasn’t sure if that is an actual bug, or if our usage was just hacky and randomly working before, so I thought I’d ask here before opening an issue.

Someone had a similar problem on Slack. What if you do using REPL?

1 Like

Thanks!!

It “works”. Using import REPL seems to be sufficient. However this obviously requires REPL as explicit dependency of the package.

Was there any further information in slack?

Apparently all the methods for doc are defined in REPL