diff --git a/README.md b/README.md index 233b081..1e43538 100644 --- a/README.md +++ b/README.md @@ -177,7 +177,7 @@ The default internal template mentioned above uses many of these and looks like {{ template "chart.header" . }} {{ template "chart.deprecationWarning" . }} -{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }} +{{ template "chart.badgesSection" . }} {{ template "chart.description" . }} diff --git a/example-charts/full-template/README.md b/example-charts/full-template/README.md index 4f33df8..8d2699a 100644 --- a/example-charts/full-template/README.md +++ b/example-charts/full-template/README.md @@ -50,6 +50,10 @@ application ![AppVersion: 13.0.0](https://img.shields.io/badge/AppVersion-13.0.0-informational?style=flat-square) +## `chart.badgesSection` + +![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 13.0.0](https://img.shields.io/badge/AppVersion-13.0.0-informational?style=flat-square) + ## `chart.homepage` https://github.com/norwoodj/helm-docs/tree/master/example-charts/full-template diff --git a/example-charts/full-template/README.md.gotmpl b/example-charts/full-template/README.md.gotmpl index a01c2f9..b5b7d92 100644 --- a/example-charts/full-template/README.md.gotmpl +++ b/example-charts/full-template/README.md.gotmpl @@ -40,6 +40,10 @@ {{ template "chart.appVersionBadge" . }} +## `chart.badgesSection` + +{{ template "chart.badgesSection" . }} + ## `chart.homepage` {{ template "chart.homepage" . }} diff --git a/pkg/document/template.go b/pkg/document/template.go index 5bebe67..392e6b7 100644 --- a/pkg/document/template.go +++ b/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" @@ -17,7 +18,7 @@ import ( const defaultDocumentationTemplate = `{{ template "chart.header" . }} {{ template "chart.deprecationWarning" . }} -{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }} +{{ template "chart.badgesSection" . }} {{ template "chart.description" . }} @@ -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" }}`) @@ -271,6 +281,7 @@ func getDocumentationTemplates(chartDirectory string, chartSearchRoot string, te getHeaderTemplate(), getDeprecatedTemplate(), getAppVersionTemplate(), + getBadgesTemplates(), getDescriptionTemplate(), getVersionTemplates(), getTypeTemplate(),