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
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.

```

# 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

@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
@fingolfin fingolfin merged commit 769c61d into master Nov 9, 2025
26 of 27 checks passed
@fingolfin fingolfin deleted the mh/clean-and-fix-old-tests branch November 9, 2025 23:17
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

3 participants