Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switch to cli-docs-tool for yaml docs generation
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com> switch to cli-docs-tool and validate yamldocs Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
- Loading branch information
Showing
16 changed files
with
162 additions
and
683 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/vendor | ||
/yaml | ||
/go.sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// This file is intended for use with "go run"; it isn't really part of the package. | ||
|
||
// +build docsgen | ||
|
||
package main | ||
|
||
import ( | ||
"log" | ||
"os" | ||
|
||
clidocstool "github.com/docker/cli-docs-tool" | ||
"github.com/docker/cli/cli/command" | ||
"github.com/docker/cli/cli/command/commands" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/pflag" | ||
) | ||
|
||
const defaultSourcePath = "docs/reference/commandline/" | ||
|
||
type options struct { | ||
source string | ||
target string | ||
} | ||
|
||
func gen(opts *options) error { | ||
log.SetFlags(0) | ||
|
||
dockerCLI, err := command.NewDockerCli() | ||
if err != nil { | ||
return err | ||
} | ||
cmd := &cobra.Command{ | ||
Use: "docker [OPTIONS] COMMAND [ARG...]", | ||
Short: "The base command for the Docker CLI.", | ||
} | ||
commands.AddCommands(cmd, dockerCLI) | ||
|
||
c, err := clidocstool.New(clidocstool.Options{ | ||
Root: cmd, | ||
SourceDir: opts.source, | ||
TargetDir: opts.target, | ||
Plugin: false, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return c.GenYamlTree(cmd) | ||
} | ||
|
||
func run() error { | ||
opts := &options{} | ||
flags := pflag.NewFlagSet(os.Args[0], pflag.ContinueOnError) | ||
flags.StringVar(&opts.source, "source", defaultSourcePath, "Docs source folder") | ||
flags.StringVar(&opts.target, "target", defaultSourcePath, "Docs target folder") | ||
if err := flags.Parse(os.Args[1:]); err != nil { | ||
return err | ||
} | ||
return gen(opts) | ||
} | ||
|
||
func main() { | ||
if err := run(); err != nil { | ||
log.Printf("ERROR: %+v", err) | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module github.com/docker/cli/docs | ||
|
||
// dummy go.mod to avoid dealing with dependencies specific | ||
// to docs generation and not really part of the project. | ||
|
||
go 1.16 | ||
|
||
//require ( | ||
// github.com/docker/cli v0.0.0+incompatible | ||
// github.com/docker/cli-docs-tool v0.3.0 | ||
//) | ||
// | ||
//replace github.com/docker/cli v0.0.0+incompatible => ../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// +build tools | ||
|
||
package main | ||
|
||
import ( | ||
_ "github.com/docker/cli-docs-tool" | ||
) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.