Skip to content

Commit

Permalink
Add badgesSection template
Browse files Browse the repository at this point in the history
When using custom templates, it's often useful to define a custom
list of badges and use that everywhere.

For example: I usually add a kubeVersion and an artifact hub badge as
well.

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
  • Loading branch information
sagikazarmark committed Jan 12, 2021
1 parent 7c4ae94 commit 6f79fac
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/document/template.go
@@ -1,13 +1,14 @@
package document

import (
"github.com/norwoodj/helm-docs/pkg/util"
"io/ioutil"
"os"
"path"
"strings"
"text/template"

"github.com/norwoodj/helm-docs/pkg/util"

"github.com/Masterminds/sprig"
log "github.com/sirupsen/logrus"

Expand Down Expand Up @@ -91,6 +92,15 @@ func getAppVersionTemplate() string {
return appVersionBuilder.String()
}

func getBadgesTemplates() string {
badgeBuilder := strings.Builder{}
badgeBuilder.WriteString(`{{ define "chart.badgesSection" }}`)
badgeBuilder.WriteString(`{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }}`)
badgeBuilder.WriteString("{{ end }}")

return badgeBuilder.String()
}

func getDescriptionTemplate() string {
descriptionBuilder := strings.Builder{}
descriptionBuilder.WriteString(`{{ define "chart.description" }}`)
Expand Down Expand Up @@ -271,6 +281,7 @@ func getDocumentationTemplates(chartDirectory string, chartSearchRoot string, te
getHeaderTemplate(),
getDeprecatedTemplate(),
getAppVersionTemplate(),
getBadgesTemplates(),
getDescriptionTemplate(),
getVersionTemplates(),
getTypeTemplate(),
Expand Down

0 comments on commit 6f79fac

Please sign in to comment.