Remove YAML docs from the repo

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax
2021-09-09 10:29:08 +02:00
parent ac9a1612d2
commit e59aecf034
23 changed files with 77 additions and 2539 deletions

View File

@ -8,19 +8,25 @@ import (
"github.com/docker/buildx/commands"
clidocstool "github.com/docker/cli-docs-tool"
"github.com/docker/cli/cli/command"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
const sourcePath = "docs/reference/"
const defaultSourcePath = "docs/reference/"
func main() {
type options struct {
source string
formats []string
}
func gen(opts *options) error {
log.SetFlags(0)
dockerCLI, err := command.NewDockerCli()
if err != nil {
log.Printf("ERROR: %+v", err)
return err
}
cmd := &cobra.Command{
Use: "docker [OPTIONS] COMMAND [ARG...]",
Short: "The base command for the Docker CLI.",
@ -31,12 +37,47 @@ func main() {
clidocstool.DisableFlagsInUseLine(cmd)
cwd, _ := os.Getwd()
source := filepath.Join(cwd, sourcePath)
source := filepath.Join(cwd, opts.source)
if err = os.MkdirAll(source, 0755); err != nil {
log.Printf("ERROR: %+v", err)
return err
}
if err = clidocstool.GenTree(cmd, source); err != nil {
for _, format := range opts.formats {
switch format {
case "md":
if err = clidocstool.GenMarkdownTree(cmd, source); err != nil {
return err
}
case "yaml":
if err = clidocstool.GenYamlTree(cmd, source); err != nil {
return err
}
default:
return errors.Errorf("unknwown doc format %q", format)
}
}
return nil
}
func run() error {
opts := &options{}
flags := pflag.NewFlagSet(os.Args[0], pflag.ContinueOnError)
flags.StringVar(&opts.source, "source", defaultSourcePath, "Docs source folder")
flags.StringSliceVar(&opts.formats, "formats", []string{}, "Format (md, yaml)")
if err := flags.Parse(os.Args[1:]); err != nil {
return err
}
if len(opts.formats) == 0 {
return errors.New("Docs format required")
}
return gen(opts)
}
func main() {
if err := run(); err != nil {
log.Printf("ERROR: %+v", err)
os.Exit(1)
}
}