From 9867ca279a407e0466aa74dcdb8b4c7ec4eaed1a Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Fri, 25 Feb 2022 15:41:12 +0100 Subject: [PATCH] docs: update cli-docs-tool to v0.4.0 Signed-off-by: CrazyMax --- docs/reference/buildx.md | 6 +- docs/reference/buildx_bake.md | 24 ++++---- docs/reference/buildx_build.md | 60 +++++++++---------- docs/reference/buildx_create.md | 26 ++++---- docs/reference/buildx_du.md | 10 ++-- docs/reference/buildx_imagetools.md | 6 +- docs/reference/buildx_imagetools_create.md | 14 ++--- docs/reference/buildx_imagetools_inspect.md | 8 +-- docs/reference/buildx_inspect.md | 8 +-- docs/reference/buildx_prune.md | 16 ++--- docs/reference/buildx_rm.md | 14 ++--- docs/reference/buildx_stop.md | 6 +- docs/reference/buildx_use.md | 10 ++-- go.mod | 2 +- go.sum | 4 +- .../cli-docs-tool/annotation/annotation.go | 2 + .../docker/cli-docs-tool/clidocstool_md.go | 35 +++++++---- .../docker/cli-docs-tool/clidocstool_yaml.go | 27 ++++++--- vendor/modules.txt | 2 +- 19 files changed, 153 insertions(+), 127 deletions(-) diff --git a/docs/reference/buildx.md b/docs/reference/buildx.md index 1b385012..48acfad8 100644 --- a/docs/reference/buildx.md +++ b/docs/reference/buildx.md @@ -29,9 +29,9 @@ Extended build capabilities with BuildKit ### Options -| Name | Description | -| --- | --- | -| [`--builder string`](#builder) | Override the configured builder instance | +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| [`--builder`](#builder) | `string` | | Override the configured builder instance | diff --git a/docs/reference/buildx_bake.md b/docs/reference/buildx_bake.md index f99c3e17..2eef58fd 100644 --- a/docs/reference/buildx_bake.md +++ b/docs/reference/buildx_bake.md @@ -13,18 +13,18 @@ Build from a file ### Options -| Name | Description | -| --- | --- | -| [`--builder string`](#builder) | Override the configured builder instance | -| [`-f`](#file), [`--file stringArray`](#file) | Build definition file | -| `--load` | Shorthand for `--set=*.output=type=docker` | -| `--metadata-file string` | Write build result metadata to the file | -| [`--no-cache`](#no-cache) | Do not use cache when building the image | -| [`--print`](#print) | Print the options without building | -| [`--progress string`](#progress) | Set type of progress output (`auto`, `plain`, `tty`). Use plain to show container output | -| [`--pull`](#pull) | Always attempt to pull a newer version of the image | -| `--push` | Shorthand for `--set=*.output=type=registry` | -| [`--set stringArray`](#set) | Override target value (e.g., `targetpattern.key=value`) | +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| [`--builder`](#builder) | `string` | | Override the configured builder instance | +| [`-f`](#file), [`--file`](#file) | `stringArray` | | Build definition file | +| `--load` | | | Shorthand for `--set=*.output=type=docker` | +| `--metadata-file` | `string` | | Write build result metadata to the file | +| [`--no-cache`](#no-cache) | | | Do not use cache when building the image | +| [`--print`](#print) | | | Print the options without building | +| [`--progress`](#progress) | `string` | `auto` | Set type of progress output (`auto`, `plain`, `tty`). Use plain to show container output | +| [`--pull`](#pull) | | | Always attempt to pull a newer version of the image | +| `--push` | | | Shorthand for `--set=*.output=type=registry` | +| [`--set`](#set) | `stringArray` | | Override target value (e.g., `targetpattern.key=value`) | diff --git a/docs/reference/buildx_build.md b/docs/reference/buildx_build.md index 607cdf8c..2a8339d3 100644 --- a/docs/reference/buildx_build.md +++ b/docs/reference/buildx_build.md @@ -13,36 +13,36 @@ Start a build ### Options -| Name | Description | -| --- | --- | -| [`--add-host stringSlice`](https://docs.docker.com/engine/reference/commandline/build/#add-entries-to-container-hosts-file---add-host) | Add a custom host-to-IP mapping (format: `host:ip`) | -| [`--allow stringSlice`](#allow) | Allow extra privileged entitlement (e.g., `network.host`, `security.insecure`) | -| [`--build-arg stringArray`](#build-arg) | Set build-time variables | -| [`--build-context stringArray`](#build-context) | Additional build contexts (e.g., name=path) | -| [`--builder string`](#builder) | Override the configured builder instance | -| [`--cache-from stringArray`](#cache-from) | External cache sources (e.g., `user/app:cache`, `type=local,src=path/to/dir`) | -| [`--cache-to stringArray`](#cache-to) | Cache export destinations (e.g., `user/app:cache`, `type=local,dest=path/to/dir`) | -| [`--cgroup-parent string`](https://docs.docker.com/engine/reference/commandline/build/#use-a-custom-parent-cgroup---cgroup-parent) | Optional parent cgroup for the container | -| [`-f`](https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f), [`--file string`](https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f) | Name of the Dockerfile (default: `PATH/Dockerfile`) | -| `--iidfile string` | Write the image ID to the file | -| `--label stringArray` | Set metadata for an image | -| [`--load`](#load) | Shorthand for `--output=type=docker` | -| [`--metadata-file string`](#metadata-file) | Write build result metadata to the file | -| `--network string` | Set the networking mode for the `RUN` instructions during build | -| `--no-cache` | Do not use cache when building the image | -| `--no-cache-filter stringArray` | Do not cache specified stages | -| [`-o`](#output), [`--output stringArray`](#output) | Output destination (format: `type=local,dest=path`) | -| [`--platform stringArray`](#platform) | Set target platform for build | -| [`--progress string`](#progress) | Set type of progress output (`auto`, `plain`, `tty`). Use plain to show container output | -| `--pull` | Always attempt to pull a newer version of the image | -| [`--push`](#push) | Shorthand for `--output=type=registry` | -| `-q`, `--quiet` | Suppress the build output and print image ID on success | -| [`--secret stringArray`](#secret) | Secret to expose to the build (format: `id=mysecret[,src=/local/secret]`) | -| [`--shm-size bytes`](#shm-size) | Size of `/dev/shm` | -| [`--ssh stringArray`](#ssh) | SSH agent socket or keys to expose to the build (format: `default\|[=\|[,]]`) | -| [`-t`](https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t), [`--tag stringArray`](https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t) | Name and optionally a tag (format: `name:tag`) | -| [`--target string`](https://docs.docker.com/engine/reference/commandline/build/#specifying-target-build-stage---target) | Set the target build stage to build | -| [`--ulimit ulimit`](#ulimit) | Ulimit options | +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| [`--add-host`](https://docs.docker.com/engine/reference/commandline/build/#add-entries-to-container-hosts-file---add-host) | `stringSlice` | | Add a custom host-to-IP mapping (format: `host:ip`) | +| [`--allow`](#allow) | `stringSlice` | | Allow extra privileged entitlement (e.g., `network.host`, `security.insecure`) | +| [`--build-arg`](#build-arg) | `stringArray` | | Set build-time variables | +| [`--build-context`](#build-context) | `stringArray` | | Additional build contexts (e.g., name=path) | +| [`--builder`](#builder) | `string` | | Override the configured builder instance | +| [`--cache-from`](#cache-from) | `stringArray` | | External cache sources (e.g., `user/app:cache`, `type=local,src=path/to/dir`) | +| [`--cache-to`](#cache-to) | `stringArray` | | Cache export destinations (e.g., `user/app:cache`, `type=local,dest=path/to/dir`) | +| [`--cgroup-parent`](https://docs.docker.com/engine/reference/commandline/build/#use-a-custom-parent-cgroup---cgroup-parent) | `string` | | Optional parent cgroup for the container | +| [`-f`](https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f), [`--file`](https://docs.docker.com/engine/reference/commandline/build/#specify-a-dockerfile--f) | `string` | | Name of the Dockerfile (default: `PATH/Dockerfile`) | +| `--iidfile` | `string` | | Write the image ID to the file | +| `--label` | `stringArray` | | Set metadata for an image | +| [`--load`](#load) | | | Shorthand for `--output=type=docker` | +| [`--metadata-file`](#metadata-file) | `string` | | Write build result metadata to the file | +| `--network` | `string` | `default` | Set the networking mode for the `RUN` instructions during build | +| `--no-cache` | | | Do not use cache when building the image | +| `--no-cache-filter` | `stringArray` | | Do not cache specified stages | +| [`-o`](#output), [`--output`](#output) | `stringArray` | | Output destination (format: `type=local,dest=path`) | +| [`--platform`](#platform) | `stringArray` | | Set target platform for build | +| [`--progress`](#progress) | `string` | `auto` | Set type of progress output (`auto`, `plain`, `tty`). Use plain to show container output | +| `--pull` | | | Always attempt to pull a newer version of the image | +| [`--push`](#push) | | | Shorthand for `--output=type=registry` | +| `-q`, `--quiet` | | | Suppress the build output and print image ID on success | +| [`--secret`](#secret) | `stringArray` | | Secret to expose to the build (format: `id=mysecret[,src=/local/secret]`) | +| [`--shm-size`](#shm-size) | `bytes` | `0` | Size of `/dev/shm` | +| [`--ssh`](#ssh) | `stringArray` | | SSH agent socket or keys to expose to the build (format: `default\|[=\|[,]]`) | +| [`-t`](https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t), [`--tag`](https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t) | `stringArray` | | Name and optionally a tag (format: `name:tag`) | +| [`--target`](https://docs.docker.com/engine/reference/commandline/build/#specifying-target-build-stage---target) | `string` | | Set the target build stage to build | +| [`--ulimit`](#ulimit) | `ulimit` | | Ulimit options | diff --git a/docs/reference/buildx_create.md b/docs/reference/buildx_create.md index 4adece33..2fde9af7 100644 --- a/docs/reference/buildx_create.md +++ b/docs/reference/buildx_create.md @@ -9,19 +9,19 @@ Create a new builder instance ### Options -| Name | Description | -| --- | --- | -| [`--append`](#append) | Append a node to builder instead of changing it | -| `--bootstrap` | Boot builder after creation | -| [`--buildkitd-flags string`](#buildkitd-flags) | Flags for buildkitd daemon | -| [`--config string`](#config) | BuildKit config file | -| [`--driver string`](#driver) | Driver to use (available: `docker`, `docker-container`, `kubernetes`) | -| [`--driver-opt stringArray`](#driver-opt) | Options for the driver | -| [`--leave`](#leave) | Remove a node from builder instead of changing it | -| [`--name string`](#name) | Builder instance name | -| [`--node string`](#node) | Create/modify node with given name | -| [`--platform stringArray`](#platform) | Fixed platforms for current node | -| [`--use`](#use) | Set the current builder instance | +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| [`--append`](#append) | | | Append a node to builder instead of changing it | +| `--bootstrap` | | | Boot builder after creation | +| [`--buildkitd-flags`](#buildkitd-flags) | `string` | | Flags for buildkitd daemon | +| [`--config`](#config) | `string` | | BuildKit config file | +| [`--driver`](#driver) | `string` | | Driver to use (available: `docker`, `docker-container`, `kubernetes`) | +| [`--driver-opt`](#driver-opt) | `stringArray` | | Options for the driver | +| [`--leave`](#leave) | | | Remove a node from builder instead of changing it | +| [`--name`](#name) | `string` | | Builder instance name | +| [`--node`](#node) | `string` | | Create/modify node with given name | +| [`--platform`](#platform) | `stringArray` | | Fixed platforms for current node | +| [`--use`](#use) | | | Set the current builder instance | diff --git a/docs/reference/buildx_du.md b/docs/reference/buildx_du.md index e44ce199..ecb9af13 100644 --- a/docs/reference/buildx_du.md +++ b/docs/reference/buildx_du.md @@ -9,11 +9,11 @@ Disk usage ### Options -| Name | Description | -| --- | --- | -| [`--builder string`](#builder) | Override the configured builder instance | -| `--filter filter` | Provide filter values | -| `--verbose` | Provide a more verbose output | +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| [`--builder`](#builder) | `string` | | Override the configured builder instance | +| `--filter` | `filter` | | Provide filter values | +| `--verbose` | | | Provide a more verbose output | diff --git a/docs/reference/buildx_imagetools.md b/docs/reference/buildx_imagetools.md index e7992ff8..4dab8b8c 100644 --- a/docs/reference/buildx_imagetools.md +++ b/docs/reference/buildx_imagetools.md @@ -17,9 +17,9 @@ Commands to work on images in registry ### Options -| Name | Description | -| --- | --- | -| [`--builder string`](#builder) | Override the configured builder instance | +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| [`--builder`](#builder) | `string` | | Override the configured builder instance | diff --git a/docs/reference/buildx_imagetools_create.md b/docs/reference/buildx_imagetools_create.md index 0b076eb5..8ede3c6a 100644 --- a/docs/reference/buildx_imagetools_create.md +++ b/docs/reference/buildx_imagetools_create.md @@ -9,13 +9,13 @@ Create a new image based on source images ### Options -| Name | Description | -| --- | --- | -| [`--append`](#append) | Append to existing manifest | -| [`--builder string`](#builder) | Override the configured builder instance | -| [`--dry-run`](#dry-run) | Show final image instead of pushing | -| [`-f`](#file), [`--file stringArray`](#file) | Read source descriptor from file | -| [`-t`](#tag), [`--tag stringArray`](#tag) | Set reference for new image | +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| [`--append`](#append) | | | Append to existing manifest | +| [`--builder`](#builder) | `string` | | Override the configured builder instance | +| [`--dry-run`](#dry-run) | | | Show final image instead of pushing | +| [`-f`](#file), [`--file`](#file) | `stringArray` | | Read source descriptor from file | +| [`-t`](#tag), [`--tag`](#tag) | `stringArray` | | Set reference for new image | diff --git a/docs/reference/buildx_imagetools_inspect.md b/docs/reference/buildx_imagetools_inspect.md index 0b913029..0d68b196 100644 --- a/docs/reference/buildx_imagetools_inspect.md +++ b/docs/reference/buildx_imagetools_inspect.md @@ -9,10 +9,10 @@ Show details of image in the registry ### Options -| Name | Description | -| --- | --- | -| [`--builder string`](#builder) | Override the configured builder instance | -| [`--raw`](#raw) | Show original JSON manifest | +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| [`--builder`](#builder) | `string` | | Override the configured builder instance | +| [`--raw`](#raw) | | | Show original JSON manifest | diff --git a/docs/reference/buildx_inspect.md b/docs/reference/buildx_inspect.md index b659bd91..f2fedefe 100644 --- a/docs/reference/buildx_inspect.md +++ b/docs/reference/buildx_inspect.md @@ -9,10 +9,10 @@ Inspect current builder instance ### Options -| Name | Description | -| --- | --- | -| [`--bootstrap`](#bootstrap) | Ensure builder has booted before inspecting | -| [`--builder string`](#builder) | Override the configured builder instance | +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| [`--bootstrap`](#bootstrap) | | | Ensure builder has booted before inspecting | +| [`--builder`](#builder) | `string` | | Override the configured builder instance | diff --git a/docs/reference/buildx_prune.md b/docs/reference/buildx_prune.md index 67a6d8c2..c547ef1a 100644 --- a/docs/reference/buildx_prune.md +++ b/docs/reference/buildx_prune.md @@ -9,14 +9,14 @@ Remove build cache ### Options -| Name | Description | -| --- | --- | -| `-a`, `--all` | Remove all unused images, not just dangling ones | -| [`--builder string`](#builder) | Override the configured builder instance | -| `--filter filter` | Provide filter values (e.g., `until=24h`) | -| `-f`, `--force` | Do not prompt for confirmation | -| `--keep-storage bytes` | Amount of disk space to keep for cache | -| `--verbose` | Provide a more verbose output | +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| `-a`, `--all` | | | Remove all unused images, not just dangling ones | +| [`--builder`](#builder) | `string` | | Override the configured builder instance | +| `--filter` | `filter` | | Provide filter values (e.g., `until=24h`) | +| `-f`, `--force` | | | Do not prompt for confirmation | +| `--keep-storage` | `bytes` | `0` | Amount of disk space to keep for cache | +| `--verbose` | | | Provide a more verbose output | diff --git a/docs/reference/buildx_rm.md b/docs/reference/buildx_rm.md index dba7a8f2..d7e0ab78 100644 --- a/docs/reference/buildx_rm.md +++ b/docs/reference/buildx_rm.md @@ -9,13 +9,13 @@ Remove a builder instance ### Options -| Name | Description | -| --- | --- | -| [`--all-inactive`](#all-inactive) | Remove all inactive builders | -| [`--builder string`](#builder) | Override the configured builder instance | -| [`-f`](#force), [`--force`](#force) | Do not prompt for confirmation | -| [`--keep-daemon`](#keep-daemon) | Keep the buildkitd daemon running | -| [`--keep-state`](#keep-state) | Keep BuildKit state | +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| [`--all-inactive`](#all-inactive) | | | Remove all inactive builders | +| [`--builder`](#builder) | `string` | | Override the configured builder instance | +| [`-f`](#force), [`--force`](#force) | | | Do not prompt for confirmation | +| [`--keep-daemon`](#keep-daemon) | | | Keep the buildkitd daemon running | +| [`--keep-state`](#keep-state) | | | Keep BuildKit state | diff --git a/docs/reference/buildx_stop.md b/docs/reference/buildx_stop.md index c34d7124..5cfed516 100644 --- a/docs/reference/buildx_stop.md +++ b/docs/reference/buildx_stop.md @@ -9,9 +9,9 @@ Stop builder instance ### Options -| Name | Description | -| --- | --- | -| [`--builder string`](#builder) | Override the configured builder instance | +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| [`--builder`](#builder) | `string` | | Override the configured builder instance | diff --git a/docs/reference/buildx_use.md b/docs/reference/buildx_use.md index fe38a075..8e952d72 100644 --- a/docs/reference/buildx_use.md +++ b/docs/reference/buildx_use.md @@ -9,11 +9,11 @@ Set the current builder instance ### Options -| Name | Description | -| --- | --- | -| [`--builder string`](#builder) | Override the configured builder instance | -| `--default` | Set builder as default for current context | -| `--global` | Builder persists context changes | +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| [`--builder`](#builder) | `string` | | Override the configured builder instance | +| `--default` | | | Set builder as default for current context | +| `--global` | | | Builder persists context changes | diff --git a/go.mod b/go.mod index 448b22b9..3793a385 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/containerd/console v1.0.3 github.com/containerd/containerd v1.6.0 github.com/docker/cli v20.10.12+incompatible - github.com/docker/cli-docs-tool v0.3.0 + github.com/docker/cli-docs-tool v0.4.0 github.com/docker/compose-on-kubernetes v0.4.19-0.20190128150448-356b2919c496 // indirect github.com/docker/distribution v2.8.0+incompatible github.com/docker/docker v20.10.7+incompatible diff --git a/go.sum b/go.sum index 0a9f68b8..b9ce7628 100644 --- a/go.sum +++ b/go.sum @@ -445,8 +445,8 @@ github.com/distribution/distribution/v3 v3.0.0-20210316161203-a01c71e2477e/go.mo github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= github.com/docker/cli v20.10.3-0.20210702143511-f782d1355eff+incompatible h1:CaaxCD/l9Dxogu6lxf7AQautlv3sHULrasPadayp0fM= github.com/docker/cli v20.10.3-0.20210702143511-f782d1355eff+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= -github.com/docker/cli-docs-tool v0.3.0 h1:GFp265P7r0k59EmjD3r066iqN1y4L5qlKsBeODJYGXo= -github.com/docker/cli-docs-tool v0.3.0/go.mod h1:rgW5KKdNpLMBIuH4WQ/1RNh38nH+/Ay5jgL4P0ZMPpY= +github.com/docker/cli-docs-tool v0.4.0 h1:MdfKoErGEbFqIxQ8an9BsZ+YzKUGd58RBVkV+Q82GPo= +github.com/docker/cli-docs-tool v0.4.0/go.mod h1:rgW5KKdNpLMBIuH4WQ/1RNh38nH+/Ay5jgL4P0ZMPpY= github.com/docker/compose-on-kubernetes v0.4.19-0.20190128150448-356b2919c496 h1:90ytrX1dbzL7Uf/hHiuWwvywC+gikHv4hkAy4CwRTbs= github.com/docker/compose-on-kubernetes v0.4.19-0.20190128150448-356b2919c496/go.mod h1:iT2pYfi580XlpaV4KmK0T6+4/9+XoKmk/fhoDod1emE= github.com/docker/distribution v0.0.0-20190905152932-14b96e55d84c/go.mod h1:0+TTO4EOBfRPhZXAeF1Vu+W3hHZ8eLp8PgKVZlcvtFY= diff --git a/vendor/github.com/docker/cli-docs-tool/annotation/annotation.go b/vendor/github.com/docker/cli-docs-tool/annotation/annotation.go index 400bd9f7..021846af 100644 --- a/vendor/github.com/docker/cli-docs-tool/annotation/annotation.go +++ b/vendor/github.com/docker/cli-docs-tool/annotation/annotation.go @@ -20,4 +20,6 @@ const ( // CodeDelimiter specifies the char that will be converted as code backtick. // Can be used on cmd for inheritance or a specific flag. CodeDelimiter = "docs.code-delimiter" + // DefaultValue specifies the default value for a flag. + DefaultValue = "docs.default-value" ) diff --git a/vendor/github.com/docker/cli-docs-tool/clidocstool_md.go b/vendor/github.com/docker/cli-docs-tool/clidocstool_md.go index e08a76d0..55cb38d4 100644 --- a/vendor/github.com/docker/cli-docs-tool/clidocstool_md.go +++ b/vendor/github.com/docker/cli-docs-tool/clidocstool_md.go @@ -17,7 +17,6 @@ package clidocstool import ( "bytes" "fmt" - "io/ioutil" "log" "os" "path/filepath" @@ -82,14 +81,14 @@ func (c *Client) GenMarkdownTree(cmd *cobra.Command) error { }); err != nil { return err } - if err = ioutil.WriteFile(targetPath, icBuf.Bytes(), 0644); err != nil { + if err = os.WriteFile(targetPath, icBuf.Bytes(), 0644); err != nil { return err } } else if err := copyFile(sourcePath, targetPath); err != nil { return err } - content, err := ioutil.ReadFile(targetPath) + content, err := os.ReadFile(targetPath) if err != nil { return err } @@ -116,7 +115,7 @@ func (c *Client) GenMarkdownTree(cmd *cobra.Command) error { if err != nil { return err } - if err = ioutil.WriteFile(targetPath, []byte(cont), fi.Mode()); err != nil { + if err = os.WriteFile(targetPath, []byte(cont), fi.Mode()); err != nil { return fmt.Errorf("failed to write %s: %w", targetPath, err) } @@ -179,8 +178,8 @@ func mdCmdOutput(cmd *cobra.Command, old string) (string, error) { if cmd.Flags().HasAvailableFlags() { fmt.Fprint(b, "### Options\n\n") - fmt.Fprint(b, "| Name | Description |\n") - fmt.Fprint(b, "| --- | --- |\n") + fmt.Fprint(b, "| Name | Type | Default | Description |\n") + fmt.Fprint(b, "| --- | --- | --- | --- |\n") cmd.Flags().VisitAll(func(f *pflag.Flag) { if f.Hidden { @@ -193,19 +192,33 @@ func mdCmdOutput(cmd *cobra.Command, old string) (string, error) { name = mdMakeLink(name, f.Name, f, isLink) fmt.Fprintf(b, "%s, ", name) } - name := "`--" + f.Name + name := "`--" + f.Name + "`" + name = mdMakeLink(name, f.Name, f, isLink) + + var ftype string if f.Value.Type() != "bool" { - name += " " + f.Value.Type() + ftype = "`" + f.Value.Type() + "`" } - name += "`" - name = mdMakeLink(name, f.Name, f, isLink) + + var defval string + if v, ok := f.Annotations[annotation.DefaultValue]; ok && len(v) > 0 { + defval = v[0] + if cd, ok := f.Annotations[annotation.CodeDelimiter]; ok { + defval = strings.ReplaceAll(defval, cd[0], "`") + } else if cd, ok := cmd.Annotations[annotation.CodeDelimiter]; ok { + defval = strings.ReplaceAll(defval, cd, "`") + } + } else if f.DefValue != "" && (f.Value.Type() != "bool" && f.DefValue != "true") && f.DefValue != "[]" { + defval = "`" + f.DefValue + "`" + } + usage := f.Usage if cd, ok := f.Annotations[annotation.CodeDelimiter]; ok { usage = strings.ReplaceAll(usage, cd[0], "`") } else if cd, ok := cmd.Annotations[annotation.CodeDelimiter]; ok { usage = strings.ReplaceAll(usage, cd, "`") } - fmt.Fprintf(b, "%s | %s |\n", mdEscapePipe(name), mdEscapePipe(usage)) + fmt.Fprintf(b, "%s | %s | %s | %s |\n", mdEscapePipe(name), mdEscapePipe(ftype), mdEscapePipe(defval), mdEscapePipe(usage)) }) fmt.Fprintln(b, "") } diff --git a/vendor/github.com/docker/cli-docs-tool/clidocstool_yaml.go b/vendor/github.com/docker/cli-docs-tool/clidocstool_yaml.go index 55cd49dd..dfccfcab 100644 --- a/vendor/github.com/docker/cli-docs-tool/clidocstool_yaml.go +++ b/vendor/github.com/docker/cli-docs-tool/clidocstool_yaml.go @@ -17,7 +17,6 @@ package clidocstool import ( "fmt" "io" - "io/ioutil" "log" "os" "path/filepath" @@ -269,13 +268,25 @@ func genFlagResult(cmd *cobra.Command, flags *pflag.FlagSet, anchors map[string] flags.VisitAll(func(flag *pflag.Flag) { opt = cmdOption{ - Option: flag.Name, - ValueType: flag.Value.Type(), - DefaultValue: forceMultiLine(flag.DefValue, defaultValueMaxWidth), - Deprecated: len(flag.Deprecated) > 0, - Hidden: flag.Hidden, + Option: flag.Name, + ValueType: flag.Value.Type(), + Deprecated: len(flag.Deprecated) > 0, + Hidden: flag.Hidden, } + var defval string + if v, ok := flag.Annotations[annotation.DefaultValue]; ok && len(v) > 0 { + defval = v[0] + if cd, ok := flag.Annotations[annotation.CodeDelimiter]; ok { + defval = strings.ReplaceAll(defval, cd[0], "`") + } else if cd, ok := cmd.Annotations[annotation.CodeDelimiter]; ok { + defval = strings.ReplaceAll(defval, cd, "`") + } + } else { + defval = flag.DefValue + } + opt.DefaultValue = forceMultiLine(defval, defaultValueMaxWidth) + usage := flag.Usage if cd, ok := flag.Annotations[annotation.CodeDelimiter]; ok { usage = strings.ReplaceAll(usage, cd[0], "`") @@ -367,7 +378,7 @@ func (c *Client) loadLongDescription(parentCmd *cobra.Command) error { } } name := cmd.CommandPath() - if i := strings.Index(name, " "); c.plugin && i >= 0 { + if i := strings.Index(name, " "); i >= 0 { // remove root command / binary name name = name[i+1:] } @@ -376,7 +387,7 @@ func (c *Client) loadLongDescription(parentCmd *cobra.Command) error { } mdFile := strings.ReplaceAll(name, " ", "_") + ".md" sourcePath := filepath.Join(c.source, mdFile) - content, err := ioutil.ReadFile(sourcePath) + content, err := os.ReadFile(sourcePath) if os.IsNotExist(err) { log.Printf("WARN: %s does not exist, skipping Markdown examples for YAML doc\n", mdFile) continue diff --git a/vendor/modules.txt b/vendor/modules.txt index 18aacd4f..635d28f4 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -104,7 +104,7 @@ github.com/docker/cli/cli/streams github.com/docker/cli/cli/trust github.com/docker/cli/cli/version github.com/docker/cli/opts -# github.com/docker/cli-docs-tool v0.3.0 +# github.com/docker/cli-docs-tool v0.4.0 ## explicit github.com/docker/cli-docs-tool github.com/docker/cli-docs-tool/annotation