Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docerror! to fix #1756 #1776

Merged
merged 24 commits into from
Mar 18, 2022
Merged

docerror! to fix #1756 #1776

merged 24 commits into from
Mar 18, 2022

Conversation

st--
Copy link
Contributor

@st-- st-- commented Mar 11, 2022

Resolves #1756: With strict=true, Documenter errors when encountering any issue (based on checking doc.internal.errors in Selectors.runner in src/Builder.jl), but it doesn't actually say "Error" - only "Warning" - on the issue itself, which makes it non-intuitive to figure out what's going on (e.g. search log for error).

The reason for this is that on any issue, a tag is appended to the doc.internal.errors array, e.g.

push!(doc.internal.errors, :cross_references)

but in most places, it explicitly just prints a warning, e.g. in src/CrossReferences.jl:

@warn "'$slug' is not unique in $(Utilities.locrepr(page.source))."

In src/DocChecks.jl, there was already a loglevel() function that based on the strictness settings returns Logging.Error or Logging.Warn, so the log message of those checks was already correct.

In this PR, I combined the push! to doc.internal.errors & the appropriate logging message in a new function docerror!, and changed the other files to use this function as well.

@st-- st-- marked this pull request as ready for review March 11, 2022 12:01
@fredrikekre
Copy link
Member

A disadvantage with this strategy is that we lose source information (all log messages will look like they come from this new function).

@st--
Copy link
Contributor Author

st-- commented Mar 15, 2022

A disadvantage with this strategy is that we lose source information (all log messages will look like they come from this new function).

Ah, that's unfortunate. Could we fix it by turning it into a @docerror macro?

@fredrikekre
Copy link
Member

Yea, but maybe it is easier to keep the

@logmsg loglevel(...) "message"

pattern as was already there in some places?

@st--
Copy link
Contributor Author

st-- commented Mar 15, 2022

I thought it was helpful to directly couple the push! to doc.internal.errors with the message, as this removes a lot of duplicated code (it also ensures that the tag is the same in push! and loglevel())

@st--
Copy link
Contributor Author

st-- commented Mar 15, 2022

How about

macro docerror(doc, tag, msg, exs...)
    quote
        let
            push!($(doc).internal.errors, $(tag))
            if is_strict($(doc).user.strict, $(tag))
                @error $(msg) $(exs...)
            else
                @warn $(msg) $(exs...)
            end
        end
    end
end

and then instead of

push!(doc.internal.errors, :cross_references)
@logmsg is_strict(doc.user.strict, :cross_references) "<long message>"

can simply write

@docerror doc :cross_references "<long message>"

@fredrikekre
Copy link
Member

Sure, if that works!

@st--
Copy link
Contributor Author

st-- commented Mar 16, 2022

I think it does (I started converting it over); could you turn on the workflow for me ?

@st--
Copy link
Contributor Author

st-- commented Mar 16, 2022

it should all be ready for CI now

test/utilities.jl Outdated Show resolved Hide resolved
test/utilities.jl Outdated Show resolved Hide resolved
@st--
Copy link
Contributor Author

st-- commented Mar 17, 2022

Phew, now all the tests are passing (except for codecov/patch, but I don't think there's an easy way of fixing that, so I hope it's acceptable as is) :)

@fredrikekre
Copy link
Member

Great, can you add a note in CHANGELOG.md? Just mention that the issue is fixed.

@st--
Copy link
Contributor Author

st-- commented Mar 17, 2022

done!

@fredrikekre
Copy link
Member

Code coverage dropped to 50% from 85%. Looks like every function that uses your new macro is marked as missed, so probably something is strange here...

@st--
Copy link
Contributor Author

st-- commented Mar 18, 2022

Code coverage dropped to 50% from 85%. Looks like every function that uses your new macro is marked as missed, so probably something is strange here...

That seems like a build issue, not an issue with my code - if you look at previous builds, e.g. codecov/project on e0dab4c, it says 86.91% (+0.17%). And a lot of the now missed lines have nothing to do with my changes.

Could you re-run the build ? GitHub has been having some issues as of yesterday. Maybe that's why it didn't properly get counted by codecov. (I've seen some issues with codecov just randomly claiming massively dropped coverage before.)

@fredrikekre fredrikekre reopened this Mar 18, 2022
@fredrikekre
Copy link
Member

Ok, that seems to have worked. Strange.

@fredrikekre fredrikekre merged commit bffc866 into JuliaDocs:master Mar 18, 2022
@st-- st-- deleted the st/fix_loglevel branch March 21, 2022 07:37
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.

strict=true fails to change loglevel from Warning to Error
3 participants