Skip to content

Commit

Permalink
Don't add "autogenerate" comment by default
Browse files Browse the repository at this point in the history
Having such a comment in the final docs HTML might be undesirable, and this is
the case e.g. when the markdown is rendered with Hugo. Additionally, if metrics
from multiple targets are compiled into one reference file, then it would
include redundant comments.

The "autogenerated" comment can still be enabled with a config option.

Signed-off-by: Anna Kapuscinska <[email protected]>
  • Loading branch information
lambdanis committed Mar 1, 2024
1 parent bdb31b4 commit 7f0ee42
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 5 additions & 4 deletions pkg/metricsmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ type LabelOverrides struct {
}

type Config struct {
CobraAnnotations map[string]string
Targets map[string]string // cli argument -> docs header
LabelOverrides []LabelOverrides
InitMetrics func(target string, reg *prometheus.Registry, log *slog.Logger) error
CobraAnnotations map[string]string
Targets map[string]string // cli argument -> docs header
LabelOverrides []LabelOverrides
InitMetrics func(target string, reg *prometheus.Registry, log *slog.Logger) error
AutogeneratedComment bool
}
6 changes: 4 additions & 2 deletions pkg/metricsmd/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ func NewCmd(vp *viper.Viper, log *slog.Logger, config *Config) *cobra.Command {
}

var b bytes.Buffer
// Comment to inform people this file is autogenerated.
b.WriteString("<!-- This file is autogenerated via https://github.com/isovalent/metricstool -->\n\n")
if config.AutogeneratedComment {
// Comment to inform people this file is autogenerated.
b.WriteString("<!-- This file is autogenerated via https://github.com/isovalent/metricstool -->\n\n")
}
// Document title
b.WriteString(fmt.Sprintf("# %s Metrics\n\n", config.Targets[target]))
// Generate metrics reference
Expand Down

0 comments on commit 7f0ee42

Please sign in to comment.