From fee70c33e489b2a1260252eed20553e86b37403d Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Fri, 9 Jan 2026 17:14:04 +0100 Subject: [PATCH] fix(docs): filter Optional markers from validation column The crd-ref-docs tool automatically recognizes the +optional marker comments in Go code and renders them as validation entries. A recent upstream change in github.com/elastic/crd-ref-docs master branch started rendering these as `Optional: {}` text in the validation column, which looks like an empty JSON object and is redundant since the Required column already shows this information. Update the documentation template to filter out these Optional markers while preserving meaningful validation rules like patterns and enums. Also remove the now-redundant customMarkers configuration, as the current version of crd-ref-docs recognizes the optional marker without explicit configuration. Closes #722 Signed-off-by: Marco Nenciarini --- hack/crd-gen-refs/config.yaml | 3 --- hack/crd-gen-refs/markdown/type.tpl | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/hack/crd-gen-refs/config.yaml b/hack/crd-gen-refs/config.yaml index 74b2051..c633246 100644 --- a/hack/crd-gen-refs/config.yaml +++ b/hack/crd-gen-refs/config.yaml @@ -1,9 +1,6 @@ processor: ignoreGroupVersions: - "GVK" - customMarkers: - - name: "optional" - target: field ignoreFields: # - "status$" - "TypeMeta$" diff --git a/hack/crd-gen-refs/markdown/type.tpl b/hack/crd-gen-refs/markdown/type.tpl index 525f7c1..db1648a 100644 --- a/hack/crd-gen-refs/markdown/type.tpl +++ b/hack/crd-gen-refs/markdown/type.tpl @@ -31,7 +31,7 @@ _Appears in:_ {{ end -}} {{ range $type.Members -}} -| `{{ .Name }}` _{{ markdownRenderType .Type }}_ | {{ template "type_members" . }} | {{ if not .Markers.optional -}}True{{- end }} | {{ markdownRenderDefault .Default }} | {{ range .Validation -}} {{ markdownRenderFieldDoc . }}
{{ end }} | +| `{{ .Name }}` _{{ markdownRenderType .Type }}_ | {{ template "type_members" . }} | {{ if not .Markers.optional -}}True{{- end }} | {{ markdownRenderDefault .Default }} | {{ range .Validation -}}{{- $v := markdownRenderFieldDoc . }}{{- if and $v (ne $v "Optional: {}") (ne $v "Optional: \\{\\}") -}} {{ $v }}
{{ end }}{{- end }} | {{ end -}} {{ end -}}