From c7c572845ae54a959c91c61b116dd4971a4dcf9a Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 26 Mar 2025 18:52:34 +0100 Subject: [PATCH] docs: improve version documentation --- .golangci.next.reference.yml | 2 ++ .golangci.reference.yml | 2 ++ docs/src/docs/usage/configuration.mdx | 8 -------- scripts/website/expand_templates/linters.go | 19 +++++++++++++------ 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 47ab27b30c3b..81d741134a69 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -4,6 +4,8 @@ # This file is not a configuration example, # it contains the exhaustive configuration with explanations of the options. +# Defines the configuration version. +# The only possible value is "2". version: "2" linters: diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 47ab27b30c3b..81d741134a69 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -4,6 +4,8 @@ # This file is not a configuration example, # it contains the exhaustive configuration with explanations of the options. +# Defines the configuration version. +# The only possible value is "2". version: "2" linters: diff --git a/docs/src/docs/usage/configuration.mdx b/docs/src/docs/usage/configuration.mdx index fbc4b889b704..276480ad7d7c 100644 --- a/docs/src/docs/usage/configuration.mdx +++ b/docs/src/docs/usage/configuration.mdx @@ -42,14 +42,6 @@ The configuration file can be validated with the JSON Schema: https://golangci-l { .ConfigurationExample } -### `version` configuration - -```yaml -# Defines the configuration version. -# The only possible value is "2". -version: "2" -``` - ## Command-Line Options ### run diff --git a/scripts/website/expand_templates/linters.go b/scripts/website/expand_templates/linters.go index 87a386e4ace0..a6c0183863ce 100644 --- a/scripts/website/expand_templates/linters.go +++ b/scripts/website/expand_templates/linters.go @@ -206,8 +206,7 @@ type ExampleSnippetsExtractor struct { func NewExampleSnippetsExtractor() *ExampleSnippetsExtractor { return &ExampleSnippetsExtractor{ - // TODO(ldez) replace .golangci.next.reference.yml by .golangci.reference.yml - referencePath: ".golangci.next.reference.yml", + referencePath: ".golangci.reference.yml", assetsPath: "assets", } } @@ -281,11 +280,19 @@ func (e *ExampleSnippetsExtractor) extractExampleSnippets(example []byte) (*Sett } if node.Value == "version" { - node.HeadComment = `See the dedicated "version" documentation section.` - newNode = nextNode - } + n := &yaml.Node{ + HeadComment: fmt.Sprintf("See the dedicated %q documentation section.", node.Value), + Kind: node.Kind, + Style: node.Style, + Tag: node.Tag, + Value: node.Value, + Content: node.Content, + } - globalNode.Content = append(globalNode.Content, node, newNode) + globalNode.Content = append(globalNode.Content, n, nextNode) + } else { + globalNode.Content = append(globalNode.Content, node, newNode) + } if node.Value == keyLinters || node.Value == keyFormatters { for i := 0; i < len(nextNode.Content); i++ {