Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

* Modules for `@example` environments are now generated by `eval`'ing an expression, rather than invoking the `Module` constructor, which is not recommended. (#2683)
* Modules for `@example` environments are now generated by `eval`'ing an expression, rather than invoking the `Module` constructor, which is not recommended. ([#2683])
* Fix handling of `expandfirst` entries containing slashes as path separators on Windows. ([#2804])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this uncovered a genuine bug in expandfirst handling on Windows, yay. I've thus added a changelog entry. (And fixed the link in the entry above)

* Changed the header crossref step to eagerly fail when encountering a non-unique header slug. ([#2668], [#2787])

This is **potentially breaking** and may cause some documentation builds to fail.
Expand Down Expand Up @@ -2189,6 +2190,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#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
[#2804]: https://github.com/JuliaDocs/Documenter.jl/issues/2804
[#2809]: https://github.com/JuliaDocs/Documenter.jl/issues/2809
[#2812]: https://github.com/JuliaDocs/Documenter.jl/issues/2812
[#2813]: https://github.com/JuliaDocs/Documenter.jl/issues/2813
Expand Down
3 changes: 2 additions & 1 deletion src/expander_pipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ function clear_modules!(d::Dict{Symbol, Any})
end

function expand(doc::Documenter.Document)
priority_pages = filter(doc.user.expandfirst) do src
expandfirst = map(normpath, doc.user.expandfirst)
priority_pages = filter(expandfirst) do src
if src in keys(doc.blueprint.pages)
return true
else
Expand Down
4 changes: 2 additions & 2 deletions test/doctests/doctests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ end
@test is_same_as_file(output, rfile(8))
end

# Here we try the default (strict = false) -- output should say that doctest failed, but
# success should still be true.
# Here we try the former default (strict = false, now warnonly = true) --
# output should say that doctest failed, but success should still be true.
run_makedocs(["working.md"]; warnonly = true) do result, success, backtrace, output
@test success
@test is_same_as_file(output, rfile(11))
Expand Down
2 changes: 1 addition & 1 deletion test/examples/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function html_doc(
build_directory, mathengine;
htmlkwargs = (;),
image_assets = ("images/logo.png", "images/logo.jpg", "images/logo.gif"),
warnonly = true,
warnonly = (VERSION.major == 1 && VERSION.minor <= 10),
kwargs...
)
return @quietly withassets(image_assets...) do
Expand Down
4 changes: 2 additions & 2 deletions test/examples/pages/a.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Links:
- [`ccall`](@ref)
- [`deepcopy`](@ref)
- [`while`](@ref)
- [`@time(x)`](@ref)
- [`@eval(x)`](@ref)
- [`T(x)`](@ref)
- [`T(x, y)`](@ref)
- [`f(::Integer)`](@ref)
Expand Down
4 changes: 2 additions & 2 deletions test/examples/pages/b.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

Links:

- [`ccall`](@ref)
- [`deepcopy`](@ref)
- [`while`](@ref)
- [`@time`](@ref)
- [`@eval`](@ref)
- [`T`](@ref)
- [`f`](@ref)
- [`f(::Any)`](@ref)
Expand Down
4 changes: 2 additions & 2 deletions test/examples/pages/c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

Links:

- [`ccall`](@ref)
- [`deepcopy`](@ref)
- [`while`](@ref)
- [`@time`](@ref)
- [`@eval`](@ref)
- [`T`](@ref)
- [`f`](@ref)
- [`f(::Any)`](@ref)
Expand Down
12 changes: 6 additions & 6 deletions test/examples/pages/d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

Links:

- [`ccall`](@ref)
- [`deepcopy`](@ref)
- [`while`](@ref)
- [`@time`](@ref)
- [`@eval`](@ref)
- [`T`](@ref)
- [`f`](@ref)
- [`f(x)`](@ref)
Expand All @@ -21,9 +21,9 @@ mutable struct T end

Links:

- [`ccall`](@ref)
- [`deepcopy`](@ref)
- [`while`](@ref)
- [`@time`](@ref)
- [`@eval`](@ref)
- [`T(x)`](@ref)
- [`T(x, y)`](@ref)
- [`T(x, y, z)`](@ref)
Expand All @@ -40,9 +40,9 @@ T(x) = T()

Links:

- [`ccall`](@ref)
- [`deepcopy`](@ref)
- [`while`](@ref)
- [`@time`](@ref)
- [`@eval`](@ref)
- [`T()`](@ref)
- [`T(x)`](@ref)
- [`T(x, y)`](@ref)
Expand Down
52 changes: 30 additions & 22 deletions test/examples/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Pages = ["man/tutorial.md"]
```@index
```

### Embedded `@ref` links headers: [`ccall`](@ref)
### Embedded `@ref` links headers: [`deepcopy`](@ref)

[#60](@ref) [#61](@ref)

Expand All @@ -45,7 +45,7 @@ end

```jldoctest
julia> [1.0, 2.0, 3.0]
3-element Array{Float64,1}:
3-element Vector{Float64}:
1.0
2.0
3.0
Expand Down Expand Up @@ -199,7 +199,7 @@ julia> g(2)
```
```jldoctest
julia> f(2)
ERROR: UndefVarError: f not defined
ERROR: UndefVarError: `f` not defined in `Main`
```

```jldoctest PR650; setup = :(f(x) = x^2; g(x) = x)
Expand Down Expand Up @@ -264,7 +264,7 @@ julia> t = T()
T()

julia> fullname(@__MODULE__)
(:Main,)
(:Main, :Main)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure how this was ever correct... I mean, yeah, ideally it would print (:Main,) because that's what is printed in Main. But we are in a sandbox module, and we are replacing the module name in output by Main, so I think this is kinda the best we can hope for?

C.f.:

julia> fullname(@__MODULE__)
(:Main,)

julia> module Foo println(fullname(@__MODULE__)) end
(:Main, :Foo)
Main.Foo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to fix some of these things up though. I wonder if this regressed at some point..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly but I see nothing in the code that would fix this.

Anyway, if this ever worked (and I am not convinced it did, but I am also too lazy to try to reconstruct the exact setup from when this test was added), then it must have been quite some time ago. That's part of the problem this PR was meant to fix: the tests in there did not actually act as tests because except for the gravest kinds of failures (crashes, hard exceptions) any regressions were ignored :-(.

I think the current behavior is OK -- if someone really wants to print the fullname of a module, and this causes a problem, they can file an issue and we can worry about the possibility of a fix then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, agreed.


julia> fullname(Base.Broadcast)
(:Base, :Broadcast)
Expand All @@ -273,7 +273,7 @@ julia> @__MODULE__
Main
```

# Issue398
# Issue #398
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's just for consistency (I am also tempted to sort these sections by issue number... or maybe each issue test should be in a file of its own?


```@meta
DocTestSetup = quote
Expand Down Expand Up @@ -309,7 +309,7 @@ abcd
DocTestSetup = nothing
```

# Issue653
# Issue #653

```jldoctest
julia> struct MyException <: Exception
Expand All @@ -331,16 +331,19 @@ julia> throw(MyException("test exception"))
ERROR: MyException: test exception
```

# Issue418
# Issue #418

```jldoctest
julia> f(x::Float64) = x
f (generic function with 1 method)

julia> f("")
ERROR: MethodError: no method matching f(::String)
The function `f` exists, but no method is defined for this combination of argument types.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is new in Julia 1.11


Closest candidates are:
f(!Matched::Float64) at none:1
f(!Matched::Float64)
@ Main none:1
```


Expand Down Expand Up @@ -374,6 +377,7 @@ a = 1
```

# Issue #793

```jldoctest
julia> write("issue793.jl", "\"Hello!\"");

Expand Down Expand Up @@ -424,7 +428,7 @@ x
@assert x == 1148
```

# Issue513
# Issue #513

```jldoctest named
julia> a = 1
Expand All @@ -434,19 +438,24 @@ julia> ans
1
```

# Filtering of `Main.`
# Filtering of `Main.` PR #574

We filter the string `Main.` in outputs to make the outputs
look more like they would in the REPL.

```jldoctest
julia> struct Point end;

julia> println(Point)
Point

julia> import Base: sqrt
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary to make this test pass in Julia >= 1.12


julia> sqrt(100)
10.0

julia> sqrt = 4
ERROR: cannot assign variable Base.sqrt from module Main
ERROR: cannot assign a value to imported variable Base.sqrt from module Main
```

```jldoctest
Expand All @@ -463,9 +472,14 @@ julia> g(2, 3.0)
8.0

julia> g(2.0, 3.0)
ERROR: MethodError: g(::Float64, ::Float64) is ambiguous. Candidates:
g(x, y::Float64) in Main at none:1
g(x::Float64, y) in Main at none:1
ERROR: MethodError: g(::Float64, ::Float64) is ambiguous.

Candidates:
g(x, y::Float64)
@ Main none:1
g(x::Float64, y)
@ Main none:1

Possible fix, define
g(::Float64, ::Float64)
```
Expand All @@ -483,12 +497,6 @@ julia> x->x # ignore error on 0.7
r = :a
```

# Bad links (Windows)

* [Colons not allowed on Windows -- `some:path`](some:path)
* [No "drive" -- `:path`](:path)
* [Absolute Windows paths -- `X:\some\path`](X:\some\path)

Comment on lines -486 to -491
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test caused a bunch of warnings. And it is unclear to me what it even is supposed to test. It was added in 80721fd from PR #485.

My best guess is in commit 80721fd which was part of PR #485 before squashing. It introduces a function fixlinks! which has some Windows specific code:

    if is_windows() && ':' in img.url
        Utilities.warn("Invalid local image: colons not allowed in paths on Windows\n    '$(img.url)' in $(get(navnode.page))")
        return
    end

That function is long gone, but a descendant of the code lives on in local_links!:

    elseif Sys.iswindows() && ':' in path
        @docerror(
            doc, :cross_references,
            "invalid local link/image: colons not allowed in paths on Windows in $(Documenter.locrepr(page.source))",
            link = node
        )
        return
    end

So perhaps this line is about getting coverage for that @docerror

But despite this, I think it is the right move to remove this here: because right now, the test results in "fake coverage": we wouldn't notice if the test for colons was broken because we ignore the output via @quietly and even if we didn't, a failure here would most likely not trigger a CI failure.

So instead, we need a new test which triggers this and then specifically watches out for the result, and checks that it shows a warning/error with the appropriate message. (And that should probably be three tests, one for each instance).

As I mentioned elsewhere, I'd like such a setup also for testing the quality of the locrepr output, i.e. to ensure it shows the "right" file paths.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See PR #2822

# Rendering text/markdown

```@example
Expand All @@ -505,13 +513,13 @@ MarkdownOnly("""
# Empty heading
##

# Issue 1392
# Issue #1392

```1392-test-language 1392-extra-info
julia> function foo end;
```

# Issue 890
# Issue #890

I will pay \$1 if $x^2$ is displayed correctly. People may also write \$s or
even money bag\$\$.
Expand Down
3 changes: 2 additions & 1 deletion test/examples/src/issue491.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Tests that code-like blocks are expanded in nested Markdown contexts.
Test the different types of code-like blocks:

```@eval
"expanded_"*"eval"
import Markdown
Markdown.parse("expanded_"*"eval")
```

```@example
Expand Down
20 changes: 11 additions & 9 deletions test/examples/src/lib/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ Pages = ["lib/functions.md"]

# Functions

[`ccall`](@ref), [`func(x)`](@ref), [`T`](@ref), [`for`](@ref), and [`while`](@ref).
[`deepcopy`](@ref), [`func(x)`](@ref), [`T`](@ref), [`@eval`](@ref), and [`while`](@ref).

```@docs
func(x)
T
ccall
for
deepcopy
while
@time
@eval
@assert
AssertionError
```

```@docs; canonical=false
func(x)
T
ccall
for
deepcopy
while
@time
@eval
@assert
AssertionError
```

# Foo
Expand Down Expand Up @@ -212,9 +212,11 @@ Pages = ["c.jl", "d.jl"]

A footnote reference [^footnote].

[^footnote]: the footnote text

# Named docstring `@ref`s

* a normal docstring `@ref` link: [`AutoDocs.Pages.f`](@ref);
* a named docstring `@ref` link: [`f`](@ref AutoDocs.Pages.f);
* and a link with custom text: [`@time 1 + 2`](@ref @time);
* some invalid syntax: [`for i = 1:10; ...`](@ref for).
* and a link with custom text: [`@eval 1 + 2`](@ref @eval);
* some invalid syntax: [`while i < 10; ...`](@ref while).
7 changes: 1 addition & 6 deletions test/examples/src/man/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,7 @@ julia> a / b

```@eval
import Markdown
code = string(sprint(Base.banner), "julia>")
Markdown.MD([Markdown.Code(code)])
```

```@eval
rand(20, 20)
Markdown.MD("Hello")
```

```jldoctest
Expand Down
10 changes: 5 additions & 5 deletions test/examples/tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,15 @@ end
@test item.priority == 1
@test DocInventories.uri(item) == "lib/functions/#Main.AutoDocs.K"
end
@test length(inv(":jl:keyword:`for`")) == 1
if length(inv(":jl:keyword:`for`")) == 1
item = inv[":jl:keyword:`for`"]
@test length(inv(":jl:keyword:`while`")) == 1
if length(inv(":jl:keyword:`while`")) == 1
item = inv[":jl:keyword:`while`"]
@test item.domain == "jl"
@test item.role == "keyword"
@test item.name == "for"
@test item.name == "while"
@test item.uri == "lib/functions/#\$"
@test item.priority == 1
@test DocInventories.uri(item) == "lib/functions/#for"
@test DocInventories.uri(item) == "lib/functions/#while"
end
@test length(inv("Documenter.hide")) == 1
if length(inv("Documenter.hide")) == 1
Expand Down
Loading