fredrikekre / Literate.jl

Simple package for literate programming in Julia
https://fredrikekre.github.io/Literate.jl
Other
548 stars 65 forks source link

[Bug] @__BINDER_ROOT_URL__ = <unknown> throws an error locally #250

Open JakobAsslaender opened 2 months ago

JakobAsslaender commented 2 months ago

Hi,

as of lately, I get an error when running Literate + Documenter locally. The macro @__BINDER_ROOT_URL__ is iterpreted as <unknown>, which seems to throw an error in the latest Documenter. As a MWE, I can just run the Literate.jl documentation locally:

Literate.jl % julia --project=docs docs/make.jl 
[ Info: generating markdown page from `~/Desktop/Literate.jl/examples/example.jl`
[ Info: writing result to `~/Desktop/Literate.jl/docs/src/generated/example.md`
[ Info: generating notebook from `~/Desktop/Literate.jl/examples/example.jl`
[ Info: executing notebook `example.ipynb`
[ Info: writing result to `~/Desktop/Literate.jl/docs/src/generated/example.ipynb`
[ Info: generating plain script file from `~/Desktop/Literate.jl/examples/example.jl`
[ Info: writing result to `~/Desktop/Literate.jl/docs/src/generated/example.jl`
[ Info: generating markdown page from `~/Desktop/Literate.jl/docs/src/outputformats.jl`
[ Info: writing result to `~/Desktop/Literate.jl/docs/src/generated/name.md`
[ Info: generating notebook from `~/Desktop/Literate.jl/docs/src/outputformats.jl`
[ Info: executing notebook `notebook.ipynb`
[ Info: writing result to `~/Desktop/Literate.jl/docs/src/generated/notebook.ipynb`
[ Info: generating plain script file from `~/Desktop/Literate.jl/docs/src/outputformats.jl`
[ Info: writing result to `~/Desktop/Literate.jl/docs/src/generated/outputformats.jl`
[ Info: SetupBuildDirectory: setting up build directory.
[ Info: Doctest: running doctests.
[ Info: ExpandTemplates: expanding markdown templates.
[ Info: CrossReferences: building cross-references.
┌ Error: invalid local link/image: file does not exist in src/generated/example.md
│   link =
│    @ast MarkdownAST.Link("<unknown>/generated/example.ipynb", "") do
│      MarkdownAST.Image("https://mybinder.org/badge_logo.svg", "") do
│        MarkdownAST.Text("")
│      end
│    end
│    
└ @ Documenter ~/.julia/packages/Documenter/qoyeC/src/utilities/utilities.jl:44
┌ Error: invalid local link/image: file does not exist in src/generated/example.md
│   link =
│    @ast MarkdownAST.Link("<unknown>/generated/example.ipynb", "") do
│      MarkdownAST.Image("https://img.shields.io/badge/show-nbviewer-579ACA.svg", "") do
│        MarkdownAST.Text("")
│      end
│    end
│    
└ @ Documenter ~/.julia/packages/Documenter/qoyeC/src/utilities/utilities.jl:44
┌ Error: invalid local link/image: file does not exist in src/generated/example.md
│   link =
│    @ast MarkdownAST.Link("<unknown>/examples/example.jl", "") do
│      MarkdownAST.Code("example.jl")
│    end
│    
└ @ Documenter ~/.julia/packages/Documenter/qoyeC/src/utilities/utilities.jl:44
┌ Error: invalid local link/image: file does not exist in src/generated/example.md
│   link =
│    @ast MarkdownAST.Link("<unknown>/generated/example.ipynb", "") do
│      MarkdownAST.Code("example.ipynb")
│    end
│    
└ @ Documenter ~/.julia/packages/Documenter/qoyeC/src/utilities/utilities.jl:44
┌ Error: invalid local link/image: file does not exist in src/generated/example.md
│   link =
│    @ast MarkdownAST.Link("<unknown>/generated/example.ipynb", "") do
│      MarkdownAST.Code("example.ipynb")
│    end
│    
└ @ Documenter ~/.julia/packages/Documenter/qoyeC/src/utilities/utilities.jl:44
┌ Error: invalid local link/image: file does not exist in src/generated/example.md
│   link =
│    @ast MarkdownAST.Link("<unknown>/examples/example.jl", "") do
│      MarkdownAST.Text("source file")
│    end
│    
└ @ Documenter ~/.julia/packages/Documenter/qoyeC/src/utilities/utilities.jl:44

When I set the binder URL to an actual URL: Literate.markdown(file_path, OUTPUT; binder_root_url="https://mybinder.org/v2/gh/") things work. But of course, it would be great if, locally, a dummy URL could be inserted that does not throw an error, while being able to use the automated insertion on GitHub.

Would it maybe be a fix to replace <unknown> with a URL in this line? https://github.com/fredrikekre/Literate.jl/blob/5c9beaa7f56bf3fe6d75a053799c73b0caec94ce/src/Literate.jl#L219-L220

Thanks for looking into this!

fredrikekre commented 1 month ago

You can disable cross reference checking when building locally with this kwarg

warnonly = is_ci ? false : [:cross_references]

to makedocs