Skip to content

Declare documented API public (for downstream ExplicitImports)#819

Draft
ChrisRackauckas-Claude wants to merge 1 commit into
JuliaDiff:masterfrom
ChrisRackauckas-Claude:declare-public-api
Draft

Declare documented API public (for downstream ExplicitImports)#819
ChrisRackauckas-Claude wants to merge 1 commit into
JuliaDiff:masterfrom
ChrisRackauckas-Claude:declare-public-api

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Contributor

Motivation

ForwardDiff currently exports only DiffResults and does not declare any names public. As a result, downstream packages that access the documented API in qualified form — e.g. ForwardDiff.jacobian, ForwardDiff.gradient, ForwardDiff.GradientConfig — get flagged by ExplicitImports.jl's check_all_qualified_accesses_are_public, because to that tool every one of these reads as "non-public" (not exported, not declared public), even though the documentation presents them as the public API.

Many SciML packages (and others) run ExplicitImports as part of their QA suite, so each currently has to carry a manual ignore-list entry for ForwardDiff names. Declaring the documented surface public lets that boilerplate go away and makes the package's public/internal boundary explicit to tooling.

What this does

Adds a single Expr(:public, ...) declaration near the end of src/ForwardDiff.jl covering the names that are documented as the public API:

  • Core entry points (in the @docs blocks of docs/src/user/api.md): derivative, derivative!, gradient, gradient!, jacobian, jacobian!, hessian, hessian!
  • Config types (also @docs in api.md): DerivativeConfig, GradientConfig, JacobianConfig, HessianConfig
  • User-facing types/accessors documented in the user guides: Chunk (Configuring Chunk Size), Dual (Custom tags), value (Retrieving Lower-Order Results), and can_dual (has a ForwardDiff.can_dual docstring and is referenced as a user-extensible hook in the cannot-dual error message)

Exports are unchanged — this only marks names public, it does not bring anything into downstream scope unqualified.

public was added in Julia 1.11, so the declaration is @static-guarded (VERSION >= v"1.11.0-DEV.469"); Julia 1.10 is completely unaffected (the block is simply not evaluated there).

Deliberately not included

I left out names that appear only in the internals/implementation doc (docs/src/dev/how_it_works.md) and are not presented to users as public API: Partials, partials, npartials, and Tag. If maintainers consider any of these part of the supported surface, I'm happy to add them.

Note

This is a draft / proposal for maintainer consideration — please feel free to adjust the exact set of names. Marked draft and should be ignored until reviewed by @ChrisRackauckas.

ForwardDiff `export`s only `DiffResults` and declares no names `public`.
Downstream packages that access the documented API in qualified form
(e.g. `ForwardDiff.jacobian`) therefore trip ExplicitImports'
`check_all_qualified_accesses_are_public`, even though the docs present
these as the public surface.

This declares the already-documented public API with Julia's `public`
keyword. Exports are unchanged. The declaration is `@static`-guarded so
Julia 1.10 (which lacks `public`) is unaffected.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@codecov

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.74%. Comparing base (090ddbb) to head (b11acb5).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #819   +/-   ##
=======================================
  Coverage   90.74%   90.74%           
=======================================
  Files          11       11           
  Lines        1070     1070           
=======================================
  Hits          971      971           
  Misses         99       99           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mcabbott

Copy link
Copy Markdown
Member

Xref #744, in which there are various suggestions for what to mark public, none exactly agreeing with the list here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants