Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add badges section #75

Merged
merged 3 commits into from Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
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
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
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
@@ -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