Skip to content

Commit 64ee549

Browse files
authored
Merge pull request #33 from crazy-max/usage-newline
markdown: replace new line in usage
2 parents 77abede + 6de4bc9 commit 64ee549

5 files changed

Lines changed: 17 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[![PkgGoDev](https://img.shields.io/badge/go.dev-docs-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/docker/cli-docs-tool)
2-
[![Test Status](https://img.shields.io/github/workflow/status/docker/cli-docs-tool/test?label=test&logo=github&style=flat-square)](https://github.com/docker/cli-docs-tool/actions?query=workflow%3Atest)
2+
[![Test Status](https://img.shields.io/github/actions/workflow/status/docker/cli-docs-tool/test.yml?branch=main&label=test&logo=github&style=flat-square)](https://github.com/docker/cli-docs-tool/actions?query=workflow%3Atest)
33
[![Go Report Card](https://goreportcard.com/badge/github.com/docker/cli-docs-tool)](https://goreportcard.com/report/github.com/docker/cli-docs-tool)
44

55
## About

clidocstool_md.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"log"
2121
"os"
2222
"path/filepath"
23+
"regexp"
2324
"strings"
2425
"text/template"
2526

@@ -28,6 +29,10 @@ import (
2829
"github.com/spf13/pflag"
2930
)
3031

32+
var (
33+
nlRegexp = regexp.MustCompile(`\r?\n`)
34+
)
35+
3136
// GenMarkdownTree will generate a markdown page for this command and all
3237
// descendants in the directory given.
3338
func (c *Client) GenMarkdownTree(cmd *cobra.Command) error {
@@ -216,7 +221,7 @@ func mdCmdOutput(cmd *cobra.Command, old string) (string, error) {
216221
} else if cd, ok := cmd.Annotations[annotation.CodeDelimiter]; ok {
217222
usage = strings.ReplaceAll(usage, cd, "`")
218223
}
219-
fmt.Fprintf(b, "%s | %s | %s | %s |\n", mdEscapePipe(name), mdEscapePipe(ftype), mdEscapePipe(defval), mdEscapePipe(usage))
224+
fmt.Fprintf(b, "%s | %s | %s | %s |\n", mdEscapePipe(name), mdEscapePipe(ftype), mdEscapePipe(defval), mdReplaceNewline(mdEscapePipe(usage)))
220225
})
221226
fmt.Fprintln(b, "")
222227
}
@@ -227,3 +232,7 @@ func mdCmdOutput(cmd *cobra.Command, old string) (string, error) {
227232
func mdEscapePipe(s string) string {
228233
return strings.ReplaceAll(s, `|`, `\|`)
229234
}
235+
236+
func mdReplaceNewline(s string) string {
237+
return nlRegexp.ReplaceAllString(s, "<br>")
238+
}

clidocstool_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ func init() {
118118

119119
buildxBuildFlags.StringVar(&ignore, "shm-size", "", `Size of "/dev/shm"`)
120120

121-
buildxBuildFlags.StringArray("ssh", []string{}, `SSH agent socket or keys to expose to the build (format: "default|<id>[=<socket>|<key>[,<key>]]")`)
121+
buildxBuildFlags.StringArray("ssh", []string{}, `SSH agent socket or keys to expose to the build
122+
format: "default|<id>[=<socket>|<key>[,<key>]]"`)
122123

123124
buildxBuildFlags.StringArrayP("tag", "t", []string{}, `Name and optionally a tag (format: "name:tag")`)
124125
buildxBuildFlags.SetAnnotation("tag", annotation.ExternalURL, []string{"https://docs.docker.com/engine/reference/commandline/build/#tag-an-image--t"})

fixtures/buildx_build.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Start a build
2929
| `-q`, `--quiet` | | | Suppress the build output and print image ID on success |
3030
| `--secret` | `stringArray` | | Secret file to expose to the build (format: `id=mysecret,src=/local/secret`) |
3131
| `--shm-size` | `string` | | Size of `/dev/shm` |
32-
| `--ssh` | `stringArray` | | SSH agent socket or keys to expose to the build (format: `default\|<id>[=<socket>\|<key>[,<key>]]`) |
32+
| `--ssh` | `stringArray` | | SSH agent socket or keys to expose to the build<br>format: `default\|<id>[=<socket>\|<key>[,<key>]]` |
3333
| [`-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`) |
3434
| [`--target`](https://docs.docker.com/engine/reference/commandline/build/#specifying-target-build-stage---target) | `string` | | Set the target build stage to build. |
3535
| `--ulimit` | `string` | | Ulimit options |

fixtures/docker_buildx_build.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,9 @@ options:
314314
- option: ssh
315315
value_type: stringArray
316316
default_value: '[]'
317-
description: |
318-
SSH agent socket or keys to expose to the build (format: `default|<id>[=<socket>|<key>[,<key>]]`)
317+
description: |-
318+
SSH agent socket or keys to expose to the build
319+
format: `default|<id>[=<socket>|<key>[,<key>]]`
319320
deprecated: false
320321
hidden: false
321322
experimental: false

0 commit comments

Comments
 (0)