From 34cecb04469b009ee9268b2ea97377631e849ea7 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 v0.3.0 introduced a change that started rendering `+optional` Go code markers as `Optional: {}` in the validation column of API documentation. This appeared as an empty JSON object and was redundant since the Required column already displayed this information. This updates the documentation template to filter out these Optional markers while preserving meaningful validation rules like patterns and enums. It also removes redundant customMarkers configuration. Closes #722 Signed-off-by: Marco Nenciarini --- Taskfile.yml | 2 +- hack/crd-gen-refs/config.yaml | 3 --- hack/crd-gen-refs/markdown/type.tpl | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 3d19578..dff6c90 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -86,7 +86,7 @@ tasks: # renovate: datasource=git-refs depName=crd-gen-refs lookupName=https://github.com/cloudnative-pg/daggerverse currentValue=main DAGGER_CRDGENREF_SHA: ee59e34a99940e45f87a16177b1d640975b05b74 # renovate: datasource=go depName=github.com/elastic/crd-ref-docs - CRDREFDOCS_VERSION: v0.2.0 + CRDREFDOCS_VERSION: v0.3.0 cmds: - > GITHUB_REF= dagger -s call -m github.com/cloudnative-pg/daggerverse/crd-ref-docs@${DAGGER_CRDGENREF_SHA} 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..fc42594 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: \\{\\}") -}} {{ $v }}
{{ end }}{{- end }} | {{ end -}} {{ end -}}