Skip to content

Conversation

@fingolfin
Copy link
Collaborator

@fingolfin fingolfin commented Nov 3, 2025

... so that we can run those tests with warnonly = false, at least in some specific Julia versions.

Resolves #2798.

@fingolfin fingolfin added the Skip Changelog Allows the CHANGELOG.md check to pass without edit to the file. label Nov 3, 2025
- [`ccall`](@ref)
- [`deepcopy`](@ref)
- [`while`](@ref)
- [`@time(x)`](@ref)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Explanation: ccall and @time docstrings reference other docstrings, and some of those have further ref's; that then leads to "missing reference" warnings, unless one pulls in all of those. So I replaced them with alternatives that (currently) don't reference anything in their docstrings

```jldoctest
julia> [1.0, 2.0, 3.0]
3-element Array{Float64,1}:
3-element Vector{Float64}:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adjust to changed output in... Julia 1.6 at least? Which is the minimum version supported by Documenter, so...

```jldoctest
julia> f(2)
ERROR: UndefVarError: f not defined
ERROR: UndefVarError: `f` not defined in `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.

This version of the message is shown in Julia >= 1.11; this is one of the reasons why we have warnonly = (VERSION.major == 1 && VERSION.minor <= 10) further above

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

```

# 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?

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

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

Comment on lines -486 to -491
# 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)

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

```@eval
"expanded_"*"eval"
import Markdown
Markdown.parse("expanded_"*"eval")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Without this we get a warning because @eval should return nothing or a Markdown.MD. We don't want that here. Instead there should be a dedicated test for this warning, see issue #2805

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Such a test is added in PR #2823


```@eval
rand(20, 20)
Markdown.MD("Hello")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Base.banner was moved to REPL.banner in Julia 1.11. But anyway, there seems no point in having a complex test here, is there?

end
@test length(inv(":jl:keyword:`for`")) == 1
if length(inv(":jl:keyword:`for`")) == 1
item = inv[":jl:keyword:`for`"]
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 had to replace for by while because in recent Julia versions, the for docstring as a @ref to outer.

@fingolfin
Copy link
Collaborator Author

@mortenpi I tried to explain the reasoning behind all changes in PR review comments.

But tests fail on Windows, any help would be appreciated:

===================== @quietly: output from the expression =====================
[ Info: SetupBuildDirectory: setting up build directory.
[ Info: Doctest: skipped.
[ Info: ExpandTemplates: expanding markdown templates.
┌ Warning: expandorder/AA.md in expandfirst does not exist
└ @ Documenter D:\a\Documenter.jl\Documenter.jl\src\expander_pipeline.jl:45
┌ Error: failed to run `@example` block in examples\src\expandorder\01.md:9-11
│ ```@example
│ isfile("AA.txt") || error("AA.txt missing")
│ ```
│   exception =
│    AA.txt missing
│    Stacktrace:
│      [1] error(s::String)
│        @ Base .\error.jl:44
│      [2] top-level scope
│        @ 01.md:10
│      [3] eval(m::Module, e::Any)
│        @ Core .\boot.jl:489
│      [4] #61
│        @ D:\a\Documenter.jl\Documenter.jl\src\expander_pipeline.jl:856 [inlined]
│      [5] cd(f::Documenter.var"#61#62"{Module, Expr}, dir::String)
│        @ Base.Filesystem .\file.jl:101

... so that we can run those tests with `warnonly = false`,
at least in some specific Julia versions.
@fingolfin fingolfin force-pushed the mh/clean-and-fix-old-tests branch 2 times, most recently from ed14185 to 4af527b Compare November 7, 2025 13:56
@fingolfin
Copy link
Collaborator Author

Ah of course it's right there in the error:

┌ Warning: expandorder/AA.md in expandfirst does not exist
└ @ Documenter D:\a\Documenter.jl\Documenter.jl\src\expander_pipeline.jl:45

My guess would be this is due to a different in path separators, combined with dumb string comparision on the paths. Indeed, the warning is produced here:

function expand(doc::Documenter.Document)
    priority_pages = filter(doc.user.expandfirst) do src
        if src in keys(doc.blueprint.pages)
            return true
        else
            @warn "$(src) in expandfirst does not exist"
            return false
        end
    end

I'll see if using joinpath will help.

But of course other kwargs for mkdocs such as pages use slashes in path just fine. Perhaps those arguments are processed somewhere, and the same processing should be applied to expandfirst ? Perhaps @mortenpi knows.

@fingolfin fingolfin force-pushed the mh/clean-and-fix-old-tests branch from f88baf9 to 2a0b103 Compare November 7, 2025 14:45
@fingolfin fingolfin added Type: Bugfix and removed Skip Changelog Allows the CHANGELOG.md check to pass without edit to the file. labels Nov 7, 2025

* 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)

@fingolfin fingolfin changed the title Adjust test outputs in test/examples to avoid warnings Adjust test outputs in test/examples to avoid warnings; fix bug in expandfirst handling on Windows Nov 7, 2025
@fingolfin fingolfin force-pushed the mh/clean-and-fix-old-tests branch from 1005449 to 80f2540 Compare November 7, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hidden warnings / errors (?) due to @quietly

2 participants