mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
examples munger allows any file extension.
This commit is contained in:
parent
ec1ba7438f
commit
21f81935e2
@ -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) {
|
|||||||
}
|
}
|
||||||
// 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
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@ spec:
|
|||||||
image: nginx
|
image: nginx
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 80
|
||||||
|
`
|
||||||
|
var textExample = `some text
|
||||||
`
|
`
|
||||||
var cases = []struct {
|
var cases = []struct {
|
||||||
in string
|
in string
|
||||||
@ -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 {
|
||||||
|
1
cmd/mungedocs/testdata/example.txt
vendored
Normal file
1
cmd/mungedocs/testdata/example.txt
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
some text
|
Loading…
Reference in New Issue
Block a user