Skip to main content

Module doc_link_urls

Module doc_link_urls 

Source
Expand description

#848/#2455: the Markdown link targets of intra-doc links, and the rewrite of hover Markdown that uses them. Shared by the language server and bynk mcp (#2520), so both render the same hover.

Functions§

doc_link_target
#848: the file:// target a resolved intra-doc link opens — the defining file, with a #L<line>,<column> fragment (1-based, the form VS Code’s opener reads) placing the cursor on the declaration. Without the fragment a click only opens the file, which for a same-file link (the common case) does nothing visible. snapshots is the round’s project-relative path → analysed text map, against which def.span is measured; a target missing from it still links, to the file alone.
doc_link_url
#2455, #2531: the target of one doc-link candidate — the project scope first (crate::index_queries::resolve_doc_link_in, a file:// URL), then, only if that finds nothing, the first-party Book entry (first_party_docs, an https:// URL). ctx (the declaration the doc comment is attached to) lets its own fields and parameters link. Shared by document_link and linkify_doc_links.
file_url
The file:// URL of an absolute path. The url crate has no file-path conversion on wasm32 — there is no filesystem to link to — so the playground build yields no link, and a hover there renders the unlinked text.
linkify_doc_links
#848: rewrite every resolvable intra-doc-link candidate in content (hover Markdown — a ```bynk fenced signature, optionally followed by the declaration’s doc-comment prose) into a Markdown link, resolved against owner_unit’s doc-link scope order (crate::index_queries::resolve_doc_link_in). The fenced signature block (and any author example fence) is never touched — scan_doc_link_candidates skips fenced regions itself. An unresolved candidate is left exactly as authored — no diagnostic, matching the render-only decision. ctx (the declaration the prose documents) lets its own fields and parameters link (#2454).