Skip to content

Show version-specific docs links on resource hovers#20016

Merged
andyleejordan merged 3 commits into
mainfrom
andyleejordan-extend-hover-doc-link-to-resource-type
Jul 7, 2026
Merged

Show version-specific docs links on resource hovers#20016
andyleejordan merged 3 commits into
mainfrom
andyleejordan-extend-hover-doc-link-to-resource-type

Conversation

@andyleejordan

@andyleejordan andyleejordan commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #16178.

We already render a View Documentation link when hovering a resource's
name, but as @anthony-c-martin noted it's hard to discover there. This PR
makes it discoverable and version-accurate:

  • Extend the hover to the resource type string — as @majastrz suggested,
    the same hover (signature + docs link) now also shows when hovering over
    Microsoft.Storage/storageAccounts@2023-01-01, not just the symbol name.
  • Make the docs link version-specific — as the opener @oricawalid
    requested, the link now points at the pinned API version's Learn page,
    e.g. .../microsoft.storage/2023-01-01/storageaccounts?pivots=deployment-language-bicep
    instead of the versionless "latest" page. It falls back to the versionless
    URL when a resource has no version.

Why this is safe

The type-string hover is implemented as a hover-only fallback in
BicepHoverHandler; it does not touch the shared BicepSymbolResolver. That
resolver backs rename, references, definition, etc., so mapping the type string
to the resource symbol there would (for example) make "rename symbol" over the
type string silently rename the resource. Keeping it local to the hover handler
avoids that blast radius.

Out of scope

The original issue also asked for clicking a resource type/ID/version to
open docs. After looking into it, opening an external URL on click of a symbol
isn't really a VS Code idiom — the discoverable, clickable link inside the hover
is the idiomatic surface for this, so we're intentionally not adding
click-to-open behavior here.


Drafted by Copilot (Claude Opus 4.8).

Microsoft Reviewers: Open in CodeFlow

andyleejordan and others added 2 commits July 6, 2026 15:25
The hover that shows a resource's signature and a `[View Documentation]`
link previously only appeared over the resource *name*. This makes the
Azure docs link hard to discover, since the type string
(e.g. `'Microsoft.Storage/storageAccounts@2023-01-01'`) is the more
natural thing to hover when you want to know about a resource type.

`BicepSymbolResolver.ResolveSymbol` returns null over the type string
because only the whole declaration and the name identifier bind to the
`ResourceSymbol` — the type `StringSyntax` is not in the symbol
bindings. So `BicepHoverHandler` now falls back, when symbol resolution
fails, to matching the type string directly and constructing a
`SymbolResolutionResult` that points the resource symbol at the type
string. That lets the hover reuse the exact same markdown and range
logic as the name hover — the type string just becomes the origin node,
so the docs link renders identically and the range highlights the type.

I scoped this to the hover handler rather than broadening the shared
symbol resolver, since `ResolveSymbol` also backs go-to-definition,
find-references, rename, and document-highlight — we don't want those to
start acting on the resource from the type string.

Fixes #16178

Drafted by Copilot (Claude Opus 4.8).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The hover's "View Documentation" link always pointed at Learn's
versionless page for a type, even when the resource pinned a concrete
API version. That page describes the latest schema, which can differ
from the version being authored, so the link didn't necessarily match
the resource.

Learn publishes a page per API version alongside the versionless page,
so we now insert the pinned version between the provider and the type
path — e.g. `Microsoft.Storage/storageAccounts@2026-04-01` links to
`.../microsoft.storage/2026-04-01/storageaccounts?pivots=deployment-language-bicep`.
When a resource somehow has no version we keep the existing versionless
URL.

Updated the existing hover URL assertions accordingly (the test RP uses
`@2020-01-01`).

Drafted by Copilot (Claude Opus 4.8).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Test this change out locally with the following install scripts (Action run 28881152796)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 28881152796
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 28881152796"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 28881152796
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 28881152796"

@andyleejordan

Copy link
Copy Markdown
Contributor Author

@shenglol shenglol left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

The vscode-bicep e2e hover tests weren't updated alongside the
LangServer changes on this branch. This does both:

- Adds a case that hovers the resource *type* string (not just the
  symbolic name) and asserts the same signature + docs link, exercising
  the issue #16178 feature end-to-end through VS Code.
- Updates the existing symbolic-name assertion to the version-specific
  Learn URL (`.../microsoft.network/2020-06-01/virtualnetworks?...`) to
  match the new behavior.

Verified locally against the min-supported VS Code (all hover tests
pass). The stable-VS-Code pass fails to launch here on an unrelated
macOS Unix-socket path-length limit caused by the long worktree path,
not by these tests.

Drafted by Copilot (Claude Opus 4.8).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

@shenglol shenglol left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@andyleejordan andyleejordan changed the title Show discoverable, version-specific docs links on resource hovers Show version-specific docs links on resource hovers Jul 7, 2026
@andyleejordan andyleejordan merged commit b31d19d into main Jul 7, 2026
81 of 82 checks passed
@andyleejordan andyleejordan deleted the andyleejordan-extend-hover-doc-link-to-resource-type branch July 7, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Clickable Links to Azure Documentation for Resource Types

2 participants