AssertionError: md isa Markdown.MD

I wanted to generate documentation for a project. I have a make.jl under the docs directory generated by PkgTemplate like the following:

using Documenter
using MyModule

makedocs(;
    modules=[MyModule],
    authors="author",
    repo="https://github.com/user/MyModule.jl/blob/{commit}{path}#L{line}",
    sitename="MyModule.jl",
    format=Documenter.HTML(;
        prettyurls=get(ENV, "CI", "false") == "true",
        canonical="https://user.github.io/MyModule.jl",
        assets=String[],
    ),
    pages=[
        "Home" => "index.md",
    ],
)

deploydocs(;
    repo="github.com/user/MyModule.jl"
)

julia make.jl gave me the following error

[ Info: SetupBuildDirectory: setting up build directory.
[ Info: Doctest: running doctests.
ERROR: LoadError: AssertionError: md isa Markdown.MD
Stacktrace:
... ...

I compared with another project for which I succeeded in making documentation, but could not figure out what went wrong here.
Suggestions are really appreciated. Thanks.

I find out that it was due to I used LazyHelp from PyPlot to get the docstring from the Python module that was imported to my project.

I have sth. like the following in my module (copied from PyPlot.jl):

for f in plt_funcs
    sf = string(f)
    @eval @doc LazyHelp(plt,$sf) function $f(args...; kws...)
        if !hasproperty(plt, $sf)
            error("matplotlib ", version, " does not have pyplot.", $sf)
        end
        return pycall(plt.$sf, PyAny, args...; kws...)
    end
end

If I comment out this part, then the documentation can be successfully generated. If there a way to proceed without commenting out this part?

It looks like that the docstring that LazyHelp attaches is not a Markdown.MD and that confuses Documenter. But it’s not immediately obvious where things are going wrong.

I would encourage you to open an issue for Documenter – minimally, we should turn that assertion into a more helpful error. It would help to have a small, isolated example to reproduce this (e.g. a simple module that one could run separately of any dependencies etc.)

1 Like

issue opened for Documenter.

2 Likes