diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e736ca4b5..1e8e6ca6cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Page category is removed from the search index and now everything is in section category. ([#2762], [#2413]) * Changed the docstring block accordions from a custom implementation to HTML details+summary tag. ([#2772], [#2773]) * Improved the search tokenizer and custom trimmer to improve search results. ([#1457], [#2114], [#2744]) -* Improved several warning/error messages to (more accurately) report the location (filename, line range) in which the warning/error originated. ([#2426], [#2803], [#2809]) +* Improved several warning/error messages to (more accurately) report the location (filename, line range) in which the warning/error originated. ([#2426], [#2752], [#2793], [#2803], [#2809]) ### Fixed @@ -2178,6 +2178,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#2748]: https://github.com/JuliaDocs/Documenter.jl/issues/2748 [#2750]: https://github.com/JuliaDocs/Documenter.jl/issues/2750 [#2751]: https://github.com/JuliaDocs/Documenter.jl/issues/2751 +[#2752]: https://github.com/JuliaDocs/Documenter.jl/issues/2752 [#2753]: https://github.com/JuliaDocs/Documenter.jl/issues/2753 [#2761]: https://github.com/JuliaDocs/Documenter.jl/issues/2761 [#2762]: https://github.com/JuliaDocs/Documenter.jl/issues/2762 @@ -2186,6 +2187,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#2774]: https://github.com/JuliaDocs/Documenter.jl/issues/2774 [#2787]: https://github.com/JuliaDocs/Documenter.jl/issues/2787 [#2792]: https://github.com/JuliaDocs/Documenter.jl/issues/2792 +[#2793]: https://github.com/JuliaDocs/Documenter.jl/issues/2793 [#2803]: https://github.com/JuliaDocs/Documenter.jl/issues/2803 [#2809]: https://github.com/JuliaDocs/Documenter.jl/issues/2809 [#2812]: https://github.com/JuliaDocs/Documenter.jl/issues/2812 diff --git a/src/html/HTMLWriter.jl b/src/html/HTMLWriter.jl index 6868a874c3..544235fdd3 100644 --- a/src/html/HTMLWriter.jl +++ b/src/html/HTMLWriter.jl @@ -73,7 +73,7 @@ using SHA: SHA using CodecZlib: ZlibCompressorStream using ANSIColoredPrinters: ANSIColoredPrinters -using ..Documenter: Documenter, Default, Remotes +using ..Documenter: Documenter, Default, Remotes, locrepr using ...JSDependencies: JSDependencies using ...DOM: DOM, @tags using ...MDFlatten: mdflatten @@ -711,8 +711,9 @@ end function Documenter.locrepr(dctx::DCtx, lines = nothing) doc = dctx.ctx.doc - page = dctx.navnode.page - return Documenter.locrepr(dctx.ctx.doc, dctx.ctx.page, lines) + src = dctx.navnode.page + page = doc.blueprint.pages[src] + return Documenter.locrepr(doc, page, lines) end function SearchRecord(ctx::HTMLContext, navnode; fragment = "", title = nothing, category = "page", text = "") @@ -2443,17 +2444,17 @@ function domify(dctx::DCtx, node::Node, t::MarkdownAST.Table) end function domify(dctx::DCtx, ::Node, e::MarkdownAST.JuliaValue) - message = """ - Unexpected Julia interpolation in the Markdown. This probably means that you have an - unbalanced or un-escaped \$ in the text. + message = + """ + Unexpected Julia interpolation in the Markdown. This probably means that you have an + unbalanced or un-escaped \$ in the text. - To write the dollar sign, escape it with `\\\$` + To write the dollar sign, escape it with `\\\$` - We don't have the file or line number available, but we got given the value: + This is in file $(locrepr(dctx)), and we were given the value: - `$(e.ref)` which is of type `$(typeof(e.ref))` + `$(e.ref)` which is of type `$(typeof(e.ref))` """ - if dctx.ctx.doc.user.treat_markdown_warnings_as_error error(message) else diff --git a/src/latex/LaTeXWriter.jl b/src/latex/LaTeXWriter.jl index 663b42f932..e75f61da56 100644 --- a/src/latex/LaTeXWriter.jl +++ b/src/latex/LaTeXWriter.jl @@ -850,13 +850,14 @@ latex(io::Context, node::Node, ::Documenter.MetaNode) = _println(io, "\n") latex(io::Context, node::Node, ::Documenter.SetupNode) = nothing function latex(io::Context, node::Node, value::MarkdownAST.JuliaValue) - message = """ - Unexpected Julia interpolation in the Markdown. This probably means that you have an unbalanced - or un-escaped \$ in the text. + message = + """ + Unexpected Julia interpolation in the Markdown. This probably means that you have an + unbalanced or un-escaped \$ in the text. To write the dollar sign, escape it with `\\\$` - We don't have the file or line number available, but we got given the value: + This is in file $(io.filename), and we were given the value: `$(value.ref)` which is of type `$(typeof(value.ref))` """ diff --git a/test/warnings/make.jl b/test/warnings/make.jl index 526202d7aa..e48d14b1d8 100644 --- a/test/warnings/make.jl +++ b/test/warnings/make.jl @@ -75,23 +75,23 @@ julia> WarningTests.run_warnings_test("dollar") [ Info: Populate: populating indices. [ Info: RenderDocument: rendering document. [ Info: HTMLWriter: rendering HTML pages. -┌ Warning: Unexpected Julia interpolation in the Markdown. This probably means that you have an -│ unbalanced or un-escaped $ in the text. +┌ Warning: Unexpected Julia interpolation in the Markdown. This probably means that you have an +│ unbalanced or un-escaped $ in the text. │ -│ To write the dollar sign, escape it with `\$` +│ To write the dollar sign, escape it with `\$` │ -│ We don't have the file or line number available, but we got given the value: +│ This is in file src/dollar.md, and we were given the value: │ -│ `foo` which is of type `Symbol` +│ `foo` which is of type `Symbol` └ @ Documenter -┌ Warning: Unexpected Julia interpolation in the Markdown. This probably means that you have an -│ unbalanced or un-escaped $ in the text. +┌ Warning: Unexpected Julia interpolation in the Markdown. This probably means that you have an +│ unbalanced or un-escaped $ in the text. │ -│ To write the dollar sign, escape it with `\$` +│ To write the dollar sign, escape it with `\$` │ -│ We don't have the file or line number available, but we got given the value: +│ This is in file src/dollar.md, and we were given the value: │ -│ `[1 2 3; 4 5 6]` which is of type `Expr` +│ `[1 2 3; 4 5 6]` which is of type `Expr` └ @ Documenter ``` """