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

fix: parse one template file at once #276

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions pkg/document/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func getHelmDocsVersionTemplates() string {
return versionSectionBuilder.String()
}

func getDocumentationTemplate(chartDirectory string, chartSearchRoot string, templateFiles []string) (string, error) {
func getDocumentationTemplate(chartDirectory string, chartSearchRoot string, templateFiles []string) ([]string, error) {
templateFilesForChart := make([]string, 0)

var templateNotFound bool
Expand All @@ -383,20 +383,20 @@ func getDocumentationTemplate(chartDirectory string, chartSearchRoot string, tem
}

log.Debugf("Using template files %s for chart %s", templateFiles, chartDirectory)
allTemplateContents := make([]byte, 0)
allTemplateContents := make([]string, 0)
for _, templateFileForChart := range templateFilesForChart {
templateContents, err := ioutil.ReadFile(templateFileForChart)
if err != nil {
return "", err
}
allTemplateContents = append(allTemplateContents, templateContents...)
allTemplateContents = append(allTemplateContents, string(templateContents))
}

if templateNotFound {
allTemplateContents = append(allTemplateContents, []byte(defaultDocumentationTemplate)...)
}

return string(allTemplateContents), nil
return allTemplateContents, nil
}

func getDocumentationTemplates(chartDirectory string, chartSearchRoot string, templateFiles []string, badgeStyle string) ([]string, error) {
Expand All @@ -407,23 +407,24 @@ func getDocumentationTemplates(chartDirectory string, chartSearchRoot string, te
return nil, err
}

return []string{
getNameTemplate(),
getHeaderTemplate(),
getDeprecatedTemplate(),
getAppVersionTemplate(badgeStyle),
getBadgesTemplates(),
getDescriptionTemplate(),
getVersionTemplates(badgeStyle),
getTypeTemplate(badgeStyle),
getSourceLinkTemplates(),
getRequirementsTableTemplates(),
getValuesTableTemplates(),
getHomepageTemplate(),
getMaintainersTemplate(),
getHelmDocsVersionTemplates(),
documentationTemplate,
}, nil
return append([]string{
getNameTemplate(),
getHeaderTemplate(),
getDeprecatedTemplate(),
getAppVersionTemplate(badgeStyle),
getBadgesTemplates(),
getDescriptionTemplate(),
getVersionTemplates(badgeStyle),
getTypeTemplate(badgeStyle),
getSourceLinkTemplates(),
getRequirementsTableTemplates(),
getValuesTableTemplates(),
getHomepageTemplate(),
getMaintainersTemplate(),
getHelmDocsVersionTemplates(),
},
documentationTemplate...
), nil
}

func newChartDocumentationTemplate(chartDocumentationInfo helm.ChartDocumentationInfo, chartSearchRoot string, templateFiles []string, badgeStyle string) (*template.Template, error) {
Expand Down