diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b23bc8d5d6..ea78cb6e447 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -132,6 +132,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 receive the same `plugins` keyword argument as `makedocs`. This enables `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..8c8640a77dd 100644 --- a/src/doctest.jl +++ b/src/doctest.jl @@ -46,13 +46,16 @@ manual pages can be disabled if `source` is set to `nothing`. # Keywords -**`testset`** specifies the name of test testset (default `Doctests`). +**`testset`** specifies the name of test testset (default `"Doctests"`). **`doctestfilters`** vector of regex to filter tests (see the manual on [Filtering Doctests](@ref)) **`fix`**, if set to `true`, updates all the doctests that fail with the correct output (default `false`). +**`plugins`** is a list of [`Documenter.Plugin`](@ref) objects to be forwarded to +[`makedocs`](@ref). Use as directed by the documentation of a third-party plugin. + !!! warning When running `doctest(...; fix=true)`, Documenter will modify the Markdown and Julia source files. It is strongly recommended that you only run it on packages in Pkg's @@ -66,6 +69,7 @@ function doctest( fix = false, testset = "Doctests", doctestfilters = Regex[], + plugins = Plugin[], ) function all_doctests() dir = mktempdir() @@ -75,7 +79,7 @@ function doctest( source = joinpath(dir, "src") mkdir(source) end - makedocs( + makedocs(; root = dir, source = source, sitename = "", @@ -85,6 +89,7 @@ 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, + plugins = plugins, ) true catch err diff --git a/test/plugins/make.jl b/test/plugins/make.jl index beb78fd6e19..768e0c67f1e 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 @@ -116,4 +116,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