Skip to content

Commit 445275f

Browse files
aaruni96fingolfin
andauthored
Report file names in which "Unexpected Julia interpolation" occurred (#2793)
Co-authored-by: Max Horn <[email protected]>
1 parent f634965 commit 445275f

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
* Page category is removed from the search index and now everything is in section category. ([#2762], [#2413])
1717
* Changed the docstring block accordions from a custom implementation to HTML details+summary tag. ([#2772], [#2773])
1818
* Improved the search tokenizer and custom trimmer to improve search results. ([#1457], [#2114], [#2744])
19-
* Improved several warning/error messages to (more accurately) report the location (filename, line range) in which the warning/error originated. ([#2426], [#2803], [#2809])
19+
* 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])
2020

2121
### Fixed
2222

@@ -2178,6 +2178,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
21782178
[#2748]: https://github.com/JuliaDocs/Documenter.jl/issues/2748
21792179
[#2750]: https://github.com/JuliaDocs/Documenter.jl/issues/2750
21802180
[#2751]: https://github.com/JuliaDocs/Documenter.jl/issues/2751
2181+
[#2752]: https://github.com/JuliaDocs/Documenter.jl/issues/2752
21812182
[#2753]: https://github.com/JuliaDocs/Documenter.jl/issues/2753
21822183
[#2761]: https://github.com/JuliaDocs/Documenter.jl/issues/2761
21832184
[#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
21862187
[#2774]: https://github.com/JuliaDocs/Documenter.jl/issues/2774
21872188
[#2787]: https://github.com/JuliaDocs/Documenter.jl/issues/2787
21882189
[#2792]: https://github.com/JuliaDocs/Documenter.jl/issues/2792
2190+
[#2793]: https://github.com/JuliaDocs/Documenter.jl/issues/2793
21892191
[#2803]: https://github.com/JuliaDocs/Documenter.jl/issues/2803
21902192
[#2809]: https://github.com/JuliaDocs/Documenter.jl/issues/2809
21912193
[#2812]: https://github.com/JuliaDocs/Documenter.jl/issues/2812

src/html/HTMLWriter.jl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ using SHA: SHA
7373
using CodecZlib: ZlibCompressorStream
7474
using ANSIColoredPrinters: ANSIColoredPrinters
7575

76-
using ..Documenter: Documenter, Default, Remotes
76+
using ..Documenter: Documenter, Default, Remotes, locrepr
7777
using ...JSDependencies: JSDependencies
7878
using ...DOM: DOM, @tags
7979
using ...MDFlatten: mdflatten
@@ -711,8 +711,9 @@ end
711711

712712
function Documenter.locrepr(dctx::DCtx, lines = nothing)
713713
doc = dctx.ctx.doc
714-
page = dctx.navnode.page
715-
return Documenter.locrepr(dctx.ctx.doc, dctx.ctx.page, lines)
714+
src = dctx.navnode.page
715+
page = doc.blueprint.pages[src]
716+
return Documenter.locrepr(doc, page, lines)
716717
end
717718

718719
function SearchRecord(ctx::HTMLContext, navnode; fragment = "", title = nothing, category = "page", text = "")
@@ -2443,17 +2444,17 @@ function domify(dctx::DCtx, node::Node, t::MarkdownAST.Table)
24432444
end
24442445

24452446
function domify(dctx::DCtx, ::Node, e::MarkdownAST.JuliaValue)
2446-
message = """
2447-
Unexpected Julia interpolation in the Markdown. This probably means that you have an
2448-
unbalanced or un-escaped \$ in the text.
2447+
message =
2448+
"""
2449+
Unexpected Julia interpolation in the Markdown. This probably means that you have an
2450+
unbalanced or un-escaped \$ in the text.
24492451
2450-
To write the dollar sign, escape it with `\\\$`
2452+
To write the dollar sign, escape it with `\\\$`
24512453
2452-
We don't have the file or line number available, but we got given the value:
2454+
This is in file $(locrepr(dctx)), and we were given the value:
24532455
2454-
`$(e.ref)` which is of type `$(typeof(e.ref))`
2456+
`$(e.ref)` which is of type `$(typeof(e.ref))`
24552457
"""
2456-
24572458
if dctx.ctx.doc.user.treat_markdown_warnings_as_error
24582459
error(message)
24592460
else

src/latex/LaTeXWriter.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -850,13 +850,14 @@ latex(io::Context, node::Node, ::Documenter.MetaNode) = _println(io, "\n")
850850
latex(io::Context, node::Node, ::Documenter.SetupNode) = nothing
851851

852852
function latex(io::Context, node::Node, value::MarkdownAST.JuliaValue)
853-
message = """
854-
Unexpected Julia interpolation in the Markdown. This probably means that you have an unbalanced
855-
or un-escaped \$ in the text.
853+
message =
854+
"""
855+
Unexpected Julia interpolation in the Markdown. This probably means that you have an
856+
unbalanced or un-escaped \$ in the text.
856857
857858
To write the dollar sign, escape it with `\\\$`
858859
859-
We don't have the file or line number available, but we got given the value:
860+
This is in file $(io.filename), and we were given the value:
860861
861862
`$(value.ref)` which is of type `$(typeof(value.ref))`
862863
"""

test/warnings/make.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,23 @@ julia> WarningTests.run_warnings_test("dollar")
7575
[ Info: Populate: populating indices.
7676
[ Info: RenderDocument: rendering document.
7777
[ Info: HTMLWriter: rendering HTML pages.
78-
┌ Warning: Unexpected Julia interpolation in the Markdown. This probably means that you have an
79-
unbalanced or un-escaped $ in the text.
78+
┌ Warning: Unexpected Julia interpolation in the Markdown. This probably means that you have an
79+
│ unbalanced or un-escaped $ in the text.
8080
81-
To write the dollar sign, escape it with `\$`
81+
│ To write the dollar sign, escape it with `\$`
8282
83-
We don't have the file or line number available, but we got given the value:
83+
This is in file src/dollar.md, and we were given the value:
8484
85-
`foo` which is of type `Symbol`
85+
│ `foo` which is of type `Symbol`
8686
└ @ Documenter
87-
┌ Warning: Unexpected Julia interpolation in the Markdown. This probably means that you have an
88-
unbalanced or un-escaped $ in the text.
87+
┌ Warning: Unexpected Julia interpolation in the Markdown. This probably means that you have an
88+
│ unbalanced or un-escaped $ in the text.
8989
90-
To write the dollar sign, escape it with `\$`
90+
│ To write the dollar sign, escape it with `\$`
9191
92-
We don't have the file or line number available, but we got given the value:
92+
This is in file src/dollar.md, and we were given the value:
9393
94-
`[1 2 3; 4 5 6]` which is of type `Expr`
94+
│ `[1 2 3; 4 5 6]` which is of type `Expr`
9595
└ @ Documenter
9696
```
9797
"""

0 commit comments

Comments
 (0)