From 6e1d58a3bd60b5692afad35d17c8010d0a3592c5 Mon Sep 17 00:00:00 2001 From: Venelin Date: Thu, 19 Oct 2023 17:25:17 +0300 Subject: [PATCH 1/8] replace result summaries --- pkg/tfgen/docs.go | 27 ------- pkg/tfgen/examples_coverage_exporter.go | 46 ++++++----- pkg/tfgen/examples_coverage_tracker.go | 5 ++ pkg/tfgen/generate.go | 7 -- pkg/tfgen/main.go | 11 +-- pkg/tfgen/metrics.go | 102 ------------------------ 6 files changed, 39 insertions(+), 159 deletions(-) delete mode 100644 pkg/tfgen/metrics.go diff --git a/pkg/tfgen/docs.go b/pkg/tfgen/docs.go index d11cbcb63..08a915bec 100644 --- a/pkg/tfgen/docs.go +++ b/pkg/tfgen/docs.go @@ -255,7 +255,6 @@ func getDocsForResource(g *Generator, source DocsSource, kind DocKind, } if docFile == nil { - entitiesMissingDocs++ msg := fmt.Sprintf("could not find docs for %v %v. Override the Docs property in the %v mapping. See "+ "type tfbridge.DocInfo for details.", kind, formatEntityName(rawname), kind) @@ -700,7 +699,6 @@ func (p *tfMarkdownParser) parseSection(h2Section []string) error { switch header { case "Timeout", "Timeouts", "User Project Override", "User Project Overrides": p.sink.debug("Ignoring doc section [%v] for [%v]", header, p.rawname) - ignoredDocHeaders[header]++ return nil case "Example Usage": sectionKind = sectionExampleUsage @@ -740,7 +738,6 @@ func (p *tfMarkdownParser) parseSection(h2Section []string) error { !p.info.ReplaceExamplesSection() { p.sink.warn("Unexpected code snippets in section '%v' for %v '%v'. The HCL code will be converted if possible, "+ "but may not display correctly in the generated docs.", header, p.kind, p.rawname) - unexpectedSnippets++ } // Now process the content based on the H2 topic. These are mostly standard across TF's docs. @@ -875,17 +872,12 @@ func parseArgReferenceSection(subsection []string, ret *entityDocs) { addNewHeading := func(name, desc, line string) { // found a property bullet, extract the name and description if nested != "" { - // We found this line within a nested field. We should record it as such. - if ret.Arguments[nested] == nil { - totalArgumentsFromDocs++ - } ret.Arguments[nested.join(name)] = &argumentDocs{desc} } else { if genericNestedRegexp.MatchString(line) { return } ret.Arguments[docsPath(name)] = &argumentDocs{description: desc} - totalArgumentsFromDocs++ } } @@ -1708,7 +1700,6 @@ func (g *Generator) convertHCL(hcl, path, exampleTitle string, languages []strin isCompleteFailure := len(failedLangs) == len(languages) if isCompleteFailure { - hclAllLangsConversionFailures++ if exampleTitle == "" { g.warn(fmt.Sprintf("unable to convert HCL example for Pulumi entity '%s': %v. The example will be dropped "+ "from any generated docs or SDKs.", path, err)) @@ -1725,18 +1716,6 @@ func (g *Generator) convertHCL(hcl, path, exampleTitle string, languages []strin for lang := range failedLangs { failedLangsStrings = append(failedLangsStrings, lang) - - switch lang { - case convert.LanguageTypescript: - hclTypeScriptPartialConversionFailures++ - case convert.LanguagePython: - hclPythonPartialConversionFailures++ - case convert.LanguageCSharp: - hclCSharpPartialConversionFailures++ - case convert.LanguageGo: - hclGoPartialConversionFailures++ - } - if exampleTitle == "" { g.warn(fmt.Sprintf("unable to convert HCL example for Pulumi entity '%s' in the following language(s): "+ "%s. Examples for these languages will be dropped from any generated docs or SDKs.", @@ -1799,11 +1778,9 @@ func cleanupDoc( cleanedText, elided := reformatText(infoCtx, v.description, footerLinks) if elided { if k.nested() { - elidedNestedArguments++ g.warn("Found in docs for nested argument [%v] in [%v]. The argument's description will be "+ "dropped in the Pulumi provider.", k, name) } else { - elidedArguments++ g.warn("Found in docs for argument [%v] in [%v]. The argument's description will be dropped in "+ "the Pulumi provider.", k, name) } @@ -1818,7 +1795,6 @@ func cleanupDoc( g.debug("Cleaning up text for attribute [%v] in [%v]", k, name) cleanedText, elided := reformatText(infoCtx, v, footerLinks) if elided { - elidedAttributes++ g.warn("Found in docs for attribute [%v] in [%v]. The attribute's description will be dropped "+ "in the Pulumi provider.", k, name) elidedDoc = true @@ -1838,7 +1814,6 @@ func cleanupDoc( if examples == "" { g.debug("Unable to find any examples in the description text. The entire description will be discarded.") - elidedDescriptions++ g.warn("Found in description for [%v]. The description and any examples will be dropped in the "+ "Pulumi provider.", name) elidedDoc = true @@ -1847,12 +1822,10 @@ func cleanupDoc( cleanedupExamples, examplesElided := reformatText(infoCtx, examples, footerLinks) if examplesElided { - elidedDescriptions++ g.warn("Found in description for [%v]. The description and any examples will be dropped in "+ "the Pulumi provider.", name) elidedDoc = true } else { - elidedDescriptionsOnly++ g.warn("Found in description for [%v], but was able to preserve the examples. The description "+ "proper will be dropped in the Pulumi provider.", name) cleanupText = cleanedupExamples diff --git a/pkg/tfgen/examples_coverage_exporter.go b/pkg/tfgen/examples_coverage_exporter.go index 53755def6..815a38cab 100644 --- a/pkg/tfgen/examples_coverage_exporter.go +++ b/pkg/tfgen/examples_coverage_exporter.go @@ -440,22 +440,20 @@ func (ce *coverageExportUtil) exportMarkdown(outputDirectory string, fileName st return os.WriteFile(targetFile, []byte(out), 0600) } -// The fourth mode, which simply gives the provider name, and success percentage. -func (ce *coverageExportUtil) exportHumanReadable(outputDirectory string, fileName string) error { - - // The Coverage Tracker data structure is flattened to gather statistics about each language - type LanguageStatistic struct { - Total int - Successes int - } +// The Coverage Tracker data structure is flattened to gather statistics about each language +type LanguageStatistic struct { + Total int + Successes int +} - type ProviderStatistic struct { - Name string - Examples int - TotalConversions int - Successes int - } +type ProviderStatistic struct { + Name string + Examples int + TotalConversions int + Successes int +} +func (ce coverageExportUtil) produceStatistics() (map[string]*LanguageStatistic, ProviderStatistic) { // Main maps for holding the overall provider summary, and each language conversion statistic var allLanguageStatistics = make(map[string]*LanguageStatistic) var providerStatistic = ProviderStatistic{ce.Tracker.ProviderName, 0, 0, 0} @@ -491,10 +489,11 @@ func (ce *coverageExportUtil) exportHumanReadable(outputDirectory string, fileNa } } - targetFile, err := createEmptyFile(outputDirectory, fileName) - if err != nil { - return err - } + return allLanguageStatistics, providerStatistic +} + +func (ce *coverageExportUtil) produceHumanReadableSummary() string { + allLanguageStatistics, providerStatistic := ce.produceStatistics() // Forming a string which will eventually be written to the target file fileString := fmt.Sprintf("Provider: %s\nSuccess rate: %.2f%% (%d/%d)\n\n", @@ -522,6 +521,17 @@ func (ce *coverageExportUtil) exportHumanReadable(outputDirectory string, fileNa ) } + return fileString +} + +// The fourth mode, which simply gives the provider name, and success percentage. +func (ce *coverageExportUtil) exportHumanReadable(outputDirectory string, fileName string) error { + targetFile, err := createEmptyFile(outputDirectory, fileName) + if err != nil { + return err + } + fileString := ce.produceHumanReadableSummary() + return os.WriteFile(targetFile, []byte(fileString), 0600) } diff --git a/pkg/tfgen/examples_coverage_tracker.go b/pkg/tfgen/examples_coverage_tracker.go index f1d535864..f07a34a28 100644 --- a/pkg/tfgen/examples_coverage_tracker.go +++ b/pkg/tfgen/examples_coverage_tracker.go @@ -236,3 +236,8 @@ func (ct *CoverageTracker) exportResults(outputDirectory string) error { coverageExportUtil := newCoverageExportUtil(ct) return coverageExportUtil.tryExport(outputDirectory) } + +func (ct *CoverageTracker) getShortResultSummary() string { + coverageExportUtil := newCoverageExportUtil(ct) + return coverageExportUtil.produceHumanReadableSummary() +} diff --git a/pkg/tfgen/generate.go b/pkg/tfgen/generate.go index e19ab93d7..c5200d7a2 100644 --- a/pkg/tfgen/generate.go +++ b/pkg/tfgen/generate.go @@ -47,7 +47,6 @@ import ( shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/schema" "github.com/pulumi/pulumi-terraform-bridge/v3/unstable/metadata" - schemaTools "github.com/pulumi/schema-tools/pkg" ) const ( @@ -906,7 +905,6 @@ func (g *Generator) UnstableGenerateFromSchema(genSchemaResult *GenerateSchemaRe } pulumiPackageSpec := genSchemaResult.PackageSpec - schemaStats = schemaTools.CountStats(pulumiPackageSpec) // Serialize the schema and attach it to the provider shim. var err error @@ -987,9 +985,6 @@ func (g *Generator) UnstableGenerateFromSchema(genSchemaResult *GenerateSchemaRe return errors.Wrapf(err, "failed to create project file") } - // Print out some documentation stats as a summary afterwards. - printDocStats() - // Close the plugin host. g.pluginHost.Close() @@ -1259,7 +1254,6 @@ func (g *Generator) gatherResource(rawname string, // If an input, generate the input property metadata. if input(propschema, propinfo) { if foundInAttributes && !isProvider { - argumentDescriptionsFromAttributes++ msg := fmt.Sprintf("Argument desc from attributes: resource, rawname = '%s', property = '%s'", rawname, key) g.debug(msg) } @@ -1435,7 +1429,6 @@ func (g *Generator) gatherDataSource(rawname string, if input(sch, cust) { doc, foundInAttributes := getDescriptionFromParsedDocs(entityDocs, arg) if foundInAttributes { - argumentDescriptionsFromAttributes++ msg := fmt.Sprintf("Argument desc taken from attributes: data source, rawname = '%s', property = '%s'", rawname, arg) g.debug(msg) diff --git a/pkg/tfgen/main.go b/pkg/tfgen/main.go index 618b1c7a3..024dfb0e5 100644 --- a/pkg/tfgen/main.go +++ b/pkg/tfgen/main.go @@ -142,10 +142,8 @@ func newTFGenCmd(pkg string, version string, prov tfbridge.ProviderInfo, // Creating an item to keep track of example coverage if the // COVERAGE_OUTPUT_DIR env is set var coverageTracker *CoverageTracker - coverageOutputDir, coverageTrackingEnabled := os.LookupEnv("COVERAGE_OUTPUT_DIR") - if coverageTrackingEnabled { - coverageTracker = newCoverageTracker(prov.Name, prov.Version) - } + coverageOutputDir, coverageTrackingOutputEnabled := os.LookupEnv("COVERAGE_OUTPUT_DIR") + coverageTracker = newCoverageTracker(prov.Name, prov.Version) opts := GeneratorOptions{ Package: pkg, @@ -162,9 +160,12 @@ func newTFGenCmd(pkg string, version string, prov tfbridge.ProviderInfo, err := gen(opts) // Exporting collected coverage data to the directory specified by COVERAGE_OUTPUT_DIR - if coverageTrackingEnabled { + if coverageTrackingOutputEnabled { err = coverageTracker.exportResults(coverageOutputDir) + } else { + fmt.Println("Additional example conversion stats are available by setting COVERAGE_OUTPUT_DIR.") } + fmt.Println(coverageTracker.getShortResultSummary()) return err }), diff --git a/pkg/tfgen/metrics.go b/pkg/tfgen/metrics.go deleted file mode 100644 index 94694d196..000000000 --- a/pkg/tfgen/metrics.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2016-2022, Pulumi Corporation. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package tfgen - -import ( - "fmt" - schemaTools "github.com/pulumi/schema-tools/pkg" -) - -var ( - ignoredDocHeaders = make(map[string]int) - elidedDescriptions int // i.e., we discard the entire description, including examples - elidedDescriptionsOnly int // we discarded the description proper, but were able to preserve the examples - elidedArguments int - elidedNestedArguments int - elidedAttributes int - - unexpectedSnippets int - hclAllLangsConversionFailures int // examples that failed to convert in any language - - // examples that failed to convert in one, but not all, languages. This is less severe impact because users will - // at least have code in another language to reference: - hclGoPartialConversionFailures int - hclPythonPartialConversionFailures int - hclTypeScriptPartialConversionFailures int - hclCSharpPartialConversionFailures int - - // Arguments metrics: - totalArgumentsFromDocs int - // See comment in getNestedDescriptionFromParsedDocs for why we track this behavior: - argumentDescriptionsFromAttributes int - - // General metrics: - entitiesMissingDocs int - - schemaStats schemaTools.PulumiSchemaStats -) - -// printDocStats outputs metrics relating to document parsing and conversion -func printDocStats() { - fmt.Println("") - - fmt.Println("General metrics:") - fmt.Printf("\t%d total resources containing %d total inputs.\n", - schemaStats.Resources.TotalResources, schemaStats.Resources.TotalInputProperties) - fmt.Printf("\t%d total functions.\n", schemaStats.Functions.TotalFunctions) - fmt.Printf("\t%d entities are missing docs entirely because they could not be found in the upstream provider.\n", - entitiesMissingDocs) - fmt.Println("") - - fmt.Println("Description metrics:") - fmt.Printf("\t%d entity descriptions contained an reference and were dropped, including examples.\n", - elidedDescriptions) - fmt.Printf("\t%d entity descriptions contained an reference and were dropped, but examples were preserved.\n", - elidedDescriptionsOnly) - fmt.Println("") - - fmt.Println("Example conversion metrics:") - fmt.Printf("\t%d HCL examples failed to convert in all languages\n", hclAllLangsConversionFailures) - fmt.Printf("\t%d HCL examples were converted in at least one language but failed to convert to TypeScript\n", - hclTypeScriptPartialConversionFailures) - fmt.Printf("\t%d HCL examples were converted in at least one language but failed to convert to Python\n", - hclPythonPartialConversionFailures) - fmt.Printf("\t%d HCL examples were converted in at least one language but failed to convert to Go\n", - hclGoPartialConversionFailures) - fmt.Printf("\t%d HCL examples were converted in at least one language but failed to convert to C#\n", - hclCSharpPartialConversionFailures) - fmt.Printf("\t%d entity document sections contained unexpected HCL code snippets. Examples will be converted, "+ - "but may not display correctly in the registry, e.g. lacking tabs.\n", unexpectedSnippets) - fmt.Println("") - - fmt.Println("Argument metrics:") - fmt.Printf("\t%d argument descriptions were parsed from the upstream docs\n", totalArgumentsFromDocs) - fmt.Printf("\t%d top-level input property descriptions came from an upstream attribute (as opposed to an argument). "+ - "Nested arguments are not included in this count.\n", argumentDescriptionsFromAttributes) - fmt.Printf("\t%d arguments contained an reference and had their descriptions dropped.\n", - elidedArguments) - fmt.Printf("\t%d nested arguments contained an reference and had their descriptions dropped.\n", - elidedNestedArguments) - //nolint:lll - fmt.Printf("\t%d of %d resource inputs (%.2f%%) are missing descriptions in the schema\n", - schemaStats.Resources.InputPropertiesMissingDescriptions, schemaStats.Resources.TotalInputProperties, - float64(schemaStats.Resources.InputPropertiesMissingDescriptions)/float64(schemaStats.Resources.TotalInputProperties)*100) - fmt.Println("") - - fmt.Println("Attribute metrics:") - fmt.Printf("\t%d attributes contained an reference and had their descriptions dropped.\n", - elidedAttributes) - fmt.Println("") -} From d7b2ae068f8a325759dcb00e69f5841b18166703 Mon Sep 17 00:00:00 2001 From: Venelin Date: Fri, 20 Oct 2023 16:51:12 +0300 Subject: [PATCH 2/8] revert changes --- pkg/tfgen/docs.go | 27 +++++++++++ pkg/tfgen/generate.go | 7 +++ pkg/tfgen/metrics.go | 102 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 pkg/tfgen/metrics.go diff --git a/pkg/tfgen/docs.go b/pkg/tfgen/docs.go index 08a915bec..d11cbcb63 100644 --- a/pkg/tfgen/docs.go +++ b/pkg/tfgen/docs.go @@ -255,6 +255,7 @@ func getDocsForResource(g *Generator, source DocsSource, kind DocKind, } if docFile == nil { + entitiesMissingDocs++ msg := fmt.Sprintf("could not find docs for %v %v. Override the Docs property in the %v mapping. See "+ "type tfbridge.DocInfo for details.", kind, formatEntityName(rawname), kind) @@ -699,6 +700,7 @@ func (p *tfMarkdownParser) parseSection(h2Section []string) error { switch header { case "Timeout", "Timeouts", "User Project Override", "User Project Overrides": p.sink.debug("Ignoring doc section [%v] for [%v]", header, p.rawname) + ignoredDocHeaders[header]++ return nil case "Example Usage": sectionKind = sectionExampleUsage @@ -738,6 +740,7 @@ func (p *tfMarkdownParser) parseSection(h2Section []string) error { !p.info.ReplaceExamplesSection() { p.sink.warn("Unexpected code snippets in section '%v' for %v '%v'. The HCL code will be converted if possible, "+ "but may not display correctly in the generated docs.", header, p.kind, p.rawname) + unexpectedSnippets++ } // Now process the content based on the H2 topic. These are mostly standard across TF's docs. @@ -872,12 +875,17 @@ func parseArgReferenceSection(subsection []string, ret *entityDocs) { addNewHeading := func(name, desc, line string) { // found a property bullet, extract the name and description if nested != "" { + // We found this line within a nested field. We should record it as such. + if ret.Arguments[nested] == nil { + totalArgumentsFromDocs++ + } ret.Arguments[nested.join(name)] = &argumentDocs{desc} } else { if genericNestedRegexp.MatchString(line) { return } ret.Arguments[docsPath(name)] = &argumentDocs{description: desc} + totalArgumentsFromDocs++ } } @@ -1700,6 +1708,7 @@ func (g *Generator) convertHCL(hcl, path, exampleTitle string, languages []strin isCompleteFailure := len(failedLangs) == len(languages) if isCompleteFailure { + hclAllLangsConversionFailures++ if exampleTitle == "" { g.warn(fmt.Sprintf("unable to convert HCL example for Pulumi entity '%s': %v. The example will be dropped "+ "from any generated docs or SDKs.", path, err)) @@ -1716,6 +1725,18 @@ func (g *Generator) convertHCL(hcl, path, exampleTitle string, languages []strin for lang := range failedLangs { failedLangsStrings = append(failedLangsStrings, lang) + + switch lang { + case convert.LanguageTypescript: + hclTypeScriptPartialConversionFailures++ + case convert.LanguagePython: + hclPythonPartialConversionFailures++ + case convert.LanguageCSharp: + hclCSharpPartialConversionFailures++ + case convert.LanguageGo: + hclGoPartialConversionFailures++ + } + if exampleTitle == "" { g.warn(fmt.Sprintf("unable to convert HCL example for Pulumi entity '%s' in the following language(s): "+ "%s. Examples for these languages will be dropped from any generated docs or SDKs.", @@ -1778,9 +1799,11 @@ func cleanupDoc( cleanedText, elided := reformatText(infoCtx, v.description, footerLinks) if elided { if k.nested() { + elidedNestedArguments++ g.warn("Found in docs for nested argument [%v] in [%v]. The argument's description will be "+ "dropped in the Pulumi provider.", k, name) } else { + elidedArguments++ g.warn("Found in docs for argument [%v] in [%v]. The argument's description will be dropped in "+ "the Pulumi provider.", k, name) } @@ -1795,6 +1818,7 @@ func cleanupDoc( g.debug("Cleaning up text for attribute [%v] in [%v]", k, name) cleanedText, elided := reformatText(infoCtx, v, footerLinks) if elided { + elidedAttributes++ g.warn("Found in docs for attribute [%v] in [%v]. The attribute's description will be dropped "+ "in the Pulumi provider.", k, name) elidedDoc = true @@ -1814,6 +1838,7 @@ func cleanupDoc( if examples == "" { g.debug("Unable to find any examples in the description text. The entire description will be discarded.") + elidedDescriptions++ g.warn("Found in description for [%v]. The description and any examples will be dropped in the "+ "Pulumi provider.", name) elidedDoc = true @@ -1822,10 +1847,12 @@ func cleanupDoc( cleanedupExamples, examplesElided := reformatText(infoCtx, examples, footerLinks) if examplesElided { + elidedDescriptions++ g.warn("Found in description for [%v]. The description and any examples will be dropped in "+ "the Pulumi provider.", name) elidedDoc = true } else { + elidedDescriptionsOnly++ g.warn("Found in description for [%v], but was able to preserve the examples. The description "+ "proper will be dropped in the Pulumi provider.", name) cleanupText = cleanedupExamples diff --git a/pkg/tfgen/generate.go b/pkg/tfgen/generate.go index c5200d7a2..e19ab93d7 100644 --- a/pkg/tfgen/generate.go +++ b/pkg/tfgen/generate.go @@ -47,6 +47,7 @@ import ( shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim" "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/schema" "github.com/pulumi/pulumi-terraform-bridge/v3/unstable/metadata" + schemaTools "github.com/pulumi/schema-tools/pkg" ) const ( @@ -905,6 +906,7 @@ func (g *Generator) UnstableGenerateFromSchema(genSchemaResult *GenerateSchemaRe } pulumiPackageSpec := genSchemaResult.PackageSpec + schemaStats = schemaTools.CountStats(pulumiPackageSpec) // Serialize the schema and attach it to the provider shim. var err error @@ -985,6 +987,9 @@ func (g *Generator) UnstableGenerateFromSchema(genSchemaResult *GenerateSchemaRe return errors.Wrapf(err, "failed to create project file") } + // Print out some documentation stats as a summary afterwards. + printDocStats() + // Close the plugin host. g.pluginHost.Close() @@ -1254,6 +1259,7 @@ func (g *Generator) gatherResource(rawname string, // If an input, generate the input property metadata. if input(propschema, propinfo) { if foundInAttributes && !isProvider { + argumentDescriptionsFromAttributes++ msg := fmt.Sprintf("Argument desc from attributes: resource, rawname = '%s', property = '%s'", rawname, key) g.debug(msg) } @@ -1429,6 +1435,7 @@ func (g *Generator) gatherDataSource(rawname string, if input(sch, cust) { doc, foundInAttributes := getDescriptionFromParsedDocs(entityDocs, arg) if foundInAttributes { + argumentDescriptionsFromAttributes++ msg := fmt.Sprintf("Argument desc taken from attributes: data source, rawname = '%s', property = '%s'", rawname, arg) g.debug(msg) diff --git a/pkg/tfgen/metrics.go b/pkg/tfgen/metrics.go new file mode 100644 index 000000000..94694d196 --- /dev/null +++ b/pkg/tfgen/metrics.go @@ -0,0 +1,102 @@ +// Copyright 2016-2022, Pulumi Corporation. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package tfgen + +import ( + "fmt" + schemaTools "github.com/pulumi/schema-tools/pkg" +) + +var ( + ignoredDocHeaders = make(map[string]int) + elidedDescriptions int // i.e., we discard the entire description, including examples + elidedDescriptionsOnly int // we discarded the description proper, but were able to preserve the examples + elidedArguments int + elidedNestedArguments int + elidedAttributes int + + unexpectedSnippets int + hclAllLangsConversionFailures int // examples that failed to convert in any language + + // examples that failed to convert in one, but not all, languages. This is less severe impact because users will + // at least have code in another language to reference: + hclGoPartialConversionFailures int + hclPythonPartialConversionFailures int + hclTypeScriptPartialConversionFailures int + hclCSharpPartialConversionFailures int + + // Arguments metrics: + totalArgumentsFromDocs int + // See comment in getNestedDescriptionFromParsedDocs for why we track this behavior: + argumentDescriptionsFromAttributes int + + // General metrics: + entitiesMissingDocs int + + schemaStats schemaTools.PulumiSchemaStats +) + +// printDocStats outputs metrics relating to document parsing and conversion +func printDocStats() { + fmt.Println("") + + fmt.Println("General metrics:") + fmt.Printf("\t%d total resources containing %d total inputs.\n", + schemaStats.Resources.TotalResources, schemaStats.Resources.TotalInputProperties) + fmt.Printf("\t%d total functions.\n", schemaStats.Functions.TotalFunctions) + fmt.Printf("\t%d entities are missing docs entirely because they could not be found in the upstream provider.\n", + entitiesMissingDocs) + fmt.Println("") + + fmt.Println("Description metrics:") + fmt.Printf("\t%d entity descriptions contained an reference and were dropped, including examples.\n", + elidedDescriptions) + fmt.Printf("\t%d entity descriptions contained an reference and were dropped, but examples were preserved.\n", + elidedDescriptionsOnly) + fmt.Println("") + + fmt.Println("Example conversion metrics:") + fmt.Printf("\t%d HCL examples failed to convert in all languages\n", hclAllLangsConversionFailures) + fmt.Printf("\t%d HCL examples were converted in at least one language but failed to convert to TypeScript\n", + hclTypeScriptPartialConversionFailures) + fmt.Printf("\t%d HCL examples were converted in at least one language but failed to convert to Python\n", + hclPythonPartialConversionFailures) + fmt.Printf("\t%d HCL examples were converted in at least one language but failed to convert to Go\n", + hclGoPartialConversionFailures) + fmt.Printf("\t%d HCL examples were converted in at least one language but failed to convert to C#\n", + hclCSharpPartialConversionFailures) + fmt.Printf("\t%d entity document sections contained unexpected HCL code snippets. Examples will be converted, "+ + "but may not display correctly in the registry, e.g. lacking tabs.\n", unexpectedSnippets) + fmt.Println("") + + fmt.Println("Argument metrics:") + fmt.Printf("\t%d argument descriptions were parsed from the upstream docs\n", totalArgumentsFromDocs) + fmt.Printf("\t%d top-level input property descriptions came from an upstream attribute (as opposed to an argument). "+ + "Nested arguments are not included in this count.\n", argumentDescriptionsFromAttributes) + fmt.Printf("\t%d arguments contained an reference and had their descriptions dropped.\n", + elidedArguments) + fmt.Printf("\t%d nested arguments contained an reference and had their descriptions dropped.\n", + elidedNestedArguments) + //nolint:lll + fmt.Printf("\t%d of %d resource inputs (%.2f%%) are missing descriptions in the schema\n", + schemaStats.Resources.InputPropertiesMissingDescriptions, schemaStats.Resources.TotalInputProperties, + float64(schemaStats.Resources.InputPropertiesMissingDescriptions)/float64(schemaStats.Resources.TotalInputProperties)*100) + fmt.Println("") + + fmt.Println("Attribute metrics:") + fmt.Printf("\t%d attributes contained an reference and had their descriptions dropped.\n", + elidedAttributes) + fmt.Println("") +} From 575da4c036b267aef70320c8aec3464351b17b62 Mon Sep 17 00:00:00 2001 From: Venelin Date: Fri, 20 Oct 2023 17:03:04 +0300 Subject: [PATCH 3/8] rename structs to lowercase --- pkg/tfgen/examples_coverage_exporter.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/tfgen/examples_coverage_exporter.go b/pkg/tfgen/examples_coverage_exporter.go index 815a38cab..a6c28a5bc 100644 --- a/pkg/tfgen/examples_coverage_exporter.go +++ b/pkg/tfgen/examples_coverage_exporter.go @@ -441,33 +441,33 @@ func (ce *coverageExportUtil) exportMarkdown(outputDirectory string, fileName st } // The Coverage Tracker data structure is flattened to gather statistics about each language -type LanguageStatistic struct { +type languageStatistic struct { Total int Successes int } -type ProviderStatistic struct { +type providerStatistic struct { Name string Examples int TotalConversions int Successes int } -func (ce coverageExportUtil) produceStatistics() (map[string]*LanguageStatistic, ProviderStatistic) { +func (ce coverageExportUtil) produceStatistics() (map[string]*languageStatistic, providerStatistic) { // Main maps for holding the overall provider summary, and each language conversion statistic - var allLanguageStatistics = make(map[string]*LanguageStatistic) - var providerStatistic = ProviderStatistic{ce.Tracker.ProviderName, 0, 0, 0} + var allLanguageStatistics = make(map[string]*languageStatistic) + var providerStats = providerStatistic{ce.Tracker.ProviderName, 0, 0, 0} // All the conversion attempts for each example are iterated by language name and // their results are added to the main map for _, page := range ce.Tracker.EncounteredPages { for _, example := range page.Examples { - providerStatistic.Examples++ + providerStats.Examples++ for languageName, conversionResult := range example.ConversionResults { - providerStatistic.TotalConversions++ + providerStats.TotalConversions++ // Obtaining the current language we will be creating statistics for - var currentLanguage *LanguageStatistic + var currentLanguage *languageStatistic if val, ok := allLanguageStatistics[languageName]; ok { // Current language already exists in main map @@ -475,21 +475,21 @@ func (ce coverageExportUtil) produceStatistics() (map[string]*LanguageStatistic, } else { // The main map doesn't yet contain this language, and it needs to be added - allLanguageStatistics[languageName] = &LanguageStatistic{0, 0} + allLanguageStatistics[languageName] = &languageStatistic{0, 0} currentLanguage = allLanguageStatistics[languageName] } // The language's entry in the summarized results is updated and any currentLanguage.Total++ if conversionResult.FailureSeverity == Success { - providerStatistic.Successes++ + providerStats.Successes++ currentLanguage.Successes++ } } } } - return allLanguageStatistics, providerStatistic + return allLanguageStatistics, providerStats } func (ce *coverageExportUtil) produceHumanReadableSummary() string { From 282f0ea7311f0d2cfd86d030a961f27591f0e03f Mon Sep 17 00:00:00 2001 From: Venelin Date: Fri, 20 Oct 2023 17:27:29 +0300 Subject: [PATCH 4/8] some further tweaks to the output --- pkg/tfgen/docs.go | 17 ----- pkg/tfgen/examples_coverage_exporter.go | 2 +- pkg/tfgen/generate.go | 3 - pkg/tfgen/main.go | 3 +- pkg/tfgen/metrics.go | 84 ++++++++++++------------- 5 files changed, 44 insertions(+), 65 deletions(-) diff --git a/pkg/tfgen/docs.go b/pkg/tfgen/docs.go index d11cbcb63..890a9c963 100644 --- a/pkg/tfgen/docs.go +++ b/pkg/tfgen/docs.go @@ -740,7 +740,6 @@ func (p *tfMarkdownParser) parseSection(h2Section []string) error { !p.info.ReplaceExamplesSection() { p.sink.warn("Unexpected code snippets in section '%v' for %v '%v'. The HCL code will be converted if possible, "+ "but may not display correctly in the generated docs.", header, p.kind, p.rawname) - unexpectedSnippets++ } // Now process the content based on the H2 topic. These are mostly standard across TF's docs. @@ -1708,7 +1707,6 @@ func (g *Generator) convertHCL(hcl, path, exampleTitle string, languages []strin isCompleteFailure := len(failedLangs) == len(languages) if isCompleteFailure { - hclAllLangsConversionFailures++ if exampleTitle == "" { g.warn(fmt.Sprintf("unable to convert HCL example for Pulumi entity '%s': %v. The example will be dropped "+ "from any generated docs or SDKs.", path, err)) @@ -1725,18 +1723,6 @@ func (g *Generator) convertHCL(hcl, path, exampleTitle string, languages []strin for lang := range failedLangs { failedLangsStrings = append(failedLangsStrings, lang) - - switch lang { - case convert.LanguageTypescript: - hclTypeScriptPartialConversionFailures++ - case convert.LanguagePython: - hclPythonPartialConversionFailures++ - case convert.LanguageCSharp: - hclCSharpPartialConversionFailures++ - case convert.LanguageGo: - hclGoPartialConversionFailures++ - } - if exampleTitle == "" { g.warn(fmt.Sprintf("unable to convert HCL example for Pulumi entity '%s' in the following language(s): "+ "%s. Examples for these languages will be dropped from any generated docs or SDKs.", @@ -1838,7 +1824,6 @@ func cleanupDoc( if examples == "" { g.debug("Unable to find any examples in the description text. The entire description will be discarded.") - elidedDescriptions++ g.warn("Found in description for [%v]. The description and any examples will be dropped in the "+ "Pulumi provider.", name) elidedDoc = true @@ -1847,12 +1832,10 @@ func cleanupDoc( cleanedupExamples, examplesElided := reformatText(infoCtx, examples, footerLinks) if examplesElided { - elidedDescriptions++ g.warn("Found in description for [%v]. The description and any examples will be dropped in "+ "the Pulumi provider.", name) elidedDoc = true } else { - elidedDescriptionsOnly++ g.warn("Found in description for [%v], but was able to preserve the examples. The description "+ "proper will be dropped in the Pulumi provider.", name) cleanupText = cleanedupExamples diff --git a/pkg/tfgen/examples_coverage_exporter.go b/pkg/tfgen/examples_coverage_exporter.go index a6c28a5bc..de93291ad 100644 --- a/pkg/tfgen/examples_coverage_exporter.go +++ b/pkg/tfgen/examples_coverage_exporter.go @@ -496,7 +496,7 @@ func (ce *coverageExportUtil) produceHumanReadableSummary() string { allLanguageStatistics, providerStatistic := ce.produceStatistics() // Forming a string which will eventually be written to the target file - fileString := fmt.Sprintf("Provider: %s\nSuccess rate: %.2f%% (%d/%d)\n\n", + fileString := fmt.Sprintf("\nProvider: %s\nSuccess rate: %.2f%% (%d/%d)\n\n", providerStatistic.Name, float64(providerStatistic.Successes)/float64(providerStatistic.TotalConversions)*100.0, providerStatistic.Successes, diff --git a/pkg/tfgen/generate.go b/pkg/tfgen/generate.go index e19ab93d7..73e70dec3 100644 --- a/pkg/tfgen/generate.go +++ b/pkg/tfgen/generate.go @@ -987,9 +987,6 @@ func (g *Generator) UnstableGenerateFromSchema(genSchemaResult *GenerateSchemaRe return errors.Wrapf(err, "failed to create project file") } - // Print out some documentation stats as a summary afterwards. - printDocStats() - // Close the plugin host. g.pluginHost.Close() diff --git a/pkg/tfgen/main.go b/pkg/tfgen/main.go index 024dfb0e5..4b3f68676 100644 --- a/pkg/tfgen/main.go +++ b/pkg/tfgen/main.go @@ -163,9 +163,10 @@ func newTFGenCmd(pkg string, version string, prov tfbridge.ProviderInfo, if coverageTrackingOutputEnabled { err = coverageTracker.exportResults(coverageOutputDir) } else { - fmt.Println("Additional example conversion stats are available by setting COVERAGE_OUTPUT_DIR.") + fmt.Println("\nAdditional example conversion stats are available by setting COVERAGE_OUTPUT_DIR.") } fmt.Println(coverageTracker.getShortResultSummary()) + printDocStats() return err }), diff --git a/pkg/tfgen/metrics.go b/pkg/tfgen/metrics.go index 94694d196..1d5309069 100644 --- a/pkg/tfgen/metrics.go +++ b/pkg/tfgen/metrics.go @@ -16,6 +16,7 @@ package tfgen import ( "fmt" + schemaTools "github.com/pulumi/schema-tools/pkg" ) @@ -30,13 +31,6 @@ var ( unexpectedSnippets int hclAllLangsConversionFailures int // examples that failed to convert in any language - // examples that failed to convert in one, but not all, languages. This is less severe impact because users will - // at least have code in another language to reference: - hclGoPartialConversionFailures int - hclPythonPartialConversionFailures int - hclTypeScriptPartialConversionFailures int - hclCSharpPartialConversionFailures int - // Arguments metrics: totalArgumentsFromDocs int // See comment in getNestedDescriptionFromParsedDocs for why we track this behavior: @@ -50,53 +44,57 @@ var ( // printDocStats outputs metrics relating to document parsing and conversion func printDocStats() { - fmt.Println("") - fmt.Println("General metrics:") fmt.Printf("\t%d total resources containing %d total inputs.\n", schemaStats.Resources.TotalResources, schemaStats.Resources.TotalInputProperties) fmt.Printf("\t%d total functions.\n", schemaStats.Functions.TotalFunctions) - fmt.Printf("\t%d entities are missing docs entirely because they could not be found in the upstream provider.\n", - entitiesMissingDocs) + if entitiesMissingDocs > 0 { + fmt.Printf("\t%d entities are missing docs entirely because they could not be found in the upstream provider.\n", + entitiesMissingDocs) + } + if unexpectedSnippets > 0 { + fmt.Printf("\t%d entity document sections contained unexpected HCL code snippets. Examples will be converted, "+ + "but may not display correctly in the registry, e.g. lacking tabs.\n", unexpectedSnippets) + } fmt.Println("") - fmt.Println("Description metrics:") - fmt.Printf("\t%d entity descriptions contained an reference and were dropped, including examples.\n", - elidedDescriptions) - fmt.Printf("\t%d entity descriptions contained an reference and were dropped, but examples were preserved.\n", - elidedDescriptionsOnly) - fmt.Println("") - - fmt.Println("Example conversion metrics:") - fmt.Printf("\t%d HCL examples failed to convert in all languages\n", hclAllLangsConversionFailures) - fmt.Printf("\t%d HCL examples were converted in at least one language but failed to convert to TypeScript\n", - hclTypeScriptPartialConversionFailures) - fmt.Printf("\t%d HCL examples were converted in at least one language but failed to convert to Python\n", - hclPythonPartialConversionFailures) - fmt.Printf("\t%d HCL examples were converted in at least one language but failed to convert to Go\n", - hclGoPartialConversionFailures) - fmt.Printf("\t%d HCL examples were converted in at least one language but failed to convert to C#\n", - hclCSharpPartialConversionFailures) - fmt.Printf("\t%d entity document sections contained unexpected HCL code snippets. Examples will be converted, "+ - "but may not display correctly in the registry, e.g. lacking tabs.\n", unexpectedSnippets) - fmt.Println("") + if elidedDescriptions > 0 || elidedDescriptionsOnly > 0 { + fmt.Println("Description metrics:") + fmt.Printf("\t%d entity descriptions contained an reference and were dropped, including examples.\n", + elidedDescriptions) + fmt.Printf( + "\t%d entity descriptions contained an reference and were dropped, but examples were preserved.\n", + elidedDescriptionsOnly, + ) + fmt.Println("") + } fmt.Println("Argument metrics:") fmt.Printf("\t%d argument descriptions were parsed from the upstream docs\n", totalArgumentsFromDocs) fmt.Printf("\t%d top-level input property descriptions came from an upstream attribute (as opposed to an argument). "+ "Nested arguments are not included in this count.\n", argumentDescriptionsFromAttributes) - fmt.Printf("\t%d arguments contained an reference and had their descriptions dropped.\n", - elidedArguments) - fmt.Printf("\t%d nested arguments contained an reference and had their descriptions dropped.\n", - elidedNestedArguments) - //nolint:lll - fmt.Printf("\t%d of %d resource inputs (%.2f%%) are missing descriptions in the schema\n", - schemaStats.Resources.InputPropertiesMissingDescriptions, schemaStats.Resources.TotalInputProperties, - float64(schemaStats.Resources.InputPropertiesMissingDescriptions)/float64(schemaStats.Resources.TotalInputProperties)*100) + if elidedArguments > 0 || elidedNestedArguments > 0 { + fmt.Printf("\t%d arguments contained an reference and had their descriptions dropped.\n", + elidedArguments) + fmt.Printf("\t%d nested arguments contained an reference and had their descriptions dropped.\n", + elidedNestedArguments) + } + fmt.Printf( + "\t%d of %d resource inputs (%.2f%%) are missing descriptions in the schema\n", + schemaStats.Resources.InputPropertiesMissingDescriptions, + schemaStats.Resources.TotalInputProperties, + float64( + schemaStats.Resources.InputPropertiesMissingDescriptions, + )/float64( + schemaStats.Resources.TotalInputProperties, + )*100, + ) fmt.Println("") - fmt.Println("Attribute metrics:") - fmt.Printf("\t%d attributes contained an reference and had their descriptions dropped.\n", - elidedAttributes) - fmt.Println("") + if elidedAttributes > 0 { + fmt.Println("Attribute metrics:") + fmt.Printf("\t%d attributes contained an reference and had their descriptions dropped.\n", + elidedAttributes) + fmt.Println("") + } } From 7367b7f162773caafde2fd11c9887187684ad70d Mon Sep 17 00:00:00 2001 From: Venelin Date: Fri, 20 Oct 2023 17:33:40 +0300 Subject: [PATCH 5/8] remove unused variable --- pkg/tfgen/metrics.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/tfgen/metrics.go b/pkg/tfgen/metrics.go index 1d5309069..502d1896d 100644 --- a/pkg/tfgen/metrics.go +++ b/pkg/tfgen/metrics.go @@ -27,9 +27,7 @@ var ( elidedArguments int elidedNestedArguments int elidedAttributes int - - unexpectedSnippets int - hclAllLangsConversionFailures int // examples that failed to convert in any language + unexpectedSnippets int // Arguments metrics: totalArgumentsFromDocs int From 208af5f67a4fb113f538d7b5006f6e7cf22c2c0e Mon Sep 17 00:00:00 2001 From: VenelinMartinov Date: Tue, 24 Oct 2023 00:29:43 +0300 Subject: [PATCH 6/8] Convert examples only for schema lang (#1457) Stop unnecessarily converting the hcl examples when doing SDK generation for typescript, dotnet and other supported languages. Example conversion work is now confined to the `make tfgen` phase of provider builds. --- pkg/tfgen/generate.go | 2 +- pkg/tfgen/main.go | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/tfgen/generate.go b/pkg/tfgen/generate.go index 73e70dec3..d4487420c 100644 --- a/pkg/tfgen/generate.go +++ b/pkg/tfgen/generate.go @@ -96,7 +96,7 @@ const ( func (l Language) shouldConvertExamples() bool { switch l { - case Golang, NodeJS, Python, CSharp, Schema, PCL: + case Schema: return true } return false diff --git a/pkg/tfgen/main.go b/pkg/tfgen/main.go index 4b3f68676..f5584f1e6 100644 --- a/pkg/tfgen/main.go +++ b/pkg/tfgen/main.go @@ -158,15 +158,16 @@ func newTFGenCmd(pkg string, version string, prov tfbridge.ProviderInfo, } err := gen(opts) - - // Exporting collected coverage data to the directory specified by COVERAGE_OUTPUT_DIR - if coverageTrackingOutputEnabled { - err = coverageTracker.exportResults(coverageOutputDir) - } else { - fmt.Println("\nAdditional example conversion stats are available by setting COVERAGE_OUTPUT_DIR.") + if opts.Language.shouldConvertExamples() { + // Exporting collected coverage data to the directory specified by COVERAGE_OUTPUT_DIR + if coverageTrackingOutputEnabled { + err = coverageTracker.exportResults(coverageOutputDir) + } else { + fmt.Println("\nAdditional example conversion stats are available by setting COVERAGE_OUTPUT_DIR.") + } + fmt.Println(coverageTracker.getShortResultSummary()) + printDocStats() } - fmt.Println(coverageTracker.getShortResultSummary()) - printDocStats() return err }), From 094acc37b1d23adc1046648f44d050451a3807ad Mon Sep 17 00:00:00 2001 From: Venelin Date: Tue, 24 Oct 2023 10:24:24 +0300 Subject: [PATCH 7/8] address comments --- pkg/tfgen/docs.go | 5 ----- pkg/tfgen/metrics.go | 23 +---------------------- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/pkg/tfgen/docs.go b/pkg/tfgen/docs.go index 890a9c963..357187e55 100644 --- a/pkg/tfgen/docs.go +++ b/pkg/tfgen/docs.go @@ -1317,7 +1317,6 @@ func (g *Generator) convertExamplesInner( stripSubsectionsWithErrors bool, convertHCL func(hcl, path, exampleTitle string, languages []string) (string, error), ) (result string) { - output := &bytes.Buffer{} writeTrailingNewline := func(buf *bytes.Buffer) { @@ -1554,7 +1553,6 @@ func (g *Generator) legacyConvert( // convertHCLToString hides the implementation details of the upstream implementation for HCL conversion and provides // simplified parameters and return values func (g *Generator) convertHCLToString(hclCode, path, languageName string) (string, error) { - fileName := fmt.Sprintf("/%s.tf", strings.ReplaceAll(path, "/", "-")) var convertedHcl string @@ -1600,7 +1598,6 @@ type languages []string func (s languages) Len() int { return len(s) } func (s languages) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s languages) Less(i, j int) bool { - notFound := -1 indexOf := func(item string, data []string) int { @@ -1804,7 +1801,6 @@ func cleanupDoc( g.debug("Cleaning up text for attribute [%v] in [%v]", k, name) cleanedText, elided := reformatText(infoCtx, v, footerLinks) if elided { - elidedAttributes++ g.warn("Found in docs for attribute [%v] in [%v]. The attribute's description will be dropped "+ "in the Pulumi provider.", k, name) elidedDoc = true @@ -1954,7 +1950,6 @@ func extractExamples(description string) string { // reformatText processes markdown strings from TF docs and cleans them for inclusion in Pulumi docs func reformatText(g infoContext, text string, footerLinks map[string]string) (string, bool) { - cleanupText := func(text string) (string, bool) { // Remove incorrect documentation that should have been cleaned up in our forks. if strings.Contains(text, "Terraform") || strings.Contains(text, "terraform") { diff --git a/pkg/tfgen/metrics.go b/pkg/tfgen/metrics.go index 502d1896d..4c954250f 100644 --- a/pkg/tfgen/metrics.go +++ b/pkg/tfgen/metrics.go @@ -26,16 +26,13 @@ var ( elidedDescriptionsOnly int // we discarded the description proper, but were able to preserve the examples elidedArguments int elidedNestedArguments int - elidedAttributes int unexpectedSnippets int // Arguments metrics: totalArgumentsFromDocs int // See comment in getNestedDescriptionFromParsedDocs for why we track this behavior: argumentDescriptionsFromAttributes int - - // General metrics: - entitiesMissingDocs int + entitiesMissingDocs int schemaStats schemaTools.PulumiSchemaStats ) @@ -56,17 +53,6 @@ func printDocStats() { } fmt.Println("") - if elidedDescriptions > 0 || elidedDescriptionsOnly > 0 { - fmt.Println("Description metrics:") - fmt.Printf("\t%d entity descriptions contained an reference and were dropped, including examples.\n", - elidedDescriptions) - fmt.Printf( - "\t%d entity descriptions contained an reference and were dropped, but examples were preserved.\n", - elidedDescriptionsOnly, - ) - fmt.Println("") - } - fmt.Println("Argument metrics:") fmt.Printf("\t%d argument descriptions were parsed from the upstream docs\n", totalArgumentsFromDocs) fmt.Printf("\t%d top-level input property descriptions came from an upstream attribute (as opposed to an argument). "+ @@ -88,11 +74,4 @@ func printDocStats() { )*100, ) fmt.Println("") - - if elidedAttributes > 0 { - fmt.Println("Attribute metrics:") - fmt.Printf("\t%d attributes contained an reference and had their descriptions dropped.\n", - elidedAttributes) - fmt.Println("") - } } From 48863404bcd345686d168583fb8d92d9f0a55305 Mon Sep 17 00:00:00 2001 From: Venelin Date: Tue, 24 Oct 2023 10:28:50 +0300 Subject: [PATCH 8/8] lint --- pkg/tfgen/metrics.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/tfgen/metrics.go b/pkg/tfgen/metrics.go index 4c954250f..eea5b350e 100644 --- a/pkg/tfgen/metrics.go +++ b/pkg/tfgen/metrics.go @@ -21,12 +21,10 @@ import ( ) var ( - ignoredDocHeaders = make(map[string]int) - elidedDescriptions int // i.e., we discard the entire description, including examples - elidedDescriptionsOnly int // we discarded the description proper, but were able to preserve the examples - elidedArguments int - elidedNestedArguments int - unexpectedSnippets int + ignoredDocHeaders = make(map[string]int) + elidedArguments int + elidedNestedArguments int + unexpectedSnippets int // Arguments metrics: totalArgumentsFromDocs int