mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: github.com/docker/cli-docs-tool v0.7.0
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
4
vendor/github.com/docker/cli-docs-tool/clidocstool_md.go
generated
vendored
4
vendor/github.com/docker/cli-docs-tool/clidocstool_md.go
generated
vendored
@ -241,7 +241,7 @@ func mdCmdOutput(cmd *cobra.Command, old string) (string, error) {
|
||||
name += mdMakeLink("`--"+f.Name+"`", f.Name, f, isLink)
|
||||
|
||||
var ftype string
|
||||
if f.Value.Type() != "bool" {
|
||||
if f.Value.Type() != "bool" || (f.Value.Type() == "bool" && f.DefValue == "true") {
|
||||
ftype = "`" + f.Value.Type() + "`"
|
||||
}
|
||||
|
||||
@ -253,7 +253,7 @@ func mdCmdOutput(cmd *cobra.Command, old string) (string, error) {
|
||||
} 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 != "[]" {
|
||||
} else if f.DefValue != "" && ((f.Value.Type() != "bool" && f.DefValue != "true") || (f.Value.Type() == "bool" && f.DefValue == "true")) && f.DefValue != "[]" {
|
||||
defval = "`" + f.DefValue + "`"
|
||||
}
|
||||
|
||||
|
13
vendor/github.com/docker/cli-docs-tool/markdown.go
generated
vendored
13
vendor/github.com/docker/cli-docs-tool/markdown.go
generated
vendored
@ -29,6 +29,9 @@ var (
|
||||
// for our use-case; DO NOT consider using this as a generic regex, or at least
|
||||
// not before reading https://stackoverflow.com/a/1732454/1811501.
|
||||
htmlAnchor = regexp.MustCompile(`<a\s+(?:name|id)="?([^"]+)"?\s*></a>\s*`)
|
||||
// relativeLink matches parts of internal links between .md documents
|
||||
// e.g. "](buildx_build.md)"
|
||||
relativeLink = regexp.MustCompile(`\]\((\.\/)?[a-z-_]+\.md(#.*)?\)`)
|
||||
)
|
||||
|
||||
// getSections returns all H2 sections by title (lowercase)
|
||||
@ -58,6 +61,16 @@ func cleanupMarkDown(mdString string) (md string, anchors []string) {
|
||||
mdString = strings.ReplaceAll(mdString, "\t", " ")
|
||||
mdString = strings.ReplaceAll(mdString, "https://docs.docker.com", "")
|
||||
|
||||
// Rewrite internal links, replacing relative paths with absolute path
|
||||
// e.g. from [docker buildx build](buildx_build.md#build-arg)
|
||||
// to [docker buildx build](/reference/cli/docker/buildx/build/#build-arg)
|
||||
mdString = relativeLink.ReplaceAllStringFunc(mdString, func(link string) string {
|
||||
link = strings.TrimLeft(link, "](./")
|
||||
link = strings.ReplaceAll(link, "_", "/")
|
||||
link = strings.ReplaceAll(link, ".md", "/")
|
||||
return "](/reference/cli/docker/" + link
|
||||
})
|
||||
|
||||
var id string
|
||||
// replace trailing whitespace per line, and handle custom anchors
|
||||
lines := strings.Split(mdString, "\n")
|
||||
|
Reference in New Issue
Block a user