Skip to content

Extending the ResourceType class to allow custom documentation links for bicep extension types #17429

@GABRIELNGBTUC

Description

@GABRIELNGBTUC

Is your feature request related to a problem? Please describe.
Nowadays, when you hover the name of resource defined in Bicep, a link to the documentation of the resource is displayed in the context windows that appears.

Image

Because this link is generated exclusively for Azure resources and the way it is generated is specially tailored for those resources as depicted by the code below, it is impossible for extensions such as the kubernetes, msgraph or any third party extension to provide documentation for their types.

private static string? TryGetTypeDocumentationLink(ResourceSymbol resource)
        {
            if (resource.TryGetResourceType() is { } resourceType &&
                resourceType.DeclaringNamespace.ExtensionNameEquals(AzNamespaceType.BuiltInName) &&
                resourceType.DeclaringNamespace.ResourceTypeProvider.HasDefinedType(resourceType.TypeReference))
            {
                var provider = resourceType.TypeReference.TypeSegments.First().ToLowerInvariant();
                var typePath = resourceType.TypeReference.TypeSegments.Skip(1).Select(x => x.ToLowerInvariant());

                return $"https://learn.microsoft.com/azure/templates/{provider}/{string.Join('/', typePath)}?pivots=deployment-language-bicep";
            }

            return null;
        }

Describe the solution you'd like
The resource type schema would accept a new property documentationLink or description that would allow extension authors to provide documentation links for their resource types. The language server would then check and read this new property to display documentation links if the resource is not an Azure type.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions