mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
Filter out [dev] comments when generating config doc
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user