diff --git a/tools/resourcedocsgen/pkg/docs/gen.go b/tools/resourcedocsgen/pkg/docs/gen.go index 818dca325..dbe71044f 100644 --- a/tools/resourcedocsgen/pkg/docs/gen.go +++ b/tools/resourcedocsgen/pkg/docs/gen.go @@ -367,7 +367,7 @@ type resourceDocArgs struct { // ConstructorParamsTyped is the typed set of parameters for the constructor, in order. ConstructorParamsTyped map[string][]formalParam // ConstructorResource is the resource that is being constructed or is the result of a constructor-like function. - ConstructorResource map[string]propertyType + ConstructorResource map[language.Language]propertyType // ArgsRequired is a flag indicating if the args param is required when creating a new resource. ArgsRequired bool @@ -1394,22 +1394,23 @@ func (mod *modContext) genConstructors( } // getConstructorResourceInfo returns a map of per-language information about the resource being constructed. -func (mod *modContext) getConstructorResourceInfo(resourceTypeName, tok string) map[string]propertyType { +func (mod *modContext) getConstructorResourceInfo(resourceTypeName, tok string) map[language.Language]propertyType { dctx := mod.context docLangHelper := dctx.getLanguageDocHelper(language.YAML) - resourceMap := make(map[string]propertyType) + resourceMap := make(map[language.Language]propertyType) resourceDisplayName := resourceTypeName for _, lang := range dctx.supportedLanguages { + lang := mustConvertPulumiSchemaLanguage(lang) // Use the module to package lookup to transform the module name to its normalized package name. - modName := mod.getLanguageModuleName(mustConvertPulumiSchemaLanguage(lang)) + modName := mod.getLanguageModuleName(lang) // Reset the type name back to the display name. resourceTypeName = resourceDisplayName switch lang { - case "nodejs", "go", "python", "java": + case language.Typescript, language.Go, language.Python, language.Java: // Intentionally left blank. - case "csharp": + case language.CSharp: namespace := title(mod.pkg.Name(), language.CSharp) if ns, ok := dctx.csharpPkgInfo.Namespaces[mod.pkg.Name()]; ok { namespace = ns @@ -1420,7 +1421,7 @@ func (mod *modContext) getConstructorResourceInfo(resourceTypeName, tok string) } resourceTypeName = fmt.Sprintf("Pulumi.%s.%s.%s", namespace, modName, resourceTypeName) - case "yaml": + case language.YAML: def, err := mod.pkg.Definition() contract.AssertNoErrorf(err, "failed to get definition for package %q", mod.pkg.Name()) resourceMap[lang] = propertyType{ diff --git a/tools/resourcedocsgen/pkg/docs/templates/resource.tmpl b/tools/resourcedocsgen/pkg/docs/templates/resource.tmpl index 2946679a3..d25819d3b 100644 --- a/tools/resourcedocsgen/pkg/docs/templates/resource.tmpl +++ b/tools/resourcedocsgen/pkg/docs/templates/resource.tmpl @@ -30,44 +30,44 @@ Resources are created with functions called constructors. To learn more about de */}}
new {{ template "linkify_param" .ConstructorResource.nodejs }}({{ htmlSafe .ConstructorParams.nodejs }});
new {{ template "linkify_param" (index .ConstructorResource lNodejs) }}({{ htmlSafe .ConstructorParams.nodejs }});
@overload
-def {{ template "linkify_param" .ConstructorResource.python }}({{ htmlSafe .ConstructorParams.pythonargs }})
+def {{ template "linkify_param" (index .ConstructorResource lPython) }}({{ htmlSafe .ConstructorParams.pythonargs }})
@overload
-def {{ template "linkify_param" .ConstructorResource.python }}({{ htmlSafe .ConstructorParams.python }})
func {{ template "linkify_go_param" .ConstructorResource.go }}({{ htmlSafe .ConstructorParams.go }}) (*{{ template "linkify_param" .ConstructorResource.go }}, error)
func {{ template "linkify_go_param" (index .ConstructorResource lGo) }}({{ htmlSafe .ConstructorParams.go }}) (*{{ template "linkify_param" (index .ConstructorResource lGo) }}, error)
public {{ template "linkify_param" .ConstructorResource.csharp }}({{ htmlSafe .ConstructorParams.csharp }})
public {{ template "linkify_param" (index .ConstructorResource lCSharp) }}({{ htmlSafe .ConstructorParams.csharp }})
-public {{ template "linkify_param" .ConstructorResource.java }}({{ htmlSafe .ConstructorParams.javaargs }})
-public {{ template "linkify_param" .ConstructorResource.java }}({{ htmlSafe .ConstructorParams.java }})
+public {{ template "linkify_param" (index .ConstructorResource lJava) }}({{ htmlSafe .ConstructorParams.javaargs }})
+public {{ template "linkify_param" (index .ConstructorResource lJava) }}({{ htmlSafe .ConstructorParams.java }})
type: {{ template "linkify_param" .ConstructorResource.yaml }}
+type: {{ template "linkify_param" (index .ConstructorResource lYAML) }}
{{ template "yaml_constructor" .ConstructorParamsTyped.yaml }}
@@ -226,7 +226,7 @@ Get an existing {{.Header.Title}} resource's state with the given name, ID, and
-public static get({{ htmlSafe .LookupParams.nodejs }}): {{ template "linkify_param" .ConstructorResource.nodejs }}
+public static get({{ htmlSafe .LookupParams.nodejs }}): {{ template "linkify_param" (index .ConstructorResource lNodejs) }}
@@ -236,25 +236,25 @@ Get an existing {{.Header.Title}} resource's state with the given name, ID, and
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
- {{ htmlSafe .LookupParams.python }}) -> {{ .ConstructorResource.python.Name }}
+ {{ htmlSafe .LookupParams.python }}) -> {{ (index .ConstructorResource lPython).Name }}
func Get{{ .Header.Title }}({{ htmlSafe .LookupParams.go }}) (*{{ template "linkify_param" .ConstructorResource.go }}, error)
func Get{{ .Header.Title }}({{ htmlSafe .LookupParams.go }}) (*{{ template "linkify_param" (index .ConstructorResource lGo) }}, error)
public static {{ template "linkify_param" .ConstructorResource.csharp }} Get({{ htmlSafe .LookupParams.csharp }})
public static {{ template "linkify_param" (index .ConstructorResource lCSharp) }} Get({{ htmlSafe .LookupParams.csharp }})
public static {{ template "linkify_param" .ConstructorResource.java }} get({{ htmlSafe .LookupParams.java }})
public static {{ template "linkify_param" (index .ConstructorResource lJava) }} get({{ htmlSafe .LookupParams.java }})
resources: _: type: {{ template "linkify_param" .ConstructorResource.yaml }} get: id: ${id}
+ resources: _: type: {{ template "linkify_param" (index .ConstructorResource lYAML) }} get: id: ${id}