From a872003a2a9746b00c824fed0276e348be14761d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 20 Mar 2024 11:43:15 +0000 Subject: [PATCH] Update module github.com/cpuguy83/go-md2man/v2 to v2.0.4 Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- test/tools/go.mod | 2 +- test/tools/go.sum | 4 +- .../cpuguy83/go-md2man/v2/Dockerfile | 20 ++--- .../github.com/cpuguy83/go-md2man/v2/Makefile | 46 ++++++---- .../cpuguy83/go-md2man/v2/md2man/roff.go | 90 +++++++++++++------ test/tools/vendor/modules.txt | 2 +- 6 files changed, 103 insertions(+), 61 deletions(-) diff --git a/test/tools/go.mod b/test/tools/go.mod index 0da8f90766..576c1140e6 100644 --- a/test/tools/go.mod +++ b/test/tools/go.mod @@ -3,7 +3,7 @@ module github.com/containers/podman/test/tools go 1.20 require ( - github.com/cpuguy83/go-md2man/v2 v2.0.3 + github.com/cpuguy83/go-md2man/v2 v2.0.4 github.com/onsi/ginkgo/v2 v2.14.0 github.com/vbatts/git-validation v1.2.1 golang.org/x/tools v0.19.0 diff --git a/test/tools/go.sum b/test/tools/go.sum index 918dd39386..51c0d08aff 100644 --- a/test/tools/go.sum +++ b/test/tools/go.sum @@ -1,8 +1,8 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= -github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/test/tools/vendor/github.com/cpuguy83/go-md2man/v2/Dockerfile b/test/tools/vendor/github.com/cpuguy83/go-md2man/v2/Dockerfile index 7181c5306f..b9fc4dfdb5 100644 --- a/test/tools/vendor/github.com/cpuguy83/go-md2man/v2/Dockerfile +++ b/test/tools/vendor/github.com/cpuguy83/go-md2man/v2/Dockerfile @@ -1,20 +1,14 @@ -ARG GO_VERSION=1.18 -ARG GO_IMAGE=golang:${GO_VERSION} +ARG GO_VERSION=1.21 -FROM --platform=$BUILDPLATFORM $GO_IMAGE AS build +FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS build COPY . /go/src/github.com/cpuguy83/go-md2man WORKDIR /go/src/github.com/cpuguy83/go-md2man -ARG TARGETOS -ARG TARGETARCH -ARG TARGETVARIANT +ARG TARGETOS TARGETARCH TARGETVARIANT RUN \ - export GOOS="${TARGETOS}"; \ - export GOARCH="${TARGETARCH}"; \ - if [ "${TARGETARCH}" = "arm" ] && [ "${TARGETVARIANT}" ]; then \ - export GOARM="${TARGETVARIANT#v}"; \ - fi; \ - CGO_ENABLED=0 go build + --mount=type=cache,target=/go/pkg/mod \ + --mount=type=cache,target=/root/.cache/go-build \ + make build FROM scratch -COPY --from=build /go/src/github.com/cpuguy83/go-md2man/go-md2man /go-md2man +COPY --from=build /go/src/github.com/cpuguy83/go-md2man/bin/go-md2man /go-md2man ENTRYPOINT ["/go-md2man"] diff --git a/test/tools/vendor/github.com/cpuguy83/go-md2man/v2/Makefile b/test/tools/vendor/github.com/cpuguy83/go-md2man/v2/Makefile index 437fc99979..5f4a423d6f 100644 --- a/test/tools/vendor/github.com/cpuguy83/go-md2man/v2/Makefile +++ b/test/tools/vendor/github.com/cpuguy83/go-md2man/v2/Makefile @@ -1,8 +1,34 @@ GO111MODULE ?= on -LINTER_BIN ?= golangci-lint export GO111MODULE +GOOS ?= $(if $(TARGETOS),$(TARGETOS),) +GOARCH ?= $(if $(TARGETARCH),$(TARGETARCH),) + +ifeq ($(TARGETARCH),amd64) +GOAMD64 ?= $(TARGETVARIANT) +endif + +ifeq ($(TARGETARCH),arm) +GOARM ?= $(TARGETVARIANT:v%=%) +endif + +ifneq ($(GOOS),) +export GOOS +endif + +ifneq ($(GOARCH),) +export GOARCH +endif + +ifneq ($(GOAMD64),) +export GOAMD64 +endif + +ifneq ($(GOARM),) +export GOARM +endif + .PHONY: build: bin/go-md2man @@ -14,22 +40,10 @@ clean: test: @go test $(TEST_FLAGS) ./... -bin/go-md2man: actual_build_flags := $(BUILD_FLAGS) -o bin/go-md2man -bin/go-md2man: bin - @CGO_ENABLED=0 go build $(actual_build_flags) - -bin: - @mkdir ./bin +bin/go-md2man: go.mod go.sum md2man/* *.go + @mkdir -p bin + CGO_ENABLED=0 go build $(BUILD_FLAGS) -o $@ .PHONY: mod mod: @go mod tidy - -.PHONY: check-mod -check-mod: # verifies that module changes for go.mod and go.sum are checked in - @hack/ci/check_mods.sh - -.PHONY: vendor -vendor: mod - @go mod vendor -v - diff --git a/test/tools/vendor/github.com/cpuguy83/go-md2man/v2/md2man/roff.go b/test/tools/vendor/github.com/cpuguy83/go-md2man/v2/md2man/roff.go index 4b19188d90..8a290f1972 100644 --- a/test/tools/vendor/github.com/cpuguy83/go-md2man/v2/md2man/roff.go +++ b/test/tools/vendor/github.com/cpuguy83/go-md2man/v2/md2man/roff.go @@ -1,6 +1,7 @@ package md2man import ( + "bufio" "bytes" "fmt" "io" @@ -21,34 +22,35 @@ type roffRenderer struct { } const ( - titleHeader = ".TH " - topLevelHeader = "\n\n.SH " - secondLevelHdr = "\n.SH " - otherHeader = "\n.SS " - crTag = "\n" - emphTag = "\\fI" - emphCloseTag = "\\fP" - strongTag = "\\fB" - strongCloseTag = "\\fP" - breakTag = "\n.br\n" - paraTag = "\n.PP\n" - hruleTag = "\n.ti 0\n\\l'\\n(.lu'\n" - linkTag = "\n\\[la]" - linkCloseTag = "\\[ra]" - codespanTag = "\\fB" - codespanCloseTag = "\\fR" - codeTag = "\n.EX\n" - codeCloseTag = "\n.EE\n" - quoteTag = "\n.PP\n.RS\n" - quoteCloseTag = "\n.RE\n" - listTag = "\n.RS\n" - listCloseTag = "\n.RE\n" - dtTag = "\n.TP\n" - dd2Tag = "\n" - tableStart = "\n.TS\nallbox;\n" - tableEnd = ".TE\n" - tableCellStart = "T{\n" - tableCellEnd = "\nT}\n" + titleHeader = ".TH " + topLevelHeader = "\n\n.SH " + secondLevelHdr = "\n.SH " + otherHeader = "\n.SS " + crTag = "\n" + emphTag = "\\fI" + emphCloseTag = "\\fP" + strongTag = "\\fB" + strongCloseTag = "\\fP" + breakTag = "\n.br\n" + paraTag = "\n.PP\n" + hruleTag = "\n.ti 0\n\\l'\\n(.lu'\n" + linkTag = "\n\\[la]" + linkCloseTag = "\\[ra]" + codespanTag = "\\fB" + codespanCloseTag = "\\fR" + codeTag = "\n.EX\n" + codeCloseTag = ".EE\n" // Do not prepend a newline character since code blocks, by definition, include a newline already (or at least as how blackfriday gives us on). + quoteTag = "\n.PP\n.RS\n" + quoteCloseTag = "\n.RE\n" + listTag = "\n.RS\n" + listCloseTag = "\n.RE\n" + dtTag = "\n.TP\n" + dd2Tag = "\n" + tableStart = "\n.TS\nallbox;\n" + tableEnd = ".TE\n" + tableCellStart = "T{\n" + tableCellEnd = "\nT}\n" + tablePreprocessor = `'\" t` ) // NewRoffRenderer creates a new blackfriday Renderer for generating roff documents @@ -75,6 +77,16 @@ func (r *roffRenderer) GetExtensions() blackfriday.Extensions { // RenderHeader handles outputting the header at document start func (r *roffRenderer) RenderHeader(w io.Writer, ast *blackfriday.Node) { + // We need to walk the tree to check if there are any tables. + // If there are, we need to enable the roff table preprocessor. + ast.Walk(func(node *blackfriday.Node, entering bool) blackfriday.WalkStatus { + if node.Type == blackfriday.Table { + out(w, tablePreprocessor+"\n") + return blackfriday.Terminate + } + return blackfriday.GoToNext + }) + // disable hyphenation out(w, ".nh\n") } @@ -322,6 +334,28 @@ func out(w io.Writer, output string) { } func escapeSpecialChars(w io.Writer, text []byte) { + scanner := bufio.NewScanner(bytes.NewReader(text)) + + // count the number of lines in the text + // we need to know this to avoid adding a newline after the last line + n := bytes.Count(text, []byte{'\n'}) + idx := 0 + + for scanner.Scan() { + dt := scanner.Bytes() + if idx < n { + idx++ + dt = append(dt, '\n') + } + escapeSpecialCharsLine(w, dt) + } + + if err := scanner.Err(); err != nil { + panic(err) + } +} + +func escapeSpecialCharsLine(w io.Writer, text []byte) { for i := 0; i < len(text); i++ { // escape initial apostrophe or period if len(text) >= 1 && (text[0] == '\'' || text[0] == '.') { diff --git a/test/tools/vendor/modules.txt b/test/tools/vendor/modules.txt index 9d908d6c92..a639bef09d 100644 --- a/test/tools/vendor/modules.txt +++ b/test/tools/vendor/modules.txt @@ -1,4 +1,4 @@ -# github.com/cpuguy83/go-md2man/v2 v2.0.3 +# github.com/cpuguy83/go-md2man/v2 v2.0.4 ## explicit; go 1.11 github.com/cpuguy83/go-md2man/v2 github.com/cpuguy83/go-md2man/v2/md2man