Commit 1900c626 authored by k8s-merge-robot's avatar k8s-merge-robot

Merge pull request #18312 from erictune/example-syncer

Auto commit by PR queue bot
parents 32ac5c57 21f81935
...@@ -27,7 +27,7 @@ const exampleToken = "EXAMPLE" ...@@ -27,7 +27,7 @@ const exampleToken = "EXAMPLE"
const exampleLineStart = "<!-- BEGIN MUNGE: EXAMPLE" const exampleLineStart = "<!-- BEGIN MUNGE: EXAMPLE"
var exampleMungeTagRE = regexp.MustCompile(beginMungeTag(fmt.Sprintf("%s %s", exampleToken, `(([^ ])*.(yaml|json))`))) var exampleMungeTagRE = regexp.MustCompile(beginMungeTag(fmt.Sprintf("%s %s", exampleToken, `(([^ ])*[.]([^.]*))`)))
// syncExamples updates all examples in markdown file. // syncExamples updates all examples in markdown file.
// //
...@@ -77,7 +77,14 @@ func syncExamples(filePath string, mlines mungeLines) (mungeLines, error) { ...@@ -77,7 +77,14 @@ func syncExamples(filePath string, mlines mungeLines) (mungeLines, error) {
} }
// update all example Tags // update all example Tags
for _, tag := range exampleTags { for _, tag := range exampleTags {
example, err := exampleContent(filePath, tag.linkText, tag.fileType) ft := ""
if tag.fileType == "json" {
ft = "json"
}
if tag.fileType == "yaml" {
ft = "yaml"
}
example, err := exampleContent(filePath, tag.linkText, ft)
if err != nil { if err != nil {
return mlines, err return mlines, err
} }
......
...@@ -34,6 +34,8 @@ spec: ...@@ -34,6 +34,8 @@ spec:
ports: ports:
- containerPort: 80 - containerPort: 80
` `
var textExample = `some text
`
var cases = []struct { var cases = []struct {
in string in string
expected string expected string
...@@ -47,6 +49,10 @@ spec: ...@@ -47,6 +49,10 @@ spec:
"<!-- BEGIN MUNGE: EXAMPLE ../mungedocs/testdata/pod.yaml -->\n<!-- END MUNGE: EXAMPLE ../mungedocs/testdata/pod.yaml -->\n", "<!-- BEGIN MUNGE: EXAMPLE ../mungedocs/testdata/pod.yaml -->\n<!-- END MUNGE: EXAMPLE ../mungedocs/testdata/pod.yaml -->\n",
"<!-- BEGIN MUNGE: EXAMPLE ../mungedocs/testdata/pod.yaml -->\n\n```yaml\n" + podExample + "```\n\n[Download example](../mungedocs/testdata/pod.yaml?raw=true)\n<!-- END MUNGE: EXAMPLE ../mungedocs/testdata/pod.yaml -->\n", "<!-- BEGIN MUNGE: EXAMPLE ../mungedocs/testdata/pod.yaml -->\n\n```yaml\n" + podExample + "```\n\n[Download example](../mungedocs/testdata/pod.yaml?raw=true)\n<!-- END MUNGE: EXAMPLE ../mungedocs/testdata/pod.yaml -->\n",
}, },
{
"<!-- BEGIN MUNGE: EXAMPLE testdata/example.txt -->\n<!-- END MUNGE: EXAMPLE testdata/example.txt -->\n",
"<!-- BEGIN MUNGE: EXAMPLE testdata/example.txt -->\n\n```\n" + textExample + "```\n\n[Download example](testdata/example.txt?raw=true)\n<!-- END MUNGE: EXAMPLE testdata/example.txt -->\n",
},
} }
repoRoot = "" repoRoot = ""
for _, c := range cases { for _, c := range cases {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment