Skip to content

Commit

Permalink
Merge pull request #75 from sagikazarmark/add-badges-section
Browse files Browse the repository at this point in the history
Add badges section
  • Loading branch information
norwoodj authored Jan 12, 2021
2 parents 7c4ae94 + e8bea34 commit 81bf0c9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" . }}
Expand Down
4 changes: 4 additions & 0 deletions example-charts/full-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions example-charts/full-template/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@

{{ template "chart.appVersionBadge" . }}

## `chart.badgesSection`

{{ template "chart.badgesSection" . }}

## `chart.homepage`

{{ template "chart.homepage" . }}
Expand Down
15 changes: 13 additions & 2 deletions pkg/document/template.go
Original file line number Diff line number Diff line change
@@ -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 All @@ -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" . }}
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 81bf0c9

Please sign in to comment.