docs: add badge showing version introduced and experimental/beta/deprecated status to command doc pages
This commit is contained in:
parent
d05fd2a14f
commit
d74662a751
1 changed files with 20 additions and 8 deletions
|
@ -31,6 +31,7 @@ type frontmatter struct {
|
||||||
Slug string
|
Slug string
|
||||||
URL string
|
URL string
|
||||||
Source string
|
Source string
|
||||||
|
Annotations map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
var frontmatterTemplate = template.Must(template.New("frontmatter").Parse(`---
|
var frontmatterTemplate = template.Must(template.New("frontmatter").Parse(`---
|
||||||
|
@ -38,6 +39,9 @@ title: "{{ .Title }}"
|
||||||
description: "{{ .Description }}"
|
description: "{{ .Description }}"
|
||||||
slug: {{ .Slug }}
|
slug: {{ .Slug }}
|
||||||
url: {{ .URL }}
|
url: {{ .URL }}
|
||||||
|
{{- range $key, $value := .Annotations }}
|
||||||
|
{{ $key }}: {{ $value }}
|
||||||
|
{{- end }}
|
||||||
# autogenerated - DO NOT EDIT, instead edit the source code in {{ .Source }} and as part of making a release run "make commanddocs"
|
# autogenerated - DO NOT EDIT, instead edit the source code in {{ .Source }} and as part of making a release run "make commanddocs"
|
||||||
---
|
---
|
||||||
`))
|
`))
|
||||||
|
@ -75,17 +79,24 @@ rclone.org website.`,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look up name => description for prepender
|
// Look up name => details for prepender
|
||||||
var description = map[string]string{}
|
type commandDetails struct {
|
||||||
var addDescription func(root *cobra.Command)
|
Short string
|
||||||
addDescription = func(root *cobra.Command) {
|
Annotations map[string]string
|
||||||
|
}
|
||||||
|
var commands = map[string]commandDetails{}
|
||||||
|
var addCommandDetails func(root *cobra.Command)
|
||||||
|
addCommandDetails = func(root *cobra.Command) {
|
||||||
name := strings.ReplaceAll(root.CommandPath(), " ", "_") + ".md"
|
name := strings.ReplaceAll(root.CommandPath(), " ", "_") + ".md"
|
||||||
description[name] = root.Short
|
commands[name] = commandDetails{
|
||||||
|
Short: root.Short,
|
||||||
|
Annotations: root.Annotations,
|
||||||
|
}
|
||||||
for _, c := range root.Commands() {
|
for _, c := range root.Commands() {
|
||||||
addDescription(c)
|
addCommandDetails(c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addDescription(cmd.Root)
|
addCommandDetails(cmd.Root)
|
||||||
|
|
||||||
// markup for the docs files
|
// markup for the docs files
|
||||||
prepender := func(filename string) string {
|
prepender := func(filename string) string {
|
||||||
|
@ -94,10 +105,11 @@ rclone.org website.`,
|
||||||
data := frontmatter{
|
data := frontmatter{
|
||||||
Date: now,
|
Date: now,
|
||||||
Title: strings.ReplaceAll(base, "_", " "),
|
Title: strings.ReplaceAll(base, "_", " "),
|
||||||
Description: description[name],
|
Description: commands[name].Short,
|
||||||
Slug: base,
|
Slug: base,
|
||||||
URL: "/commands/" + strings.ToLower(base) + "/",
|
URL: "/commands/" + strings.ToLower(base) + "/",
|
||||||
Source: strings.ReplaceAll(strings.ReplaceAll(base, "rclone", "cmd"), "_", "/") + "/",
|
Source: strings.ReplaceAll(strings.ReplaceAll(base, "rclone", "cmd"), "_", "/") + "/",
|
||||||
|
Annotations: commands[name].Annotations,
|
||||||
}
|
}
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
err := frontmatterTemplate.Execute(&buf, data)
|
err := frontmatterTemplate.Execute(&buf, data)
|
||||||
|
|
Loading…
Reference in a new issue