Skip to content

Commit

Permalink
Accept plugins argument for doctest
Browse files Browse the repository at this point in the history
Forward keyword arguments from `doctest` to `makedocs`. This
includes the `plugins` keyword argument, but potentially other keyword
arguments as well.
  • Loading branch information
goerz committed Sep 10, 2023
1 parent 41ddf34 commit efc2500
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* The search UI has had a complete overhaul, with a fresh new modal UI with better context for search results and a filter mechanism to remove unwanted results. The client-side search engine has been changed from LunrJs to MinisearchJs. ([#1437], [#2141], [#2147], [#2202])

* The `doctest` routine can now internally forward select additional keyword arguments to `makedocs`. Specifically, this includes the `plugins` argument, enabling `doctest` to run if any plugin with a mandatory `Plugin` object is loaded, e.g., [DocumenterCitations](https://github.com/JuliaDocs/DocumenterCitations.jl). ([#2245])

### Fixed

* Line endings in Markdown source files are now normalized to `LF` before parsing, to work around [a bug in the Julia Markdown parser][julia-29344] where parsing is sensitive to line endings, and can therefore cause platform-dependent behavior. ([#1906])
Expand Down
11 changes: 10 additions & 1 deletion src/doctest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,18 @@ manual pages can be disabled if `source` is set to `nothing`.
develop mode and commit any staged changes. You should also review all the changes made
by `doctest` before committing them, as there may be edge cases when the automatic
fixing fails.
Select other keyword arguments, e.g., `plugins`, are internally forwarded to
[`makedocs`](@ref). These should only be used as directed, e.g., in the documentation of a
third-party plugin.
"""
function doctest(
source::Union{AbstractString,Nothing},
modules::AbstractVector{Module};
fix = false,
testset = "Doctests",
doctestfilters = Regex[],
kwargs...
)
function all_doctests()
dir = mktempdir()
Expand All @@ -75,7 +80,7 @@ function doctest(
source = joinpath(dir, "src")
mkdir(source)
end
makedocs(
makedocs(;

Check warning on line 83 in src/doctest.jl

View check run for this annotation

Codecov / codecov/patch

src/doctest.jl#L83

Added line #L83 was not covered by tests
root = dir,
source = source,
sitename = "",
Expand All @@ -85,6 +90,10 @@ function doctest(
# When doctesting, we don't really want to get bogged down with issues
# related to determining the remote repositories for edit URLs and such
remotes = nothing,
# Forward other keyword arguments. Users are warned to "only use as
# directed", but e.g. `plugins` may be necessary for some third-party
# plugins.
kwargs...,
)
true
catch err
Expand Down
13 changes: 12 additions & 1 deletion test/plugins/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ A = _TestPluginA(false)
plugins=[_RunPluginTests(true), A],
sitename="-", modules = [PluginsTestModule], warnonly=false
) === nothing
@test A.processed = true
@test A.processed


# Errors
Expand Down Expand Up @@ -115,4 +115,15 @@ catch exc
end


# Doctests - the `doctest` function must also be able to process plugins

A = _TestPluginA(false)
@test !(A.processed)
doctest(
joinpath(@__DIR__, "src"),
[PluginsTestModule];
plugins=[_RunPluginTests(true), A]
)
@test A.processed

end

0 comments on commit efc2500

Please sign in to comment.