ali-ramadhan / DocumenterCitations.jl

DocumenterCitations.jl uses Bibliography.jl to add support for BibTeX citations and references in documentation pages generated by Documenter.jl.
https://ali-ramadhan.github.io/DocumenterCitations.jl/dev
MIT License
65 stars 10 forks source link

When using `doctest=:fix`, I get `ERROR: KeyError: key Markdown.Code(...` #55

Closed fingolfin closed 2 years ago

fingolfin commented 2 years ago

When trying to "fix" doctests for our project, I get the following error in Julia 1.6.5, with Documenter v0.27.10 and DocumenterCitations v0.2.11 and also DEV

julia> Documenter.doctest(Oscar; fix=true)
[ Info: SetupBuildDirectory: setting up build directory.
[ Info: Doctest: running doctests.
┌ Warning: could not find code block in source file
└ @ Documenter.DocTests ~/.julia/packages/Documenter/qdbx6/src/DocTests.jl:421
[ Info: Skipped ExpandTemplates step (doctest only).
[ Info: Skipped CrossReferences step (doctest only).
[ Info: Citations: building citations.
┌ Error: Doctesting failed
│   exception =
│    KeyError: key Markdown.Code("@meta", "CurrentModule = Oscar\nDocTestSetup = quote\n  using Oscar\nend") not found
│    Stacktrace:
│      [1] getindex(d::IdDict{Any, Any}, key::Any)
│        @ Base ./iddict.jl:93
│      [2] expand_citations(doc::Documenter.Documents.Document)
│        @ DocumenterCitations ~/.julia/packages/DocumenterCitations/syRlI/src/citations.jl:15
│      [3] runner(#unused#::Type{DocumenterCitations.Citations}, doc::Documenter.Documents.Document)
│        @ DocumenterCitations ~/.julia/packages/DocumenterCitations/syRlI/src/citations.jl:8
│      [4] dispatch(#unused#::Type{Documenter.Builder.DocumentPipeline}, x::Documenter.Documents.Document)
│        @ Documenter.Utilities.Selectors ~/.julia/packages/Documenter/qdbx6/src/Utilities/Selectors.jl:170
│      [5] #2
│        @ ~/.julia/packages/Documenter/qdbx6/src/Documenter.jl:266 [inlined]
│      [6] cd(f::Documenter.var"#2#3"{Documenter.Documents.Document}, dir::String)
│        @ Base.Filesystem ./file.jl:106
│      [7] makedocs(; debug::Bool, format::Documenter.Writers.HTMLWriter.HTML, kwargs::Base.Iterators.Pairs{Symbol, Any, NTuple{6, Symbol}, NamedTuple{(:root, :source, :sitename, :doctest, :modules, :doctestfilters), Tuple{String, String, String, Symbol, Vector{Module}, Vector{Regex}}}})
│        @ Documenter ~/.julia/packages/Documenter/qdbx6/src/Documenter.jl:265
│      [8] (::Documenter.var"#all_doctests#32"{Bool, Vector{Regex}, Vector{Module}})()
│        @ Documenter ~/.julia/packages/Documenter/qdbx6/src/Documenter.jl:874
│      [9] macro expansion
│        @ ~/.julia/packages/Documenter/qdbx6/src/Documenter.jl:895 [inlined]
│     [10] macro expansion
│        @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
│     [11] doctest(source::String, modules::Vector{Module}; fix::Bool, testset::String, doctestfilters::Vector{Regex})
│        @ Documenter ~/.julia/packages/Documenter/qdbx6/src/Documenter.jl:895
│     [12] doctest(package::Module; manual::Bool, testset::Nothing, kwargs::Base.Iterators.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:fix,), Tuple{Bool}}})
│        @ Documenter ~/.julia/packages/Documenter/qdbx6/src/Documenter.jl:830
│     [13] top-level scope
│        @ REPL[59]:1
│     [14] eval
│        @ ./boot.jl:360 [inlined]
│     [15] eval_user_input(ast::Any, backend::REPL.REPLBackend)
│        @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:139
│     [16] repl_backend_loop(backend::REPL.REPLBackend)
│        @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:200
│     [17] start_repl_backend(backend::REPL.REPLBackend, consumer::Any)
│        @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:185
│     [18] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool)
│        @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:317
│     [19] run_repl(repl::REPL.AbstractREPL, consumer::Any)
│        @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:305
│     [20] (::Base.var"#875#877"{Bool, Bool, Bool})(REPL::Module)
│        @ Base ./client.jl:387
│     [21] #invokelatest#2
│        @ ./essentials.jl:708 [inlined]
│     [22] invokelatest
│        @ ./essentials.jl:706 [inlined]
│     [23] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
│        @ Base ./client.jl:372
│     [24] exec_options(opts::Base.JLOptions)
│        @ Base ./client.jl:302
│     [25] _start()
│        @ Base ./client.jl:485
└ @ Documenter ~/.julia/packages/Documenter/qdbx6/src/Documenter.jl:884
fingolfin commented 2 years ago

Actually I can reproduce this in this repo itself:

julia> doctest(DocumenterCitations; fix=true)
[ Info: SetupBuildDirectory: setting up build directory.
[ Info: Doctest: running doctests.
[ Info: Skipped ExpandTemplates step (doctest only).
[ Info: Skipped CrossReferences step (doctest only).
[ Info: Citations: building citations.
┌ Error: Doctesting failed
│   exception =
│    KeyError: key Markdown.Paragraph(Any["Here we create a full list of formatted references contained in our ", Markdown.Code("", ".bib"), " file using"]) not found
│    Stacktrace:
...

and my PR #56 resolves this. I'll see if I can turn this into a CI test