diff --git a/cmd/gendocs/gendocs.go b/cmd/gendocs/gendocs.go index 4965aa7a3..4c5417abc 100644 --- a/cmd/gendocs/gendocs.go +++ b/cmd/gendocs/gendocs.go @@ -31,6 +31,7 @@ type frontmatter struct { Slug string URL string Source string + Annotations map[string]string } var frontmatterTemplate = template.Must(template.New("frontmatter").Parse(`--- @@ -38,6 +39,9 @@ title: "{{ .Title }}" description: "{{ .Description }}" slug: {{ .Slug }} 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" --- `)) @@ -75,17 +79,24 @@ rclone.org website.`, return err } - // Look up name => description for prepender - var description = map[string]string{} - var addDescription func(root *cobra.Command) - addDescription = func(root *cobra.Command) { + // Look up name => details for prepender + type commandDetails struct { + Short string + 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" - description[name] = root.Short + commands[name] = commandDetails{ + Short: root.Short, + Annotations: root.Annotations, + } for _, c := range root.Commands() { - addDescription(c) + addCommandDetails(c) } } - addDescription(cmd.Root) + addCommandDetails(cmd.Root) // markup for the docs files prepender := func(filename string) string { @@ -94,10 +105,11 @@ rclone.org website.`, data := frontmatter{ Date: now, Title: strings.ReplaceAll(base, "_", " "), - Description: description[name], + Description: commands[name].Short, Slug: base, URL: "/commands/" + strings.ToLower(base) + "/", Source: strings.ReplaceAll(strings.ReplaceAll(base, "rclone", "cmd"), "_", "/") + "/", + Annotations: commands[name].Annotations, } var buf bytes.Buffer err := frontmatterTemplate.Execute(&buf, data)