fix: trailing white spaces in genrated docs (#1198)

Signed-off-by: Matej Vasek <mvasek@redhat.com>

Signed-off-by: Matej Vasek <mvasek@redhat.com>
This commit is contained in:
Matej Vasek 2022-08-30 15:38:18 +02:00 committed by GitHub
parent 1f4db6eab4
commit cd64b70b47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -6,6 +6,7 @@ import (
"html/template" "html/template"
"io/ioutil" "io/ioutil"
"os" "os"
"regexp"
"strings" "strings"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -117,7 +118,10 @@ func writeMarkdown(c *cobra.Command, name string, opts TemplateOptions) error {
fmt.Fprintf(os.Stderr, "unable to process help text: %v", err) fmt.Fprintf(os.Stderr, "unable to process help text: %v", err)
} }
if err := ioutil.WriteFile(targetDir+"/"+name+".md", out.Bytes(), 0666); err != nil { re := regexp.MustCompile(`[^\S\r\n]+\n`)
data := re.ReplaceAll(out.Bytes(), []byte{'\n'}) // trim white spaces before EOL
if err := ioutil.WriteFile(targetDir+"/"+name+".md", data, 0666); err != nil {
return err return err
} }
return nil return nil

View File

@ -43,7 +43,7 @@ DESCRIPTION
springboot http springboot http
typescript cloudevents typescript cloudevents
typescript http typescript http
To install more language runtimes and their templates see 'func repository'. To install more language runtimes and their templates see 'func repository'.
@ -59,7 +59,7 @@ EXAMPLES
o Create a Go function which handles CloudEvents in ./myfunc. o Create a Go function which handles CloudEvents in ./myfunc.
$ func create -l go -t cloudevents myfunc $ func create -l go -t cloudevents myfunc
``` ```
func create [flags] func create [flags]

View File

@ -16,7 +16,7 @@ DESCRIPTION
To specify a URI of a single, specific repository for which templates To specify a URI of a single, specific repository for which templates
should be displayed, use the --repository flag. should be displayed, use the --repository flag.
Installed repositories are by default located at ~/.func/repositories Installed repositories are by default located at ~/.func/repositories
($XDG_CONFIG_HOME/.func/repositories). This can be overridden with ($XDG_CONFIG_HOME/.func/repositories). This can be overridden with
$FUNC_REPOSITORIES_PATH. $FUNC_REPOSITORIES_PATH.