docs: add a new page with global flags and link to it from the command docs

In f544234 we removed the global flags from each command as it was
making each page very big and causing 1000s of lines of duplication in
the man page.

This change adds a new flags page with all the global flags on and
links each command page to it.

Fixes #3273
This commit is contained in:
Nick Craig-Wood 2019-06-20 16:18:02 +01:00
parent 71a19a1972
commit 4ee6de5c3e
71 changed files with 640 additions and 135 deletions

View file

@ -33,6 +33,7 @@ documentation, changelog and configuration walkthroughs.
atexit.Run()
},
BashCompletionFunction: bashCompletionFunc,
DisableAutoGenTag: true,
}
const (
@ -74,6 +75,10 @@ __rclone_custom_func() {
`
)
// GeneratingDocs is set by rclone gendocs to alter the format of the
// output suitable for the documentation.
var GeneratingDocs = false
// root help command
var helpCommand = &cobra.Command{
Use: "help",
@ -100,7 +105,11 @@ var helpFlags = &cobra.Command{
}
flagsRe = re
}
Root.SetOutput(os.Stdout)
if GeneratingDocs {
Root.SetUsageTemplate(docFlagsTemplate)
} else {
Root.SetOutput(os.Stdout)
}
_ = command.Usage()
},
}
@ -222,6 +231,35 @@ Use "rclone help flags" for to see the global flags.
Use "rclone help backends" for a list of supported services.
`
var docFlagsTemplate = `---
title: "Global Flags"
description: "Rclone Global Flags"
date: "YYYY-MM-DD"
---
# Global Flags
This describes the global flags available to every rclone command
split into two groups, non backend and backend flags.
## Non Backend Flags
These flags are available for every command.
` + "```" + `
{{(backendFlags . false).FlagUsages | trimTrailingWhitespaces}}
` + "```" + `
## Backend Flags
These flags are available for every command. They control the backends
and may be set in the config file.
` + "```" + `
{{(backendFlags . true).FlagUsages | trimTrailingWhitespaces}}
` + "```" + `
`
// show all the backends
func showBackends() {
fmt.Printf("All rclone backends:\n\n")