From 5e74bfef8dddcac6537bd55ac9ea3fe83bc22c50 Mon Sep 17 00:00:00 2001 From: Theo Chatzimichos Date: Sat, 30 May 2026 01:02:07 +0200 Subject: [PATCH] fix(docs): compile the bqRE once at package level Avoids recompiling the regex on every call to normalizeDetail, slightly improving the speed. Signed-off-by: Theo Chatzimichos --- cmd/crossplane/docs.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/crossplane/docs.go b/cmd/crossplane/docs.go index fd04a82..a60daf0 100644 --- a/cmd/crossplane/docs.go +++ b/cmd/crossplane/docs.go @@ -35,6 +35,9 @@ import ( //go:embed docs-templates/command-reference.md.tmpl var docsTmpl string +// bqRE matches the opening of a special blockquote: > **Word:** text. +var bqRE = regexp.MustCompile(`^> \*\*(\w+):\*\* `) + type docsCmd struct { OutputFile string `default:"command-reference.md" help:"Path to write the generated command-reference markdown file." name:"output-file" short:"o" type:"path"` @@ -203,7 +206,6 @@ func normalizeDetail(detail string, headingLevel int) string { } // Convert special blockquotes into pretty Hugo blocks. - bqRE := regexp.MustCompile(`^> \*\*(\w+):\*\* `) bqMatch := bqRE.FindStringSubmatch(line) if bqMatch != nil { // Omit the feature enablement message from the top-level command