From a4df3022c67d3dc7d989e63e830e5e226906ed83 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Sun, 12 Jul 2026 02:13:33 -0400 Subject: [PATCH] Mark the documented public API as public FiniteDiff exports nothing and declared no `public` names, so every documented entry point (finite_difference_* and the *Cache types) is only reachable via qualified access `FiniteDiff.name`. On Julia 1.11+ that trips downstream ExplicitImports/Aqua qualified-access checks, which flag these as accesses to non-public names (e.g. the QA failure in SimpleBoundaryValueDiffEq.jl accessing finite_difference_jacobian). Declare the 15 names rendered in the docs' `@docs` blocks as `public`. `public` is a keyword only on 1.11+, so it is emitted via `eval` guarded on VERSION to keep the source parseable on the 1.10 LTS. Add a test asserting each name is defined and, on 1.11+, marked public. Co-Authored-By: Chris Rackauckas --- src/FiniteDiff.jl | 13 +++++++++++++ test/public_api_tests.jl | 27 +++++++++++++++++++++++++++ test/runtests.jl | 1 + 3 files changed, 41 insertions(+) create mode 100644 test/public_api_tests.jl diff --git a/src/FiniteDiff.jl b/src/FiniteDiff.jl index d1a7d06..eb7d69f 100644 --- a/src/FiniteDiff.jl +++ b/src/FiniteDiff.jl @@ -142,4 +142,17 @@ include("jacobians.jl") include("hessians.jl") include("jvp.jl") +# Mark the documented user-facing API (the names rendered in the docs' `@docs` +# blocks) as public. `public` is a keyword only on Julia 1.11+, so it is emitted +# via `eval` guarded on the version to keep this source parseable on the 1.10 LTS. +@static if VERSION >= v"1.11.0-DEV.469" + eval(Expr(:public, + :finite_difference_derivative, :finite_difference_derivative!, + :finite_difference_gradient, :finite_difference_gradient!, + :finite_difference_jacobian, :finite_difference_jacobian!, + :finite_difference_hessian, :finite_difference_hessian!, + :finite_difference_jvp, :finite_difference_jvp!, + :DerivativeCache, :GradientCache, :JacobianCache, :HessianCache, :JVPCache)) +end + end # module diff --git a/test/public_api_tests.jl b/test/public_api_tests.jl new file mode 100644 index 0000000..28a7c27 --- /dev/null +++ b/test/public_api_tests.jl @@ -0,0 +1,27 @@ +using FiniteDiff, Test + +# The documented user-facing API: every name rendered in a `@docs` block in the +# manual. These must be reachable and, on Julia 1.11+, marked `public` so that +# downstream packages' ExplicitImports/Aqua qualified-access checks pass. +const PUBLIC_API = ( + :finite_difference_derivative, :finite_difference_derivative!, + :finite_difference_gradient, :finite_difference_gradient!, + :finite_difference_jacobian, :finite_difference_jacobian!, + :finite_difference_hessian, :finite_difference_hessian!, + :finite_difference_jvp, :finite_difference_jvp!, + :DerivativeCache, :GradientCache, :JacobianCache, :HessianCache, :JVPCache, +) + +@testset "Public API is defined" begin + for name in PUBLIC_API + @test isdefined(FiniteDiff, name) + end +end + +@static if VERSION >= v"1.11.0-DEV.469" + @testset "Public API is marked public" begin + for name in PUBLIC_API + @test Base.ispublic(FiniteDiff, name) + end + end +end diff --git a/test/runtests.jl b/test/runtests.jl index fc66d8a..1b3f5b9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -14,6 +14,7 @@ end @time begin if GROUP == "All" || GROUP == "Core" + @time @safetestset "Public API Tests" begin include("public_api_tests.jl") end @time @safetestset "FiniteDiff Standard Tests" begin include("finitedifftests.jl") end @time @safetestset "Color Differentiation Tests" begin include("coloring_tests.jl") end @time @safetestset "Out of Place Tests" begin include("out_of_place_tests.jl") end