Add :canonical: directives for intersphinx cross-referencing#12098
Add :canonical: directives for intersphinx cross-referencing#12098Dreamsorcerer merged 2 commits intoaio-libs:masterfrom
Conversation
When other projects use autodoc or intersphinx to reference aiohttp objects, they resolve the fully-qualified module path (e.g. aiohttp.client.ClientSession) rather than the public API path (aiohttp.ClientSession). Since our docs only document the public aliases, these references fail to resolve. This adds :canonical: directive options to all class, function, and exception directives in the reference documentation, mapping each documented object to its actual module path. This allows intersphinx to resolve both the public alias and the internal module path. Fixes aio-libs#10468 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #12098 +/- ##
=======================================
Coverage 98.77% 98.77%
=======================================
Files 128 128
Lines 44892 44892
Branches 2383 2383
=======================================
+ Hits 44342 44343 +1
+ Misses 390 389 -1
Partials 160 160
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Backport to 3.13: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply 345ac4d on top of patchback/backports/3.13/345ac4df3f41e3975a1daa8788a01ec6ff9483bb/pr-12098 Backporting merged PR #12098 into master
🤖 @patchback |
Backport to 3.14: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply 345ac4d on top of patchback/backports/3.14/345ac4df3f41e3975a1daa8788a01ec6ff9483bb/pr-12098 Backporting merged PR #12098 into master
🤖 @patchback |
|
Thanks. If you could follow those instructions to create backports, that'd be really helpful. |
Summary
Fixes #10468
When other projects use
autodocorintersphinxto reference aiohttp objects, they resolve the fully-qualified module path (e.g.aiohttp.client.ClientSession) from the object's__module__attribute. Since our docs only document the public aliases (e.g.aiohttp.ClientSessionvia.. currentmodule:: aiohttp), these cross-references fail with warnings like:This PR adds
:canonical:directive options to allclass,function, andexceptiondirectives across the reference documentation. The:canonical:option (available since Sphinx 4.0) tells Sphinx to register each object under both its documented name and its actual module path in the intersphinx inventory, enabling cross-referencing via either path.Files changed
docs/client_reference.rst— 50 canonical directives (ClientSession, connectors, exceptions, etc.)docs/web_reference.rst— 50 canonical directives (Request, Response, Application, routing, runners, etc.)docs/web_exceptions.rst— 57 canonical directives (all HTTP exception classes)docs/tracing_reference.rst— 17 canonical directives (TraceConfig and all trace param classes)docs/multipart_reference.rst— 4 canonical directives (MultipartReader, MultipartWriter, etc.)docs/websocket_utilities.rst— 2 canonical directives (WSCloseCode, WSMsgType)docs/streams.rst— 1 canonical directive (StreamReader)CHANGES/10468.doc.rst— changelog entryHow it works
For example,
ClientSessionis defined inaiohttp.clientbut documented under.. currentmodule:: aiohttp:This registers
aiohttp.client.ClientSessionas an alias in the Sphinx inventory, so intersphinx lookups from other projects will resolve correctly while the docs continue to display the public API pathaiohttp.ClientSession.Test plan
make html(no new warnings)This PR was created with the assistance of Claude Opus 4.6 by Anthropic. Happy to make any adjustments! Reviewed and submitted by a human.