Merge pull request #900 from saschagrunert/author-improvement
Improve docs generation for cli.Authors
This commit is contained in:
commit
47016a65eb
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
*.coverprofile
|
*.coverprofile
|
||||||
|
*.orig
|
||||||
node_modules/
|
node_modules/
|
||||||
vendor
|
vendor
|
18
docs_test.go
18
docs_test.go
@ -64,7 +64,10 @@ func testApp() *App {
|
|||||||
}}
|
}}
|
||||||
app.UsageText = "app [first_arg] [second_arg]"
|
app.UsageText = "app [first_arg] [second_arg]"
|
||||||
app.Usage = "Some app"
|
app.Usage = "Some app"
|
||||||
app.Authors = []*Author{{Name: "Harrison", Email: "harrison@lolwut.com"}}
|
app.Authors = []*Author{
|
||||||
|
{Name: "Harrison", Email: "harrison@lolwut.com"},
|
||||||
|
{Name: "Oliver Allen", Email: "oliver@toyshop.com"},
|
||||||
|
}
|
||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +115,19 @@ func TestToMarkdownNoCommands(t *testing.T) {
|
|||||||
expectFileContent(t, "testdata/expected-doc-no-commands.md", res)
|
expectFileContent(t, "testdata/expected-doc-no-commands.md", res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestToMarkdownNoAuthors(t *testing.T) {
|
||||||
|
// Given
|
||||||
|
app := testApp()
|
||||||
|
app.Authors = []*Author{}
|
||||||
|
|
||||||
|
// When
|
||||||
|
res, err := app.ToMarkdown()
|
||||||
|
|
||||||
|
// Then
|
||||||
|
expect(t, err, nil)
|
||||||
|
expectFileContent(t, "testdata/expected-doc-no-authors.md", res)
|
||||||
|
}
|
||||||
|
|
||||||
func TestToMan(t *testing.T) {
|
func TestToMan(t *testing.T) {
|
||||||
// Given
|
// Given
|
||||||
app := testApp()
|
app := testApp()
|
||||||
|
@ -71,10 +71,9 @@ OPTIONS:
|
|||||||
{{end}}{{end}}
|
{{end}}{{end}}
|
||||||
`
|
`
|
||||||
|
|
||||||
var MarkdownDocTemplate = `% {{ .App.Name }}(8) {{ .App.Description }}
|
var MarkdownDocTemplate = `% {{ .App.Name }}(8){{ if .App.Description }} {{ .App.Description }}{{ end }}
|
||||||
{{ range $Author := .App.Authors}}
|
{{ range $a := .App.Authors }}
|
||||||
% {{ $Author.Name }}
|
% {{ $a }}{{ end }}
|
||||||
{{- end}}
|
|
||||||
|
|
||||||
# NAME
|
# NAME
|
||||||
|
|
||||||
|
5
testdata/expected-doc-full.man
vendored
5
testdata/expected-doc-full.man
vendored
@ -1,7 +1,10 @@
|
|||||||
.nh
|
.nh
|
||||||
.TH greet(8)
|
.TH greet(8)
|
||||||
|
|
||||||
.SH Harrison
|
.SH Harrison harrison@lolwut.com
|
||||||
|
\[la]mailto:harrison@lolwut.com\[ra]
|
||||||
|
Oliver Allen oliver@toyshop.com
|
||||||
|
\[la]mailto:oliver@toyshop.com\[ra]
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.PP
|
.PP
|
||||||
|
3
testdata/expected-doc-full.md
vendored
3
testdata/expected-doc-full.md
vendored
@ -1,6 +1,7 @@
|
|||||||
% greet(8)
|
% greet(8)
|
||||||
|
|
||||||
% Harrison
|
% Harrison <harrison@lolwut.com>
|
||||||
|
% Oliver Allen <oliver@toyshop.com>
|
||||||
|
|
||||||
# NAME
|
# NAME
|
||||||
|
|
||||||
|
61
testdata/expected-doc-no-authors.md
vendored
Normal file
61
testdata/expected-doc-no-authors.md
vendored
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
% greet(8)
|
||||||
|
|
||||||
|
|
||||||
|
# NAME
|
||||||
|
|
||||||
|
greet - Some app
|
||||||
|
|
||||||
|
# SYNOPSIS
|
||||||
|
|
||||||
|
greet
|
||||||
|
|
||||||
|
```
|
||||||
|
[--another-flag|-b]
|
||||||
|
[--flag|--fl|-f]=[value]
|
||||||
|
[--socket|-s]=[value]
|
||||||
|
```
|
||||||
|
|
||||||
|
# DESCRIPTION
|
||||||
|
|
||||||
|
app [first_arg] [second_arg]
|
||||||
|
|
||||||
|
**Usage**:
|
||||||
|
|
||||||
|
```
|
||||||
|
greet [GLOBAL OPTIONS] command [COMMAND OPTIONS] [ARGUMENTS...]
|
||||||
|
```
|
||||||
|
|
||||||
|
# GLOBAL OPTIONS
|
||||||
|
|
||||||
|
**--another-flag, -b**: another usage text
|
||||||
|
|
||||||
|
**--flag, --fl, -f**="":
|
||||||
|
|
||||||
|
**--socket, -s**="": some 'usage' text (default: value)
|
||||||
|
|
||||||
|
|
||||||
|
# COMMANDS
|
||||||
|
|
||||||
|
## config, c
|
||||||
|
|
||||||
|
another usage test
|
||||||
|
|
||||||
|
**--another-flag, -b**: another usage text
|
||||||
|
|
||||||
|
**--flag, --fl, -f**="":
|
||||||
|
|
||||||
|
### sub-config, s, ss
|
||||||
|
|
||||||
|
another usage test
|
||||||
|
|
||||||
|
**--sub-command-flag, -s**: some usage text
|
||||||
|
|
||||||
|
**--sub-flag, --sub-fl, -s**="":
|
||||||
|
|
||||||
|
## info, i, in
|
||||||
|
|
||||||
|
retrieve generic information
|
||||||
|
|
||||||
|
## some-command
|
||||||
|
|
||||||
|
|
3
testdata/expected-doc-no-commands.md
vendored
3
testdata/expected-doc-no-commands.md
vendored
@ -1,6 +1,7 @@
|
|||||||
% greet(8)
|
% greet(8)
|
||||||
|
|
||||||
% Harrison
|
% Harrison <harrison@lolwut.com>
|
||||||
|
% Oliver Allen <oliver@toyshop.com>
|
||||||
|
|
||||||
# NAME
|
# NAME
|
||||||
|
|
||||||
|
3
testdata/expected-doc-no-flags.md
vendored
3
testdata/expected-doc-no-flags.md
vendored
@ -1,6 +1,7 @@
|
|||||||
% greet(8)
|
% greet(8)
|
||||||
|
|
||||||
% Harrison
|
% Harrison <harrison@lolwut.com>
|
||||||
|
% Oliver Allen <oliver@toyshop.com>
|
||||||
|
|
||||||
# NAME
|
# NAME
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user