This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 1897e9145cf471b1ad93f9604b91e3df808178c8
Author: Thomas Diesler <[email protected]>
AuthorDate: Thu Apr 25 16:02:59 2024 +0200

    (#5424) Ignore internal traits from public ascii docs
---
 addons/tracing/tracing.go                         |  4 +--
 cmd/util/doc-gen/generators/traitdocgen.go        | 37 ++++++++++++-----------
 docs/modules/ROOT/nav.adoc                        |  1 -
 docs/modules/ROOT/partials/apis/camel-k-crds.adoc |  2 ++
 docs/modules/traits/pages/dependencies.adoc       | 36 ----------------------
 docs/modules/traits/pages/registry.adoc           |  2 ++
 pkg/apis/camel/v1/trait/dependencies.go           |  4 +--
 pkg/apis/camel/v1/trait/registry.go               |  6 ++--
 8 files changed, 31 insertions(+), 61 deletions(-)

diff --git a/addons/tracing/tracing.go b/addons/tracing/tracing.go
index 808da4903..8bbab9126 100644
--- a/addons/tracing/tracing.go
+++ b/addons/tracing/tracing.go
@@ -37,8 +37,8 @@ import (
 //
 // WARNING: The Tracing trait can't be enabled at the same time as the 
Telemetry trait.
 //
-// +camel-k:trait=tracing
-// +camel-k:deprecated=2.3.0
+// +camel-k:trait=tracing.
+// +camel-k:deprecated=1.12.0.
 type Trait struct {
        traitv1.Trait `property:",squash" json:",inline"`
        // Enables automatic configuration of the trait, including automatic 
discovery of the tracing endpoint.
diff --git a/cmd/util/doc-gen/generators/traitdocgen.go 
b/cmd/util/doc-gen/generators/traitdocgen.go
index 8d52bd8f6..67f157e9a 100644
--- a/cmd/util/doc-gen/generators/traitdocgen.go
+++ b/cmd/util/doc-gen/generators/traitdocgen.go
@@ -42,6 +42,7 @@ import (
 const (
        tagTrait      = "+camel-k:trait"
        tagDeprecated = "+camel-k:deprecated"
+       tagInternal   = "+camel-k:internal"
        tagLint       = "nolint"
 
        adocCommonMarkerStart = "// Start of autogenerated code - DO NOT EDIT!"
@@ -85,12 +86,9 @@ func (g *traitDocGen) Filename() string {
 }
 
 func (g *traitDocGen) Filter(context *generator.Context, t *types.Type) bool {
-       for _, c := range t.CommentLines {
-               if strings.Contains(c, tagTrait) {
-                       return true
-               }
-       }
-       return false
+       comments := strings.Join(t.CommentLines, " ")
+       match := strings.Contains(comments, tagTrait) && 
!strings.Contains(comments, tagInternal)
+       return match
 }
 
 func (g *traitDocGen) GenerateType(context *generator.Context, t *types.Type, 
out io.Writer) error {
@@ -104,18 +102,21 @@ func (g *traitDocGen) GenerateType(context 
*generator.Context, t *types.Type, ou
        traitFile := traitID + ".adoc"
        filename := path.Join(docDir, traitPath, traitFile)
 
-       g.generatedTraitFiles = append(g.generatedTraitFiles, traitFile)
-
-       return util.WithFileContent(filename, func(file *os.File, data []byte) 
error {
-               content := strings.Split(string(data), "\n")
+       if g.Filter(context, t) {
+               g.generatedTraitFiles = append(g.generatedTraitFiles, traitFile)
+               err := util.WithFileContent(filename, func(file *os.File, data 
[]byte) error {
+                       content := strings.Split(string(data), "\n")
 
-               writeTitle(t, traitID, &content)
-               writeBadges(t, traitID, &content)
-               writeDescription(t, traitID, &content)
-               writeFields(t, traitID, &content)
+                       writeTitle(traitID, &content)
+                       writeBadges(t, &content)
+                       writeDescription(t, traitID, &content)
+                       writeFields(t, traitID, &content)
 
-               return writeFile(file, content)
-       })
+                       return writeFile(file, content)
+               })
+               return err
+       }
+       return nil
 }
 
 func (g *traitDocGen) Finalize(c *generator.Context, w io.Writer) error {
@@ -159,7 +160,7 @@ func traitNameFromFile(file string) string {
        return name
 }
 
-func writeTitle(t *types.Type, traitID string, content *[]string) {
+func writeTitle(traitID string, content *[]string) {
        res := append([]string(nil), *content...)
        // Check if we already have a title
        for _, s := range res {
@@ -173,7 +174,7 @@ func writeTitle(t *types.Type, traitID string, content 
*[]string) {
 
 // Write badges
 // https://shields.io/badges/static-badge
-func writeBadges(t *types.Type, traitID string, content *[]string) {
+func writeBadges(t *types.Type, content *[]string) {
        pre, post := split(*content, adocBadgesMarkerStart, adocBadgesMarkerEnd)
        // When there are no badges in the generated output already
        // assume that we want to have them just after the title
diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index 3bd4d36d0..b5d52e5bb 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -57,7 +57,6 @@
 ** xref:traits:camel.adoc[Camel]
 ** xref:traits:container.adoc[Container]
 ** xref:traits:cron.adoc[Cron]
-** xref:traits:dependencies.adoc[Dependencies]
 ** xref:traits:deployer.adoc[Deployer]
 ** xref:traits:deployment.adoc[Deployment]
 ** xref:traits:environment.adoc[Environment]
diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc 
b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
index 2bc10b2e8..1287f9efe 100644
--- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
+++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
@@ -8240,6 +8240,8 @@ Deprecated: for backward compatibility.
 * <<#_camel_apache_org_v1_IntegrationKitTraits, IntegrationKitTraits>>
 * <<#_camel_apache_org_v1_Traits, Traits>>
 
+WARNING: The Registry trait is **deprecated** and will removed in future 
release versions.
+
 The Registry trait sets up Maven to use the Image registry
 as a Maven repository.
 
diff --git a/docs/modules/traits/pages/dependencies.adoc 
b/docs/modules/traits/pages/dependencies.adoc
deleted file mode 100755
index c23b75a28..000000000
--- a/docs/modules/traits/pages/dependencies.adoc
+++ /dev/null
@@ -1,36 +0,0 @@
-= Dependencies Trait
-
-// Start of autogenerated code - DO NOT EDIT! (badges)
-image:https://img.shields.io/badge/2.4.0-white?label=Deprecated&labelColor=C40C0C&color=gray[Deprecated
 Badge]
-// End of autogenerated code - DO NOT EDIT! (badges)
-// Start of autogenerated code - DO NOT EDIT! (description)
-The Dependencies trait is internally used to automatically add runtime 
dependencies based on the
-integration that the user wants to run.
-
-
-This trait is available in the following profiles: **Kubernetes, Knative, 
OpenShift**.
-
-NOTE: The dependencies trait is a *platform trait* and cannot be disabled by 
the user.
-
-// End of autogenerated code - DO NOT EDIT! (description)
-// Start of autogenerated code - DO NOT EDIT! (configuration)
-== Configuration
-
-Trait properties can be specified when running any integration with the CLI:
-[source,console]
-----
-$ kamel run --trait dependencies.[key]=[value] integration.groovy
-----
-The following configuration options are available:
-
-[cols="2m,1m,5a"]
-|===
-|Property | Type | Description
-
-| dependencies.enabled
-| bool
-| Deprecated: no longer in use.
-
-|===
-
-// End of autogenerated code - DO NOT EDIT! (configuration)
diff --git a/docs/modules/traits/pages/registry.adoc 
b/docs/modules/traits/pages/registry.adoc
index f86f3fb1a..209415495 100644
--- a/docs/modules/traits/pages/registry.adoc
+++ b/docs/modules/traits/pages/registry.adoc
@@ -4,6 +4,8 @@
 
image:https://img.shields.io/badge/2.2.0-white?label=Deprecated&labelColor=C40C0C&color=gray[Deprecated
 Badge]
 // End of autogenerated code - DO NOT EDIT! (badges)
 // Start of autogenerated code - DO NOT EDIT! (description)
+WARNING: The Registry trait is **deprecated** and will removed in future 
release versions.
+
 The Registry trait sets up Maven to use the Image registry
 as a Maven repository.
 
diff --git a/pkg/apis/camel/v1/trait/dependencies.go 
b/pkg/apis/camel/v1/trait/dependencies.go
index 93d13ec85..9dc294c9e 100644
--- a/pkg/apis/camel/v1/trait/dependencies.go
+++ b/pkg/apis/camel/v1/trait/dependencies.go
@@ -20,8 +20,8 @@ package trait
 // The Dependencies trait is internally used to automatically add runtime 
dependencies based on the
 // integration that the user wants to run.
 //
-// +camel-k:trait=dependencies
-// +camel-k:deprecated=2.4.0
+// +camel-k:trait=dependencies.
+// +camel-k:internal.
 type DependenciesTrait struct {
        PlatformBaseTrait `property:",squash" json:",inline"`
 }
diff --git a/pkg/apis/camel/v1/trait/registry.go 
b/pkg/apis/camel/v1/trait/registry.go
index a4b839183..b35d74beb 100644
--- a/pkg/apis/camel/v1/trait/registry.go
+++ b/pkg/apis/camel/v1/trait/registry.go
@@ -17,11 +17,13 @@ limitations under the License.
 
 package trait
 
+// WARNING: The Registry trait is **deprecated** and will removed in future 
release versions.
+//
 // The Registry trait sets up Maven to use the Image registry
 // as a Maven repository.
 //
-// +camel-k:trait=registry
-// +camel-k:deprecated=2.2.0
+// +camel-k:trait=registry.
+// +camel-k:deprecated=2.2.0.
 type RegistryTrait struct {
        Trait `property:",squash" json:",inline"`
 }

Reply via email to