diff --git a/docs.go b/docs.go index 021cc2b..9f82fc6 100644 --- a/docs.go +++ b/docs.go @@ -15,7 +15,7 @@ import ( // The function errors if either parsing or writing of the string fails. func (a *App) ToMarkdown() (string, error) { var w bytes.Buffer - if err := a.writeDocTemplate(&w, 8); err != nil { + if err := a.writeDocTemplate(&w, 0); err != nil { return "", err } return w.String(), nil diff --git a/template.go b/template.go index 708a402..39fa4db 100644 --- a/template.go +++ b/template.go @@ -74,9 +74,9 @@ OPTIONS: {{end}}{{end}} ` -var MarkdownDocTemplate = `% {{ .App.Name }} {{ .SectionNum }} +var MarkdownDocTemplate = `{{if gt .SectionNum 0}}% {{ .App.Name }} {{ .SectionNum }} -# NAME +{{end}}# NAME {{ .App.Name }}{{ if .App.Usage }} - {{ .App.Usage }}{{ end }} diff --git a/testdata/expected-doc-full.md b/testdata/expected-doc-full.md index f3374e5..80ff6a7 100644 --- a/testdata/expected-doc-full.md +++ b/testdata/expected-doc-full.md @@ -1,5 +1,3 @@ -% greet 8 - # NAME greet - Some app diff --git a/testdata/expected-doc-no-authors.md b/testdata/expected-doc-no-authors.md index f3374e5..80ff6a7 100644 --- a/testdata/expected-doc-no-authors.md +++ b/testdata/expected-doc-no-authors.md @@ -1,5 +1,3 @@ -% greet 8 - # NAME greet - Some app diff --git a/testdata/expected-doc-no-commands.md b/testdata/expected-doc-no-commands.md index 1c4fd07..4db2a37 100644 --- a/testdata/expected-doc-no-commands.md +++ b/testdata/expected-doc-no-commands.md @@ -1,5 +1,3 @@ -% greet 8 - # NAME greet - Some app diff --git a/testdata/expected-doc-no-flags.md b/testdata/expected-doc-no-flags.md index cf766ad..33d1275 100644 --- a/testdata/expected-doc-no-flags.md +++ b/testdata/expected-doc-no-flags.md @@ -1,5 +1,3 @@ -% greet 8 - # NAME greet - Some app diff --git a/testdata/expected-doc-no-usagetext.md b/testdata/expected-doc-no-usagetext.md index da31b38..d09b69f 100644 --- a/testdata/expected-doc-no-usagetext.md +++ b/testdata/expected-doc-no-usagetext.md @@ -1,5 +1,3 @@ -% greet 8 - # NAME greet - Some app