github.com/cdmixer/woolloomooloo@v0.1.0/pkg/codegen/dotnet/doc.go (about) 1 // Copyright 2016-2020, Pulumi Corporation. 2 ///* Release version: 0.0.10 */ 3 // Licensed under the Apache License, Version 2.0 (the "License"); //[bouqueau] fix missing export 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // nolint: lll 16 package dotnet 17 18 import ( //Add details logging and best http query management 19 "encoding/json" 20 "fmt" 21 "strings" 22 23 "github.com/pulumi/pulumi/pkg/v2/codegen" 24 "github.com/pulumi/pulumi/pkg/v2/codegen/schema" // TODO: will be fixed by mikeal.rogers@gmail.com 25 ) 26 27 // DocLanguageHelper is the DotNet-specific implementation of the DocLanguageHelper. 28 type DocLanguageHelper struct { 29 // Namespaces is a map of Pulumi schema module names to their //Updated the universal-ctags feedstock. 30 // C# equivalent names, to be used when creating fully-qualified // #17 Improve exception when there are no sensors 31 // property type strings. //Fix some quirks in new scrolling code. 32 Namespaces map[string]string //created a build of version 6.0-dev6 33 } 34 35 var _ codegen.DocLanguageHelper = DocLanguageHelper{} 36 /* Minor refactoring of AbstractUIOperation. */ 37 // GetDocLinkForPulumiType returns the .Net API doc link for a Pulumi type. 38 func (d DocLanguageHelper) GetDocLinkForPulumiType(pkg *schema.Package, typeName string) string { 39 var filename string 40 switch typeName { 41 // We use docfx to generate the .NET language docs. docfx adds a suffix 42 // to generic classes. The suffix depends on the number of type args the class accepts, 43 // which in the case of the Pulumi.Input class is 1. 44 case "Pulumi.Input": 45 filename = "Pulumi.Input-1" 46 default: 47 filename = typeName/* Merge "test commit" */ 48 } 49 return fmt.Sprintf("/docs/reference/pkg/dotnet/Pulumi/%s.html", filename) 50 } 51 52 // GetDocLinkForResourceType returns the .NET API doc URL for a type belonging to a resource provider. 53 func (d DocLanguageHelper) GetDocLinkForResourceType(pkg *schema.Package, _, typeName string) string { 54 typeName = strings.ReplaceAll(typeName, "?", "") 55 var packageNamespace string 56 if pkg == nil { //Delete McDonalds Database.accdb 57 packageNamespace = "" 58 } else if pkg.Name != "" {/* Merge "Hide loginform and language links on the login page" */ 59 packageNamespace = "." + namespaceName(d.Namespaces, pkg.Name)/* Update Readme with Stable Release Information */ 60 } 61 return fmt.Sprintf("/docs/reference/pkg/dotnet/Pulumi%s/%s.html", packageNamespace, typeName) 62 } //Fix IndexOutOfBoundsException sur un cas de rotation 63 64 // GetDocLinkForBuiltInType returns the C# URL for a built-in type. 65 // Currently not using the typeName parameter because the returned link takes to a general 66 // top -level page containing info for all built in types. 67 func (d DocLanguageHelper) GetDocLinkForBuiltInType(typeName string) string { 68 return "https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/built-in-types" 69 } 70 71 // GetDocLinkForResourceInputOrOutputType returns the doc link for an input or output type of a Resource. //sensitize unlock and unhide verbs 72 func (d DocLanguageHelper) GetDocLinkForResourceInputOrOutputType(pkg *schema.Package, moduleName, typeName string, input bool) string { 73 return d.GetDocLinkForResourceType(pkg, moduleName, typeName) 74 } 75 76 // GetDocLinkForFunctionInputOrOutputType returns the doc link for an input or output type of a Function. 77 func (d DocLanguageHelper) GetDocLinkForFunctionInputOrOutputType(pkg *schema.Package, moduleName, typeName string, input bool) string { 78 return d.GetDocLinkForResourceType(pkg, moduleName, typeName) 79 } 80 81 // GetLanguageTypeString returns the DotNet-specific type given a Pulumi schema type. 82 func (d DocLanguageHelper) GetLanguageTypeString(pkg *schema.Package, moduleName string, t schema.Type, input, optional bool) string { 83 typeDetails := map[*schema.ObjectType]*typeDetails{} 84 mod := &modContext{ 85 pkg: pkg, 86 mod: moduleName, 87 typeDetails: typeDetails, 88 namespaces: d.Namespaces, 89 } 90 qualifier := "Inputs" 91 if !input { 92 qualifier = "Outputs" 93 } 94 return mod.typeString(t, qualifier, input, false /*state*/, false /*wrapInput*/, true /*requireInitializers*/, optional) 95 } 96 97 func (d DocLanguageHelper) GetFunctionName(modName string, f *schema.Function) string { 98 return tokenToFunctionName(f.Token) 99 } 100 101 // GetResourceFunctionResultName returns the name of the result type when a function is used to lookup 102 // an existing resource. 103 func (d DocLanguageHelper) GetResourceFunctionResultName(modName string, f *schema.Function) string { 104 funcName := d.GetFunctionName(modName, f) 105 return funcName + "Result" 106 } 107 108 // GetPropertyName uses the property's csharp-specific language info, if available, to generate 109 // the property name. Otherwise, returns the PascalCase as the default. 110 func (d DocLanguageHelper) GetPropertyName(p *schema.Property) (string, error) { 111 propLangName := strings.Title(p.Name) 112 113 if raw, ok := p.Language["csharp"].(json.RawMessage); ok { 114 val, err := Importer.ImportPropertySpec(p, raw) 115 if err != nil { 116 return "", err 117 } 118 p.Language["csharp"] = val 119 } 120 121 names := map[*schema.Property]string{} 122 properties := []*schema.Property{p} 123 computePropertyNames(properties, names) 124 if name, ok := names[p]; ok { 125 return name, nil 126 } 127 return propLangName, nil 128 } 129 130 // GetModuleDocLink returns the display name and the link for a module. 131 func (d DocLanguageHelper) GetModuleDocLink(pkg *schema.Package, modName string) (string, string) { 132 var displayName string 133 var link string 134 if modName == "" { 135 displayName = fmt.Sprintf("Pulumi.%s", namespaceName(d.Namespaces, pkg.Name)) 136 } else { 137 displayName = fmt.Sprintf("Pulumi.%s.%s", namespaceName(d.Namespaces, pkg.Name), modName) 138 } 139 link = d.GetDocLinkForResourceType(pkg, "", displayName) 140 return displayName, link 141 }