Title: fix: Expand relative cross-references against the object the docstring was written on by devtechedge · Pull Request #342 · mkdocstrings/python · GitHub
Open Graph Title: fix: Expand relative cross-references against the object the docstring was written on by devtechedge · Pull Request #342 · mkdocstrings/python
X Title: fix: Expand relative cross-references against the object the docstring was written on by devtechedge · Pull Request #342 · mkdocstrings/python
Description: With inherited_members enabled, the docstring of a base class member is rendered in the docs of the inheriting class. In AutorefsHook.expand_identifier, leading-dot relative cross-references found in such docstrings walk up from current_object, which for an inherited member is a Griffe alias living under the inheriting class. A reference written on pkga.sub.Base.MAPPING therefore expands to pkgb.Thing in the docs of a package that subclasses Base, instead of pkga.Thing, silently linking to a wrong target or aborting strict builds when the consumer has relative_crossrefs disabled. This change anchors the dot-walk on the docstring's parent, the object the docstring was actually written on, when that object is reachable, and falls back to the current object otherwise. This mirrors how get_context already uses docstring.parent for source location. The reproducer and root-cause analysis in #341 describe exactly this behavior, including the frequenz-sdk build failure against frequenz-quantities. A regression test in tests/test_rendering.py builds two in-memory modules with cross-module inheritance and asserts a ....Thing reference in an inherited member's docstring expands to pkga.Thing; it fails on main and passes with this change. A control assertion also checks that non-inherited objects still expand identically. Re-export aliases are anchored uniformly by this change: since docstring.parent of a re-export alias points at the private defining object, relative references there now expand against it. If different treatment is preferred for re-exports, happy to follow maintainer guidance. Whether the consumer's relative_crossrefs setting should gate expansion of a dependency's docstring at all is out of scope for this PR. Fixes #341
Open Graph Description: With inherited_members enabled, the docstring of a base class member is rendered in the docs of the inheriting class. In AutorefsHook.expand_identifier, leading-dot relative cross-references found ...
X Description: With inherited_members enabled, the docstring of a base class member is rendered in the docs of the inheriting class. In AutorefsHook.expand_identifier, leading-dot relative cross-references found ...
Opengraph URL: https://github.com/mkdocstrings/python/pull/342
X: @github
Domain: redirect.github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:096246a6-b03a-a4a1-6026-bdcdf02aa65b |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C63E:2E5258:30538F:435CD6:6AF844D6 |
| html-safe-nonce | a458c3ec821d72c9522ea748c3d9c152341aebbee5e5c373690f1204dc259f15 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNjNFOjJFNTI1ODozMDUzOEY6NDM1Q0Q2OjZBRjg0NEQ2IiwidmlzaXRvcl9pZCI6IjMzNDI0MDUwNTU0NzM1MzQxNjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a83eb5e48ec094ef1b2e8a807889f8737c36747fb25c6d038080a5156158362d |
| hovercard-subject-tag | pull_request:4521334715 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/mkdocstrings/python/pull/342/files |
| twitter:image | https://avatars.githubusercontent.com/u/294291171?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/294291171?s=400&v=4 |
| og:image:alt | With inherited_members enabled, the docstring of a base class member is rendered in the docs of the inheriting class. In AutorefsHook.expand_identifier, leading-dot relative cross-references found ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5713ecd83001b2f55c3509fb7a292bf7d66d0f167c7ae87a9f7eaec5a52bf8db |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/mkdocstrings/python git https://github.com/mkdocstrings/python.git |
| octolytics-dimension-user_id | 75664361 |
| octolytics-dimension-user_login | mkdocstrings |
| octolytics-dimension-repository_id | 422878404 |
| octolytics-dimension-repository_nwo | mkdocstrings/python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 422878404 |
| octolytics-dimension-repository_network_root_nwo | mkdocstrings/python |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 653be32ff5c755082a4db662491bfbbcfc9112c1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width