René's URL Explorer Experiment


Title: change: scoped cross-references should give precedence to exact matches · Issue #343 · mkdocstrings/python · GitHub

Open Graph Title: change: scoped cross-references should give precedence to exact matches · Issue #343 · mkdocstrings/python

X Title: change: scoped cross-references should give precedence to exact matches · Issue #343 · mkdocstrings/python

Description: Opening to keep as a memo for when working on a better solution in Zensical. Scoped cross-reference resolution Problem With scoped_crossrefs=True, mkdocstrings-python currently expands every reference before mkdocs-autorefs resolves it. ...

Open Graph Description: Opening to keep as a memo for when working on a better solution in Zensical. Scoped cross-reference resolution Problem With scoped_crossrefs=True, mkdocstrings-python currently expands every refere...

X Description: Opening to keep as a memo for when working on a better solution in Zensical. Scoped cross-reference resolution Problem With scoped_crossrefs=True, mkdocstrings-python currently expands every refere...

Opengraph URL: https://github.com/mkdocstrings/python/issues/343

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.112.4


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"change: scoped cross-references should give precedence to exact matches","articleBody":"Opening to keep as a memo for when working on a better solution in Zensical.\n\n# Scoped cross-reference resolution\n\n\n## Problem\n\n\nWith `scoped_crossrefs=True`, mkdocstrings-python currently expands every reference before mkdocs-autorefs resolves it.\n\n\nFor example, consider `markdown.something` in `markdown.core`, where `markdown` is also a local function. The handler changes this identifier to `markdown.core.markdown.something`.\n\n\nThis change removes the exact identifier before autorefs checks its local anchor maps or external inventories. A documented or imported `markdown.something` therefore cannot win over the scoped interpretation.\n\n\n## Resolution timing\n\n\n`AutorefsHook.expand_identifier()` runs during docstring Markdown conversion. It runs when `AutorefsInlineProcessor` creates the temporary `\u003cautoref>` element.\n\n\nAt that time, autorefs does not yet have its complete identifier-to-URL maps:\n\n\n- MkDocs can render and register targets on later pages.\n- Mkdocstrings registers external inventory URLs during `on_env`.\n- A Griffe object can exist without a rendered heading or registered URL.\n\n\nChecking autorefs during `expand_identifier()` would therefore make resolution depend on page order. Checking Griffe would only prove that a Python object exists, not that autorefs can link to it.\n\n\nAutorefs resolves `\u003cautoref>` elements during `on_env`, after MkDocs has rendered all pages and mkdocstrings has registered external inventories. Both candidates must survive until this step.\n\n\n## Applicable reference forms\n\n\nRelative and scoped cross-references are only manually written. They use an explicit target such as `[text][identifier]` or a code-style target such as ``[`identifier`][]``.\n\n\nAutorefs treats both forms as exact references and does not create a normal Markdown slug for them. Automatic cross-references are already absolute and do not need scoped resolution.\n\n\nThe required order is therefore:\n\n\n1. For an ordinary manual reference, try the identifier exactly as written.\n2. If `scoped_crossrefs=True`, try the identifier expanded in the current Python scope.\n3. For an explicit relative reference, use only its context-directed expansion.\n\n\nWhen `scoped_crossrefs=False`, do not emit or try a scoped fallback.\n\n\n## Implementation in mkdocstrings-python\n\n\nUse the existing `identifier` and `slug` attributes of `\u003cautoref>`. Autorefs already tries `identifier` first and `slug` second.\n\n\nFor an ordinary reference, `AutorefsHook.expand_identifier()` must preserve the exact identifier. When scoped cross-references are enabled, it must also compute and temporarily store the scoped identifier.\n\n\n`AutorefsHook.get_context()` must return a context whose `as_dict()` adds the scoped identifier as `slug`. Here, `slug` transports a fallback identifier; it is not a Markdown slug.\n\n\nFor example, the hook must produce the equivalent of:\n\n\n```html\n\u003cautoref identifier=\"markdown.something\" slug=\"markdown.core.markdown.something\">...\u003c/autoref>\n```\n\n\nAutorefs will then try `markdown.something` before `markdown.core.markdown.something`. This happens after all local and external URLs are available.\n\n\nThe hook must clear its stored fallback before it processes each reference. It must not emit `slug` when the scoped identifier equals the exact identifier.\n\n\nIf an enabled relative reference starts with a dot, expand it with the existing relative-reference logic. Return the expanded identifier directly and do not emit a scoped fallback.\n\n\nThis design requires no changes or new capabilities in mkdocs-autorefs. It also requires no coordinated release or new minimum autorefs version.\n\n\n## Tests\n\n\nAdd integration coverage for these cases:\n\n\n1. With `scoped_crossrefs=True`, both the exact and scoped targets exist. The exact target wins.\n2. With `scoped_crossrefs=True`, only the scoped target exists. The scoped fallback resolves.\n3. With `scoped_crossrefs=False`, the handler does not emit or try a scoped fallback.\n4. An exact target from an external inventory wins over a local scoped interpretation.\n5. Explicit relative cross-references keep their context-directed behavior and do not emit a scoped fallback.\n6. Automatic cross-references remain absolute and unchanged.\n7. The hook clears its stored fallback between consecutive references.\n\n\n## Backlink limitation\n\n\nAutorefs records backlinks against `identifier` before it tries `slug`. If the scoped fallback wins, autorefs does not record the backlink against the scoped target.\n\n\nThis behavior already applies to normal slug fallbacks. Link resolution needs no autorefs change, but backlink parity would require separate work in autorefs.\n","author":{"url":"https://github.com/pawamoy","@type":"Person","name":"pawamoy"},"datePublished":"2026-09-22T13:41:56Z","url":"https://github.com/mkdocstrings/python/issues/343"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:726dbd05-15bc-ddf3-64be-b9340141ca1c
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCE80:FBBFE:1129A86:16B5A03:6B0652E2
html-safe-nonce82bf5a4184ff7e03a3f81ac090633cd0204172c6b1dc759a0daa6e85c707e9a9
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRTgwOkZCQkZFOjExMjlBODY6MTZCNUEwMzo2QjA2NTJFMiIsInZpc2l0b3JfaWQiOiIzNzEyNTUyNzYzMDQyMTkwMDUwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac6bbed77910d0ae4f5e64014ebb732d911a5e9df2d7a866b654280593a1d38637
hovercard-subject-tagissue:5540429546
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/mkdocstrings/python/343/issue_layout
twitter:imagehttps://opengraph.githubassets.com/ae177097742d2bb9a4de33bc5a26a5970b165954399b3fafc59bf35761361427/mkdocstrings/python/issues/343
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/ae177097742d2bb9a4de33bc5a26a5970b165954399b3fafc59bf35761361427/mkdocstrings/python/issues/343
og:image:altOpening to keep as a memo for when working on a better solution in Zensical. Scoped cross-reference resolution Problem With scoped_crossrefs=True, mkdocstrings-python currently expands every refere...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamepawamoy
hostnamegithub.com
expected-hostnamegithub.com
None772b6997ca4daa0428dd49a25d76052e765555ae560fe9c88517eb828bbd861e
turbo-cache-controlno-preview
go-importgithub.com/mkdocstrings/python git https://github.com/mkdocstrings/python.git
octolytics-dimension-user_id75664361
octolytics-dimension-user_loginmkdocstrings
octolytics-dimension-repository_id422878404
octolytics-dimension-repository_nwomkdocstrings/python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id422878404
octolytics-dimension-repository_network_root_nwomkdocstrings/python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef1f9a08f7c769a37f1dfc18ad43d463c222a7eea
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/mkdocstrings/python/issues/343#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmkdocstrings%2Fpython%2Fissues%2F343
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmkdocstrings%2Fpython%2Fissues%2F343
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=mkdocstrings%2Fpython
Reloadhttps://github.com/mkdocstrings/python/issues/343
Reloadhttps://github.com/mkdocstrings/python/issues/343
Reloadhttps://github.com/mkdocstrings/python/issues/343
mkdocstringshttps://github.com/mkdocstrings
pythonhttps://github.com/mkdocstrings/python
Codehttps://github.com/mkdocstrings/python
Issues6 (6)https://github.com/mkdocstrings/python/issues
Pull requestshttps://github.com/mkdocstrings/python/pulls
Discussionshttps://github.com/mkdocstrings/python/discussions
Actionshttps://github.com/mkdocstrings/python/actions
Security and qualityhttps://github.com/mkdocstrings/python/security
Insightshttps://github.com/mkdocstrings/python/insights
https://github.com/mkdocstrings/python
New issuehttps://github.com/login?return_to=https://github.com/mkdocstrings/python/issues/343
New issuehttps://github.com/login?return_to=https://github.com/mkdocstrings/python/issues/343
change: scoped cross-references should give precedence to exact matcheshttps://github.com/mkdocstrings/python/issues/343#top
https://github.com/pawamoy
cross-refshttps://github.com/mkdocstrings/python/issues?q=state%3Aopen%20label%3A%22cross-refs%22
refactorhttps://github.com/mkdocstrings/python/issues?q=state%3Aopen%20label%3A%22refactor%22
https://github.com/pawamoy
pawamoyhttps://github.com/pawamoy
on Sep 22, 2026https://github.com/mkdocstrings/python/issues/343#issue-5540429546
pawamoyhttps://github.com/pawamoy
on Sep 22, 2026https://github.com/mkdocstrings/python/issues/343#event-31603910133
pawamoyhttps://github.com/pawamoy
cross-refshttps://github.com/mkdocstrings/python/issues?q=state%3Aopen%20label%3A%22cross-refs%22
refactorhttps://github.com/mkdocstrings/python/issues?q=state%3Aopen%20label%3A%22refactor%22
on Sep 22, 2026https://github.com/mkdocstrings/python/issues/343#event-31603911940
Sign up for freehttps://github.com/signup?return_to=https://github.com/mkdocstrings/python/issues/343
Sign in to commenthttps://github.com/login?return_to=https://github.com/mkdocstrings/python/issues/343
pawamoyhttps://github.com/pawamoy
cross-refshttps://github.com/mkdocstrings/python/issues?q=state%3Aopen%20label%3A%22cross-refs%22
refactorhttps://github.com/mkdocstrings/python/issues?q=state%3Aopen%20label%3A%22refactor%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.