You've already forked cli-docs-tool
mirror of
https://github.com/docker/cli-docs-tool.git
synced 2025-08-12 19:42:43 +03:00
Merge pull request #33 from crazy-max/usage-newline
markdown: replace new line in usage
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
[](https://pkg.go.dev/github.com/docker/cli-docs-tool)
|
[](https://pkg.go.dev/github.com/docker/cli-docs-tool)
|
||||||
[](https://github.com/docker/cli-docs-tool/actions?query=workflow%3Atest)
|
[](https://github.com/docker/cli-docs-tool/actions?query=workflow%3Atest)
|
||||||
[](https://goreportcard.com/report/github.com/docker/cli-docs-tool)
|
[](https://goreportcard.com/report/github.com/docker/cli-docs-tool)
|
||||||
|
|
||||||
## About
|
## About
|
||||||
|
@@ -20,6 +20,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
@@ -28,6 +29,10 @@ import (
|
|||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
nlRegexp = regexp.MustCompile(`\r?\n`)
|
||||||
|
)
|
||||||
|
|
||||||
// GenMarkdownTree will generate a markdown page for this command and all
|
// GenMarkdownTree will generate a markdown page for this command and all
|
||||||
// descendants in the directory given.
|
// descendants in the directory given.
|
||||||
func (c *Client) GenMarkdownTree(cmd *cobra.Command) error {
|
func (c *Client) GenMarkdownTree(cmd *cobra.Command) error {
|
||||||
@@ -216,7 +221,7 @@ func mdCmdOutput(cmd *cobra.Command, old string) (string, error) {
|
|||||||
} else if cd, ok := cmd.Annotations[annotation.CodeDelimiter]; ok {
|
} else if cd, ok := cmd.Annotations[annotation.CodeDelimiter]; ok {
|
||||||
usage = strings.ReplaceAll(usage, cd, "`")
|
usage = strings.ReplaceAll(usage, cd, "`")
|
||||||
}
|
}
|
||||||
fmt.Fprintf(b, "%s | %s | %s | %s |\n", mdEscapePipe(name), mdEscapePipe(ftype), mdEscapePipe(defval), mdEscapePipe(usage))
|
fmt.Fprintf(b, "%s | %s | %s | %s |\n", mdEscapePipe(name), mdEscapePipe(ftype), mdEscapePipe(defval), mdReplaceNewline(mdEscapePipe(usage)))
|
||||||
})
|
})
|
||||||
fmt.Fprintln(b, "")
|
fmt.Fprintln(b, "")
|
||||||
}
|
}
|
||||||
@@ -227,3 +232,7 @@ func mdCmdOutput(cmd *cobra.Command, old string) (string, error) {
|
|||||||
func mdEscapePipe(s string) string {
|
func mdEscapePipe(s string) string {
|
||||||
return strings.ReplaceAll(s, `|`, `\|`)
|
return strings.ReplaceAll(s, `|`, `\|`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func mdReplaceNewline(s string) string {
|
||||||
|
return nlRegexp.ReplaceAllString(s, "<br>")
|
||||||
|
}
|
||||||
|
@@ -118,7 +118,8 @@ func init() {
|
|||||||
|
|
||||||
buildxBuildFlags.StringVar(&ignore, "shm-size", "", `Size of "/dev/shm"`)
|
buildxBuildFlags.StringVar(&ignore, "shm-size", "", `Size of "/dev/shm"`)
|
||||||
|
|
||||||
buildxBuildFlags.StringArray("ssh", []string{}, `SSH agent socket or keys to expose to the build (format: "default|<id>[=<socket>|<key>[,<key>]]")`)
|
buildxBuildFlags.StringArray("ssh", []string{}, `SSH agent socket or keys to expose to the build
|
||||||
|
format: "default|<id>[=<socket>|<key>[,<key>]]"`)
|
||||||
|
|
||||||
buildxBuildFlags.StringArrayP("tag", "t", []string{}, `Name and optionally a tag (format: "name:tag")`)
|
buildxBuildFlags.StringArrayP("tag", "t", []string{}, `Name and optionally a tag (format: "name:tag")`)
|
||||||
buildxBuildFlags.SetAnnotation("tag", annotation.ExternalURL, []string{"https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t"})
|
buildxBuildFlags.SetAnnotation("tag", annotation.ExternalURL, []string{"https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t"})
|
||||||
|
@@ -29,7 +29,7 @@ Start a build
|
|||||||
| `-q`, `--quiet` | | | Suppress the build output and print image ID on success |
|
| `-q`, `--quiet` | | | Suppress the build output and print image ID on success |
|
||||||
| `--secret` | `stringArray` | | Secret file to expose to the build (format: `id=mysecret,src=/local/secret`) |
|
| `--secret` | `stringArray` | | Secret file to expose to the build (format: `id=mysecret,src=/local/secret`) |
|
||||||
| `--shm-size` | `string` | | Size of `/dev/shm` |
|
| `--shm-size` | `string` | | Size of `/dev/shm` |
|
||||||
| `--ssh` | `stringArray` | | SSH agent socket or keys to expose to the build (format: `default\|<id>[=<socket>\|<key>[,<key>]]`) |
|
| `--ssh` | `stringArray` | | SSH agent socket or keys to expose to the build<br>format: `default\|<id>[=<socket>\|<key>[,<key>]]` |
|
||||||
| [`-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`) |
|
| [`-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. |
|
| [`--target`](https://docs.docker.com/engine/reference/commandline/build/#specifying-target-build-stage---target) | `string` | | Set the target build stage to build. |
|
||||||
| `--ulimit` | `string` | | Ulimit options |
|
| `--ulimit` | `string` | | Ulimit options |
|
||||||
|
@@ -314,8 +314,9 @@ options:
|
|||||||
- option: ssh
|
- option: ssh
|
||||||
value_type: stringArray
|
value_type: stringArray
|
||||||
default_value: '[]'
|
default_value: '[]'
|
||||||
description: |
|
description: |-
|
||||||
SSH agent socket or keys to expose to the build (format: `default|<id>[=<socket>|<key>[,<key>]]`)
|
SSH agent socket or keys to expose to the build
|
||||||
|
format: `default|<id>[=<socket>|<key>[,<key>]]`
|
||||||
deprecated: false
|
deprecated: false
|
||||||
hidden: false
|
hidden: false
|
||||||
experimental: false
|
experimental: false
|
||||||
|
Reference in New Issue
Block a user