mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
promtool docs: write flags between backtits in help
Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
This commit is contained in:
parent
b3b669fd9a
commit
fd5b01afdc
|
@ -615,7 +615,7 @@ Create blocks of data for new recording rules.
|
|||
|
||||
### `promtool promql`
|
||||
|
||||
PromQL formatting and editing. Requires the --experimental flag.
|
||||
PromQL formatting and editing. Requires the `--experimental` flag.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/grafana/regexp"
|
||||
)
|
||||
|
||||
// GenerateMarkdown generates the markdown documentation for an application from
|
||||
|
@ -230,6 +231,7 @@ func writeSubcommands(writer io.Writer, level int, modelName string, commands []
|
|||
if cmd.HelpLong != "" {
|
||||
help = cmd.HelpLong
|
||||
}
|
||||
help = formatHyphenatedWords(help)
|
||||
if _, err := writer.Write([]byte(fmt.Sprintf("\n\n%s `%s %s`\n\n%s\n\n", strings.Repeat("#", level+1), modelName, cmd.FullCommand, help))); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -250,3 +252,11 @@ func writeSubcommands(writer io.Writer, level int, modelName string, commands []
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func formatHyphenatedWords(input string) string {
|
||||
hyphenRegex := regexp.MustCompile(`\B--\w+\b`)
|
||||
replacer := func(s string) string {
|
||||
return fmt.Sprintf("`%s`", s)
|
||||
}
|
||||
return hyphenRegex.ReplaceAllStringFunc(input, replacer)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue