diff --git a/.mdsf.json b/.mdsf.json deleted file mode 100644 index c3f53e2e3..000000000 --- a/.mdsf.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/hougesen/mdsf/main/schemas/v0.11.1/mdsf.schema.json", - "format_finished_document": false, - "languages": { - "go": "golangci-lint:fmt", - "shell": "shfmt" - }, - "language_aliases": { - "sh": "shell", - "cmd": "shell", - "bash": "shell" - } -} diff --git a/README.md b/README.md index 5819ab3e8..da04f75ed 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,8 @@ Feedback, contributions and proposals are welcome. > **Recent news** > -> ✅ Preparing v2.5.0: new features, a few fixes (`EventuallyWithT`) +> ✅ Preparing v2.5.0: new features: support for synctest, NoFileDescriptorLeak for macos, +> plus a few fixes (`EventuallyWithT`, `Subset`). > > See also our [ROADMAP][doc-roadmap]. diff --git a/SECURITY.md b/SECURITY.md index 86b3a423e..a182f38d0 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -6,7 +6,7 @@ This policy outlines the commitment and practices of the go-openapi maintainers | Version | Supported | | ------- | ------------------ | -| 2.2.x | :white_check_mark: | +| 2.4.x | :white_check_mark: | ## Vulnerability checks in place diff --git a/codegen/internal/generator/doc_generator.go b/codegen/internal/generator/doc_generator.go index 6797b74cc..d880eeca6 100644 --- a/codegen/internal/generator/doc_generator.go +++ b/codegen/internal/generator/doc_generator.go @@ -184,7 +184,7 @@ func (d *DocGenerator) buildIndexDocument(docsByDomain iter.Seq2[string, model.D } doc.RefCount = len(doc.Index) - doc.Metrics = buildMetrics(docsByDomain) + doc.Metrics = d.buildMetrics(docsByDomain) doc.QuickIndex = buildQuickIndex(docsByDomain) return doc @@ -209,7 +209,7 @@ func buildIndexEntries(docsByDomain iter.Seq2[string, model.Document]) []model.I return entries } -func buildMetrics(docsByDomain iter.Seq2[string, model.Document]) (metrics model.Metrics) { +func (d *DocGenerator) buildMetrics(docsByDomain iter.Seq2[string, model.Document]) (metrics model.Metrics) { metrics.ByDomain = make(map[string]model.DomainMetrics) for domain, doc := range docsByDomain { @@ -240,7 +240,28 @@ func buildMetrics(docsByDomain iter.Seq2[string, model.Document]) (metrics model metrics.ByDomain[domain] = domainMetrics } - metrics.NonGenerics = metrics.Functions - metrics.Generics + metrics.NonGenerics = metrics.Assertions - metrics.Generics + variantsMultiplier := 1 + genericsVariantsMultiplier := 1 + + if d.ctx.enableForward { + variantsMultiplier++ + if d.ctx.enableFormat { + variantsMultiplier++ + } + } + + if d.ctx.enableFormat { + variantsMultiplier++ + genericsVariantsMultiplier++ + } + + metrics.PackageVariants = metrics.NonGenerics*variantsMultiplier + metrics.Generics*genericsVariantsMultiplier + + // caveat: assume 2 target packages (not really available from options atm). + const generatedPackages = 2 + metrics.TotalVariants = generatedPackages * metrics.PackageVariants + metrics.TotalFunctions = generatedPackages * (metrics.PackageVariants + metrics.Helpers + 1) // add the Assertion constructor. return metrics } diff --git a/codegen/internal/generator/templates/doc_metrics.md.gotmpl b/codegen/internal/generator/templates/doc_metrics.md.gotmpl index f302a0248..7489f1c06 100644 --- a/codegen/internal/generator/templates/doc_metrics.md.gotmpl +++ b/codegen/internal/generator/templates/doc_metrics.md.gotmpl @@ -13,15 +13,18 @@ All assertions are classified into **{{ .Domains }}** domains to help navigate t ## API metrics -Counts for core functionality, excluding variants (formatted, forward, forward-formatted). - -| Kind | Count | -| ------------------------ | ----------------- | -| All functions | {{ .Functions }} | -| All core assertions | {{ .Assertions }} | -| Generic assertions | {{ .Generics }} | -| Helpers (not assertions) | {{ .Helpers }} | -| Others | {{ .Others }} | +Counts for core functionality, and generated variants (formatted, forward, forward-formatted). + +| Kind | Count | Note | +| ------------------------- | ----------------- | ---- | +| All core functions | {{ .Functions }} | Maintained core | +| All core assertions | {{ .Assertions }} | Usage with `*testing.T` | +| Generic assertions | {{ .Generics }} | Type-safe assertions ("T" suffix) | +| Helpers (not assertions) | {{ .Helpers }} | General-purpose utilities, not assertions | +| Others | {{ .Others }} | | +| assert/require variants | {{ .PackageVariants }} | Generated variants | +| Total assertions variants | {{ .TotalVariants }} | Available assertions API | +| Total API surface | {{ .TotalFunctions }} | | {{- end }} diff --git a/codegen/internal/model/documentation.go b/codegen/internal/model/documentation.go index b014eb0d1..281a5ce25 100644 --- a/codegen/internal/model/documentation.go +++ b/codegen/internal/model/documentation.go @@ -151,14 +151,17 @@ type IndexEntry struct { //nolint:tagliatelle // not using camelcase type Metrics struct { - Domains int `yaml:"domains"` - Functions int `yaml:"functions"` - Assertions int `yaml:"assertions"` - Generics int `yaml:"generics"` - NonGenerics int `yaml:"nongeneric_assertions"` - Helpers int `yaml:"helpers"` - Others int `yaml:"others"` - ByDomain map[string]DomainMetrics `yaml:"by_domain"` + Domains int `yaml:"domains"` + Functions int `yaml:"functions"` + Assertions int `yaml:"assertions"` + Generics int `yaml:"generics"` + NonGenerics int `yaml:"nongeneric_assertions"` + Helpers int `yaml:"helpers"` + Others int `yaml:"others"` + ByDomain map[string]DomainMetrics `yaml:"by_domain"` + PackageVariants int `yaml:"package_variants"` + TotalVariants int `yaml:"total_variants"` + TotalFunctions int `yaml:"total_functions"` } type DomainMetrics struct { diff --git a/docs/doc-site/api/metrics.md b/docs/doc-site/api/metrics.md index 4cd34e74a..fd241586e 100644 --- a/docs/doc-site/api/metrics.md +++ b/docs/doc-site/api/metrics.md @@ -11,15 +11,18 @@ All assertions are classified into **19** domains to help navigate the API, depe ## API metrics -Counts for core functionality, excluding variants (formatted, forward, forward-formatted). +Counts for core functionality, and generated variants (formatted, forward, forward-formatted). -| Kind | Count | -| ------------------------ | ----------------- | -| All functions | 135 | -| All core assertions | 131 | -| Generic assertions | 50 | -| Helpers (not assertions) | 4 | -| Others | 0 | +| Kind | Count | Note | +| ------------------------- | ----------------- | ---- | +| All core functions | 135 | Maintained core | +| All core assertions | 131 | Usage with `*testing.T` | +| Generic assertions | 50 | Type-safe assertions ("T" suffix) | +| Helpers (not assertions) | 4 | General-purpose utilities, not assertions | +| Others | 0 | | +| assert/require variants | 424 | Generated variants | +| Total assertions variants | 848 | Available assertions API | +| Total API surface | 858 | | ## Quick index diff --git a/docs/doc-site/project/maintainers/ARCHITECTURE.md b/docs/doc-site/project/maintainers/ARCHITECTURE.md index c6bc87717..2de85b28e 100644 --- a/docs/doc-site/project/maintainers/ARCHITECTURE.md +++ b/docs/doc-site/project/maintainers/ARCHITECTURE.md @@ -55,7 +55,7 @@ All these variants make up several hundreds functions, which poses a challenge f We have adopted code and documentation generation as a mean to mitigate this issue. -#### Current (v2.3.0-unreleased) +#### Current (v2.5.0-unreleased) 1. Generic assertions (with type parameters): {{% siteparam "metrics.generics" %}} functions 2. Non-generic assertions (with t T parameter, no type parameters): {{% siteparam "metrics.nongeneric_assertions" %}} functions @@ -65,12 +65,11 @@ We have adopted code and documentation generation as a mean to mitigate this iss **Generated Functions** - 1. Generic assertions: {{% siteparam "metrics.generated_generic" %}} - 2. Non-generic assertions: {{% siteparam "metrics.generated_nongeneric" %}} - 3. Helper functions: {{% siteparam "metrics.generated_helpers" %}} - 4. Constructors: 2 + 1. Generated variants in each package (assert/require): {{% siteparam "metrics.package_variants" %}} + 2. Helpers: {{% siteparam "metrics.helpers" %}} + 3. Constructors: 2 (1 in assert, 1 in require) - Total: {{% siteparam "metrics.generated_total" %}} functions + Overall: {{% siteparam "metrics.total_functions" %}} generated functions ## Architecture Overview diff --git a/hack/doc-site/hugo/metrics.yaml b/hack/doc-site/hugo/metrics.yaml index 417ce8e6c..28f109835 100644 --- a/hack/doc-site/hugo/metrics.yaml +++ b/hack/doc-site/hugo/metrics.yaml @@ -4,7 +4,7 @@ params: functions: 135 assertions: 131 generics: 50 - nongeneric_assertions: 85 + nongeneric_assertions: 81 helpers: 4 others: 0 by_domain: @@ -65,3 +65,6 @@ params: yaml: name: Yaml count: 5 + package_variants: 424 + total_variants: 848 + total_functions: 858