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 11, 2023
1 parent a6cd6a7 commit b1320f2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
9 changes: 7 additions & 2 deletions src/doctest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -66,6 +69,7 @@ function doctest(
fix = false,
testset = "Doctests",
doctestfilters = Regex[],
plugins = Plugin[],
)
function all_doctests()
dir = mktempdir()
Expand All @@ -75,7 +79,7 @@ function doctest(
source = joinpath(dir, "src")
mkdir(source)
end
makedocs(
makedocs(;

Check warning on line 82 in src/doctest.jl

View check run for this annotation

Codecov / codecov/patch

src/doctest.jl#L82

Added line #L82 was not covered by tests
root = dir,
source = source,
sitename = "",
Expand All @@ -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
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 @@ -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

0 comments on commit b1320f2

Please sign in to comment.