From 3b85307f67dc236acf7ccc218e147b3e0596277d Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 23 Feb 2025 08:33:23 +0100 Subject: [PATCH] Filter out [dev] comments when generating config doc --- docs/Config.md | 2 -- pkg/config/user_config.go | 4 ++-- pkg/jsonschema/generate_config_docs.go | 9 ++++++++- schema/config.json | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/Config.md b/docs/Config.md index 2e0f104d0..d27050da0 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -412,8 +412,6 @@ os: editAtLineAndWait: "" # Whether lazygit suspends until an edit process returns - # Pointer to bool so that we can distinguish unset (nil) from false. - # We're naming this `editInTerminal` for backwards compatibility editInTerminal: false # For opening a directory in an editor diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index d6a27733e..116f63487 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -557,8 +557,8 @@ type OSConfig struct { EditAtLineAndWait string `yaml:"editAtLineAndWait,omitempty"` // Whether lazygit suspends until an edit process returns - // Pointer to bool so that we can distinguish unset (nil) from false. - // We're naming this `editInTerminal` for backwards compatibility + // [dev] Pointer to bool so that we can distinguish unset (nil) from false. + // [dev] We're naming this `editInTerminal` for backwards compatibility SuspendOnEdit *bool `yaml:"editInTerminal,omitempty"` // For opening a directory in an editor diff --git a/pkg/jsonschema/generate_config_docs.go b/pkg/jsonschema/generate_config_docs.go index b5228c042..731cddea9 100644 --- a/pkg/jsonschema/generate_config_docs.go +++ b/pkg/jsonschema/generate_config_docs.go @@ -77,13 +77,20 @@ func prepareMarshalledConfig(buffer bytes.Buffer) []byte { } func setComment(yamlNode *yaml.Node, description string) { + // Filter out lines containing "[dev]"; this allows us to add developer + // documentation to properties that don't get included in the docs + lines := strings.Split(description, "\n") + lines = lo.Filter(lines, func(s string, _ int) bool { + return !strings.Contains(s, "[dev]") + }) + // Workaround for the way yaml formats the HeadComment if it contains // blank lines: it renders these without a leading "#", but we want a // leading "#" even on blank lines. However, yaml respects it if the // HeadComment already contains a leading "#", so we prefix all lines // (including blank ones) with "#". yamlNode.HeadComment = strings.Join( - lo.Map(strings.Split(description, "\n"), func(s string, _ int) string { + lo.Map(lines, func(s string, _ int) string { if s == "" { return "#" // avoid trailing space on blank lines } diff --git a/schema/config.json b/schema/config.json index 2af6ae595..276cba300 100644 --- a/schema/config.json +++ b/schema/config.json @@ -1468,7 +1468,7 @@ }, "editInTerminal": { "type": "boolean", - "description": "Whether lazygit suspends until an edit process returns\nPointer to bool so that we can distinguish unset (nil) from false.\nWe're naming this `editInTerminal` for backwards compatibility" + "description": "Whether lazygit suspends until an edit process returns\n[dev] Pointer to bool so that we can distinguish unset (nil) from false.\n[dev] We're naming this `editInTerminal` for backwards compatibility" }, "openDirInEditor": { "type": "string",