Filter out [dev] comments when generating config doc

This commit is contained in:
Stefan Haller 2025-02-23 08:33:23 +01:00
parent 30e9bf8a75
commit 3b85307f67
4 changed files with 11 additions and 6 deletions

View file

@ -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

View file

@ -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

View file

@ -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
}

View file

@ -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",