Browse Source

Remove From

Signed-off-by: jolheiser <john.olheiser@gmail.com>
main v0.0.2
jolheiser 1 month ago
parent
commit
da2620a37f
Signed by: jolheiser GPG Key ID: B853ADA5DA7BBF7A
  1. 33
      README.md
  2. 2
      examples/flagset/main.go
  3. 2
      examples/multiple/main.go
  4. 2
      examples/single/main.go
  5. 8
      ffmd.go

33
README.md

@ -9,6 +9,39 @@ With `ffmd` you can generate markdown docs for both `flag.FlagSet` and `ffcli.Co
Check out [examples](examples) for some sample generated docs.
## Generate your docs
```go
//go:build generate
// +build generate
package main
import (
"os"
"go.jolheiser.com/ffmd"
)
func main() {
fi, err := os.Create("docs.md")
if err != nil {
panic(err)
}
defer fi.Close()
// cmd is the ffcli.Command
md, err := ffmd.Command(cmd)
if err != nil {
panic(err)
}
if _, err := fi.WriteString(md); err != nil {
panic(err)
}
}
```
## License

2
examples/flagset/main.go

@ -23,7 +23,7 @@ func main() {
fs.Duration("duration-flag", 0, "Duration flag with no default")
fs.Duration("duration-flag-default", time.Minute*5, "Duration flag with default")
md, err := ffmd.FromFlagSet(fs)
md, err := ffmd.FlagSet(fs)
if err != nil {
panic(err)
}

2
examples/multiple/main.go

@ -62,7 +62,7 @@ func main() {
cmd2.Subcommands = []*ffcli.Command{cmd3, cmd5}
cmd3.Subcommands = []*ffcli.Command{cmd4}
md, err := ffmd.FromCommand(cmd)
md, err := ffmd.Command(cmd)
if err != nil {
panic(err)
}

2
examples/single/main.go

@ -31,7 +31,7 @@ func main() {
Subcommands: nil,
}
md, err := ffmd.FromCommand(cmd)
md, err := ffmd.Command(cmd)
if err != nil {
panic(err)
}

8
ffmd.go

@ -19,13 +19,13 @@ var (
Template = template.Must(template.New("").Parse(ffmdtmpl))
)
// FromCommand turns a ffcli.Command into markdown
func FromCommand(cmd *ffcli.Command) (string, error) {
// Command turns a ffcli.Command into markdown
func Command(cmd *ffcli.Command) (string, error) {
return fromCommand(cmd, 1)
}
// FromFlagSet turns a flag.FlagSet into markdown
func FromFlagSet(fs *flag.FlagSet) (string, error) {
// FlagSet turns a flag.FlagSet into markdown
func FlagSet(fs *flag.FlagSet) (string, error) {
return flagSetCommand(fs, 2).Markdown()
}

Loading…
Cancel
Save