Skip to content

Example blocks should not crash the whole build on parse errors #2731

@asinghvi17

Description

@asinghvi17
for k in keys
    k !in acceptable_keys && do_something()
end

is an example of code that does not parse correctly. In an @example block

Warning: failed to parse exception in src/somefile.md
  exception = 
    ParseError:
    # Error @ none:16:15
        for (param, value) in params
    #             ┌──────────────────────────
            param !in default_keys && error(...)
    #────────────────────────────────────────────────────────────────────────┘ ── Expected `end`
ERROR: LoadError: AssertionError: Issue at #= somefile.md:109 =#:
Stacktrace:
  [1] parseblock(code::String, doc::Documenter.Document, file::String; skip::Int64, keywords::Bool, raise::Bool, linenumbernode::LineNumberNode)
    @ Documenter ~/.julia/packages/Documenter/iRt2s/src/utilities/utilities.jl:172
  [2] parseblock
    @ ~/.julia/packages/Documenter/iRt2s/src/utilities/utilities.jl:138 [inlined]
  [3] #parseblock#21
    @ ~/.julia/packages/Documenter/iRt2s/src/documents.jl:80 [inlined]
  [4] runner(::Type{Documenter.Expanders.ExampleBlocks}, node::MarkdownAST.Node{Nothing}, page::Documenter.Page, doc::Documenter.Document)
    @ Documenter ~/.julia/packages/Documenter/iRt2s/src/expander_pipeline.jl:851
  [5] dispatch(::Type{Documenter.Expanders.ExpanderPipeline}, ::MarkdownAST.Node{Nothing}, ::Vararg{Any})
    @ Documenter.Selectors ~/.julia/packages/Documenter/iRt2s/src/utilities/Selectors.jl:170
  [6] expand(doc::Documenter.Document)
    @ Documenter ~/.julia/packages/Documenter/iRt2s/src/expander_pipeline.jl:59
  [7] runner(::Type{Documenter.Builder.ExpandTemplates}, doc::Documenter.Document)
    @ Documenter ~/.julia/packages/Documenter/iRt2s/src/builder_pipeline.jl:224
  [8] dispatch(::Type{Documenter.Builder.DocumentPipeline}, x::Documenter.Document)
    @ Documenter.Selectors ~/.julia/packages/Documenter/iRt2s/src/utilities/Selectors.jl:170
  [9] #88
    @ ~/.julia/packages/Documenter/iRt2s/src/makedocs.jl:275 [inlined]
 [10] withenv(::Documenter.var"#88#90"{Documenter.Document}, ::Pair{String, Nothing}, ::Vararg{Pair{String, Nothing}})
    @ Base ./env.jl:265
 [11] #87
    @ ~/.julia/packages/Documenter/iRt2s/src/makedocs.jl:274 [inlined]
 [12] cd(f::Documenter.var"#87#89"{Documenter.Document}, dir::String)
    @ Base.Filesystem ./file.jl:112
 [13] makedocs(; debug::Bool, format::MarkdownVitepress, kwargs::@Kwargs{modules::Vector{Module}, authors::String, sitename::String, pages::Vector{Pair{String, Any}}, warnonly::Bool, clean::Bool})
    @ Documenter ~/.julia/packages/Documenter/iRt2s/src/makedocs.jl:273
 

Error: Process completed with exit code 1.

This should probably not completely crash? (Example is sanitized)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions