in src/TemplateRefGenerator/Generators/MarkdownGenerator.cs [798:900]
private record PropertyData(
string Name,
string? Description,
string Type);
private static IEnumerable<PropertyData> GetProperties(
ResourceMetadata resource,
DeploymentType deploymentType,
string typeName,
IReadOnlyDictionary<string, ObjectTypeProperty> properties,
IEnumerable<PropertyRemark> propertyRemarks,
int anchorIndex)
{
var remarksByPropertyName = propertyRemarks.ToDictionary(x => x.PropertyName, StringComparer.OrdinalIgnoreCase);
var isResourceType = (typeName == resource.ResourceType);
if (isResourceType)
{
switch (deploymentType)
{
case DeploymentType.Bicep:
if (Utils.IsChildResource(resource.UnqualifiedResourceType))
{
var parentType = Utils.GetParentResource(resource.ResourceType);
var parentTypeUnqualified = Utils.GetParentResource(resource.UnqualifiedResourceType);
yield return new(
"parent",
$"In Bicep, you can specify the parent resource for a child resource. You only need to add this property when the child resource is declared outside of the parent resource.{Br}{Br}For more information, see [Child resource outside parent resource](/azure/azure-resource-manager/bicep/child-resource-name-type#outside-parent-resource).",
$"Symbolic name for resource of type: [{parentTypeUnqualified}](~/{parentType.ToLowerInvariant()}.md)");
}
else if (resource.Type.ScopeType == ScopeType.Unknown ||
resource.Type.ScopeType.HasFlag(ScopeType.Extension))
{
yield return new(
"scope",
"Use when creating a resource at a scope that is different than the deployment scope.",
"Set this property to the symbolic name of a resource to apply the [extension resource](/azure/azure-resource-manager/bicep/scope-extension-resources).");
}
break;
case DeploymentType.Terraform:
if (Utils.IsChildResource(resource.UnqualifiedResourceType))
{
var parentType = Utils.GetParentResource(resource.ResourceType);
var parentTypeUnqualified = Utils.GetParentResource(resource.UnqualifiedResourceType);
yield return new(
"parent_id",
$"The ID of the resource that is the parent for this resource.",
$"ID for resource of type: [{parentTypeUnqualified}](~/{parentType.ToLowerInvariant()}.md)");
}
else if (resource.Type.ScopeType == ScopeType.Unknown ||
resource.Type.ScopeType.HasFlag(ScopeType.Extension))
{
yield return new(
"parent_id",
"The ID of the resource to apply this extension resource to.",
"string (required)");
}
yield return new(
"type",
"The resource type",
$"\"{resource.ResourceType}@{resource.ApiVersion}\"");
break;
case DeploymentType.Json:
yield return new(
"type",
"The resource type",
$"'{resource.ResourceType}'");
yield return new(
"apiVersion",
"The api version",
$"'{resource.ApiVersion}'");
break;
}
}
foreach (var (propName, prop) in GetOrderedWritableProperties(properties))
{
if (isResourceType && propName == "tags")
{
var tagsType = deploymentType != DeploymentType.Terraform ?
"Dictionary of tag names and values. See [Tags in templates](/azure/azure-resource-manager/management/tag-resources#arm-templates)" :
"Dictionary of tag names and values.";
yield return new(
"tags",
"Resource tags",
tagsType);
continue;
}
var remark = remarksByPropertyName.TryGetValue(propName, out var value) ? value : null;
var description = remark?.Description ?? prop.Description;
var requiredSuffix = prop.Flags.HasFlag(ObjectTypePropertyFlags.Required) ? " (required)" : "";
yield return new(
propName,
description,
$"{GetTypeValue(prop.Type.Type, anchorIndex)}{requiredSuffix}");
}
}