diff --git a/CHANGELOG.md b/CHANGELOG.md index 9abc927f156..e91bb614b1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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]) diff --git a/src/doctest.jl b/src/doctest.jl index 07c6996ef9d..f3494f1fc3b 100644 --- a/src/doctest.jl +++ b/src/doctest.jl @@ -59,6 +59,10 @@ 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}, @@ -66,6 +70,7 @@ function doctest( fix = false, testset = "Doctests", doctestfilters = Regex[], + kwargs... ) function all_doctests() dir = mktempdir() @@ -75,7 +80,7 @@ function doctest( source = joinpath(dir, "src") mkdir(source) end - makedocs( + makedocs(; root = dir, source = source, sitename = "", @@ -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 diff --git a/test/plugins/make.jl b/test/plugins/make.jl index 4689787171f..5d409da101b 100644 --- a/test/plugins/make.jl +++ b/test/plugins/make.jl @@ -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 @@ -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