Skip to content
Myr

YAML documentation contains "Usage" (#1037)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Alessandro (Ale) Segala · committed by GitHub · parent 1d3ac91 · Browse files · 2 files+16 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+16 added−0 removed

  • other:+16 added−0 removed

2 files+16 added−0 removed

modified:doc/yaml_docs_test.go+11 added
55 unmodified lines
56 t.Fatalf("Expected file 'do.yaml' to exist")57 }58}5960func TestGenYamlDocRunnable(t *testing.T) {61 // Testing a runnable command: should contain the "usage" field62 buf := new(bytes.Buffer)63 if err := GenYaml(rootCmd, buf); err != nil {64 t.Fatal(err)65 }66 output := buf.String()6768 checkStringContains(t, output, "usage: "+rootCmd.Use)69}7071func BenchmarkGenYamlToFile(b *testing.B) {72 file, err := ioutil.TempFile("", "")73 if err != nil {74 b.Fatal(err)
11 unmodified lines
modified:doc/yaml_docs.go+5 added
35 unmodified lines
36type cmdDoc struct {37 Name string38 Synopsis string `yaml:",omitempty"`39 Description string `yaml:",omitempty"`40 Usage string `yaml:",omitempty"`41 Options []cmdOption `yaml:",omitempty"`42 InheritedOptions []cmdOption `yaml:"inherited_options,omitempty"`43 Example string `yaml:",omitempty"`44 SeeAlso []string `yaml:"see_also,omitempty"`
53 unmodified lines
9899 yamlDoc.Synopsis = forceMultiLine(cmd.Short)100 yamlDoc.Description = forceMultiLine(cmd.Long)101102 if cmd.Runnable() {103 yamlDoc.Usage = cmd.UseLine()104 }105106 if len(cmd.Example) > 0 {107 yamlDoc.Example = cmd.Example108 }109
65 unmodified lines