Declare the documented public API via Julia's public mechanism (#1215)#1312
Merged
Conversation
HTTP.jl 2.x exports almost nothing (`WebSockets`, `escape`, plus a handful of re-exports), so nearly the entire documented API is reached as `HTTP.name` without being formally marked public. Julia 1.11 added the `public` keyword to distinguish supported public API from internals; declare it here so downstream code and tooling can tell the difference (and `names(HTTP)` reflects the real surface). - Main module, HTTP.WebSockets, and HTTP.Handlers each declare their documented, non-exported names public. Already-exported names are public via `export` and are not repeated. Names HTTP only extends from Base (`get`, `get!`) are included since they are documented `HTTP.get`/`HTTP.get!` entry points. - The declaration is gated on `VERSION >= v"1.11.0-DEV.469"` and uses `Core.eval(@__MODULE__, Expr(:public, …))`, which parses on Julia 1.10 (the package's lower compat bound) where the `public` keyword does not exist. - New test asserts every name documented in docs/src/api/*.md is exported or public, and that internals stay private — so future docs additions can't silently skip the declaration. Supersedes the stale 1.x-targeting PR #1215 (which listed `download`/`status`, neither of which is an HTTP.jl function in 2.x). No behavior change: `public` does not affect `using HTTP`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1312 +/- ##
=======================================
Coverage 87.15% 87.16%
=======================================
Files 29 29
Lines 11291 11291
=======================================
+ Hits 9841 9842 +1
+ Misses 1450 1449 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #1215 (which targeted the deleted 1.x
src/HTTP.jland listeddownload/status— neither is an HTTP.jl function in 2.x).HTTP.jl 2.x exports almost nothing (
WebSockets,escape, and a few re-exports), so nearly the entire documented API is reached asHTTP.namewithout being formally marked public. Julia 1.11'spublickeyword exists exactly to distinguish supported public API from internals — this declares it, so downstream code and tooling (andnames(HTTP)) reflect the real public surface. Theretry_attempts/isrecoverablework from #1295/#1310 highlighted this gap.What it does
HTTP.WebSockets, andHTTP.Handlerseach declare their documented, non-exported namespublic. Already-exported names aren't repeated.get/get!are included (they're documentedHTTP.get/HTTP.get!entry points, even though HTTP extends them fromBase).VERSION >= v"1.11.0-DEV.469"viaCore.eval(@__MODULE__, Expr(:public, …)), which parses on Julia 1.10 (the package's lower compat bound, where thepublickeyword doesn't exist) — only the evaluation is version-gated.publicdoes not affectusing HTTP; it's metadata.Validation
names(HTTP)now surfaces 107 names (was just the exports); internals like_retryable_request_error/_normalize_local_addrcorrectly stay private.test/public_api_tests.jlparsesdocs/src/api/*.mdand asserts every documentedHTTP.*name is exported-or-public (and internals are private) — a doc-parity guard so future documented additions can't silently skip the declaration. It already caught one gap during development (HTTP.@client).🤖 Generated with Claude Code