Generate links for primitive types. (#4386)
This commit is contained in:
parent
c830017383
commit
7834f2fcb2
|
@ -48,6 +48,7 @@ type DocLanguageHelper interface {
|
|||
GetDocLinkForPulumiType(pkg *schema.Package, typeName string) string
|
||||
GetDocLinkForResourceInputOrOutputType(pkg *schema.Package, moduleName, typeName string, input bool) string
|
||||
GetDocLinkForFunctionInputOrOutputType(pkg *schema.Package, moduleName, typeName string, input bool) string
|
||||
GetDocLinkForBuiltInType(typeName string) string
|
||||
GetLanguageTypeString(pkg *schema.Package, moduleName string, t schema.Type, input, optional bool) string
|
||||
// GetResourceFunctionResultName returns the name of the result type when a static resource function is used to lookup
|
||||
// an existing resource.
|
||||
|
|
|
@ -418,6 +418,11 @@ func (mod *modContext) typeString(t schema.Type, lang string, characteristics pr
|
|||
tokenName := tokenToName(t.Token)
|
||||
// Links to anchor tags on the same page must be lower-cased.
|
||||
href = "#" + strings.ToLower(tokenName)
|
||||
default:
|
||||
// Check if type is primitive/built-in type if no match for cases listed above.
|
||||
if schema.IsPrimitiveType(t) {
|
||||
href = docLanguageHelper.GetDocLinkForBuiltInType(t.String())
|
||||
}
|
||||
}
|
||||
|
||||
// Strip the namespace/module prefix for the type's display name.
|
||||
|
@ -489,7 +494,7 @@ func (mod *modContext) genConstructorTS(r *schema.Resource, argsOptional bool) [
|
|||
Name: "name",
|
||||
Type: propertyType{
|
||||
Name: "string",
|
||||
Link: nodejs.GetDocLinkForBuiltInType("string"),
|
||||
Link: docLangHelper.GetDocLinkForBuiltInType("string"),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -535,7 +540,7 @@ func (mod *modContext) genConstructorGo(r *schema.Resource, argsOptional bool) [
|
|||
Name: "name",
|
||||
Type: propertyType{
|
||||
Name: "string",
|
||||
Link: go_gen.GetDocLinkForBuiltInType("string"),
|
||||
Link: docLangHelper.GetDocLinkForBuiltInType("string"),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -598,7 +603,7 @@ func (mod *modContext) genConstructorCS(r *schema.Resource, argsOptional bool) [
|
|||
Name: "name",
|
||||
Type: propertyType{
|
||||
Name: "string",
|
||||
Link: "https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/built-in-types",
|
||||
Link: docLangHelper.GetDocLinkForBuiltInType("string"),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -891,9 +896,10 @@ func (mod *modContext) getTSLookupParams(r *schema.Resource, stateParam string)
|
|||
return []formalParam{
|
||||
{
|
||||
Name: "name",
|
||||
|
||||
Type: propertyType{
|
||||
Name: "string",
|
||||
Link: nodejs.GetDocLinkForBuiltInType("string"),
|
||||
Link: docLangHelper.GetDocLinkForBuiltInType("string"),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -939,7 +945,7 @@ func (mod *modContext) getGoLookupParams(r *schema.Resource, stateParam string)
|
|||
Name: "name",
|
||||
Type: propertyType{
|
||||
Name: "string",
|
||||
Link: go_gen.GetDocLinkForBuiltInType("string"),
|
||||
Link: docLangHelper.GetDocLinkForBuiltInType("string"),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -978,7 +984,7 @@ func (mod *modContext) getCSLookupParams(r *schema.Resource, stateParam string)
|
|||
Name: "name",
|
||||
Type: propertyType{
|
||||
Name: "string",
|
||||
Link: "https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/built-in-types",
|
||||
Link: docLangHelper.GetDocLinkForBuiltInType("string"),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -50,6 +50,13 @@ func (d DocLanguageHelper) GetDocLinkForResourceType(pkg *schema.Package, _, typ
|
|||
return fmt.Sprintf("/docs/reference/pkg/dotnet/Pulumi%s/%s.html", packageNamespace, typeName)
|
||||
}
|
||||
|
||||
// GetDocLinkForBuiltInType returns the C# URL for a built-in type.
|
||||
// Currently not using the typeName parameter because the returned link takes to a general
|
||||
// top -level page containing info for all built in types.
|
||||
func (d DocLanguageHelper) GetDocLinkForBuiltInType(typeName string) string {
|
||||
return "https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/built-in-types"
|
||||
}
|
||||
|
||||
// GetDocLinkForResourceInputOrOutputType returns the doc link for an input or output type of a Resource.
|
||||
func (d DocLanguageHelper) GetDocLinkForResourceInputOrOutputType(pkg *schema.Package, moduleName, typeName string, input bool) string {
|
||||
return d.GetDocLinkForResourceType(pkg, moduleName, typeName)
|
||||
|
|
|
@ -82,7 +82,7 @@ func (d DocLanguageHelper) GetDocLinkForFunctionInputOrOutputType(pkg *schema.Pa
|
|||
}
|
||||
|
||||
// GetDocLinkForBuiltInType returns the godoc URL for a built-in type.
|
||||
func GetDocLinkForBuiltInType(typeName string) string {
|
||||
func (d DocLanguageHelper) GetDocLinkForBuiltInType(typeName string) string {
|
||||
return fmt.Sprintf("https://golang.org/pkg/builtin/#%s", typeName)
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ func (d DocLanguageHelper) GetDocLinkForFunctionInputOrOutputType(pkg *schema.Pa
|
|||
}
|
||||
|
||||
// GetDocLinkForBuiltInType returns the URL for a built-in type.
|
||||
func GetDocLinkForBuiltInType(typeName string) string {
|
||||
func (d DocLanguageHelper) GetDocLinkForBuiltInType(typeName string) string {
|
||||
return fmt.Sprintf("https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/%s", typeName)
|
||||
}
|
||||
|
||||
|
|
|
@ -52,6 +52,13 @@ func (d DocLanguageHelper) GetDocLinkForFunctionInputOrOutputType(pkg *schema.Pa
|
|||
return ""
|
||||
}
|
||||
|
||||
// GetDocLinkForBuiltInType returns the Python URL for a built-in type.
|
||||
// Currently not using the typeName parameter because the returned link takes to a general
|
||||
// top-level page containing info for all built in types.
|
||||
func (d DocLanguageHelper) GetDocLinkForBuiltInType(typeName string) string {
|
||||
return "https://docs.python.org/3/library/stdtypes.html"
|
||||
}
|
||||
|
||||
// GetLanguageTypeString returns the Python-specific type given a Pulumi schema type.
|
||||
func (d DocLanguageHelper) GetLanguageTypeString(pkg *schema.Package, moduleName string, t schema.Type, input, optional bool) string {
|
||||
name := pyType(t)
|
||||
|
|
Loading…
Reference in a new issue