diff --git a/src/plugins/documenter.jl b/src/plugins/documenter.jl index 97ae7dc..b52eee8 100644 --- a/src/plugins/documenter.jl +++ b/src/plugins/documenter.jl @@ -33,14 +33,22 @@ function gen_plugin(p::Documenter, t::Template, pkg_name::AbstractString) end kwargs_string = if :additional_kwargs in fieldnames(typeof(p)) - set_kwargs = ["modules", "format", "pages", "repo", "sitename", "authors", "assets"] + standard_kwargs = ["modules", "format", "pages", "repo", "sitename", "authors", "assets"] # We want something that looks like the following: # key1="val1", # key2="val2", # - kwargs = (x for x in p.additional_kwargs if first(x) ∉ set_kwargs) - join(string(tab, first(p), "=", repr(last(p)), ",\n") for p in kwargs) + valid_keys = [k for k in keys(p.additional_kwargs) if k ∉ standard_kwargs] + if length(p.additional_kwargs) > length(valid_keys) + invalid_keys = (repr(k) for k in keys(p.additional_kwargs) if k in standard_kwargs) + @warn string( + "Ignoring predefined Documenter kwargs ", + join(invalid_keys, ", "), + " from additional kwargs." + ) + end + join(string(tab, k, "=", repr(p.additional_kwargs[k]), ",\n") for k in valid_keys) else "" end diff --git a/test/tests.jl b/test/tests.jl index aca2855..378a3d0 100644 --- a/test/tests.jl +++ b/test/tests.jl @@ -13,11 +13,6 @@ end struct Bar <: CustomPlugin end # A dummy Plugin subtype. struct Baz <: Plugin end -# A Documenter with extra kwargs -struct Bat <: Documenter - assets::Vector{AbstractString} - additional_kwargs::Vector{<:Pair} -end # Various options to be passed into templates. const me = "christopher-dG" @@ -402,19 +397,25 @@ end include(joinpath("plugins", "githubpages.jl")) end +# A Documenter with extra kwargs +struct Qux <: Documenter + assets::Vector{AbstractString} + additional_kwargs::AbstractDict +end @testset "Documenter add kwargs" begin t = Template(; user=me) pkg_dir = joinpath(t.dir, test_pkg) - p = Bat( + p = Qux( [], - ["strict"=>true, "checkdocs"=>:none, "format"=>:markdown, "stringarg"=>"string"] + Dict("strict"=>true, "checkdocs"=>:none, "format"=>:markdown, "stringarg"=>"string") ) - gen_plugin(p, t, test_pkg) + warn_str = "Ignoring predefined Documenter kwargs \"format\" from additional kwargs." + @test_logs (:warn, warn_str) gen_plugin(p, t, test_pkg) make = readchomp(joinpath(pkg_dir, "docs", "make.jl")) @test occursin( strip(""" - strict=true, checkdocs=:none, + strict=true, stringarg="string", """), make,