From: Daniel Swarbrick <dswarbrick@debian.org>
Date: Fri, 14 Jul 2023 19:05:46 +0200
Subject: Disable write-documentation flag / command

Forwarded: not-needed
Last-Update: 2023-07-12

This functionality requires a newer version of the alecthomas/kingpin
package, which has not yet landed in unstable.
---
 cmd/prometheus/main.go          | 10 ----------
 cmd/prometheus/main_test.go     |  1 +
 cmd/promtool/main.go            |  5 -----
 cmd/promtool/main_test.go       |  1 +
 util/documentcli/documentcli.go |  3 +++
 5 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go
index 5a3ab0e..9c6e43a 100644
--- a/cmd/prometheus/main.go
+++ b/cmd/prometheus/main.go
@@ -69,7 +69,6 @@ import (
 	"github.com/prometheus/prometheus/tracing"
 	"github.com/prometheus/prometheus/tsdb"
 	"github.com/prometheus/prometheus/tsdb/agent"
-	"github.com/prometheus/prometheus/util/documentcli"
 	"github.com/prometheus/prometheus/util/logging"
 	prom_runtime "github.com/prometheus/prometheus/util/runtime"
 	"github.com/prometheus/prometheus/web"
@@ -419,15 +418,6 @@ func main() {
 
 	promlogflag.AddFlags(a, &cfg.promlogConfig)
 
-	a.Flag("write-documentation", "Generate command line documentation. Internal use.").Hidden().Action(func(ctx *kingpin.ParseContext) error {
-		if err := documentcli.GenerateMarkdown(a.Model(), os.Stdout); err != nil {
-			os.Exit(1)
-			return err
-		}
-		os.Exit(0)
-		return nil
-	}).Bool()
-
 	_, err := a.Parse(os.Args[1:])
 	if err != nil {
 		fmt.Fprintln(os.Stderr, fmt.Errorf("Error parsing commandline arguments: %w", err))
diff --git a/cmd/prometheus/main_test.go b/cmd/prometheus/main_test.go
index 9270285..9dc0b1c 100644
--- a/cmd/prometheus/main_test.go
+++ b/cmd/prometheus/main_test.go
@@ -486,6 +486,7 @@ func TestModeSpecificFlags(t *testing.T) {
 }
 
 func TestDocumentation(t *testing.T) {
+	t.Skip("Skipping unsupported test")
 	if runtime.GOOS == "windows" {
 		t.SkipNow()
 	}
diff --git a/cmd/promtool/main.go b/cmd/promtool/main.go
index 396d8a9..46628ea 100644
--- a/cmd/promtool/main.go
+++ b/cmd/promtool/main.go
@@ -58,7 +58,6 @@ import (
 	_ "github.com/prometheus/prometheus/plugins" // Register plugins.
 	"github.com/prometheus/prometheus/promql"
 	"github.com/prometheus/prometheus/scrape"
-	"github.com/prometheus/prometheus/util/documentcli"
 )
 
 const (
@@ -233,8 +232,6 @@ func main() {
 
 	featureList := app.Flag("enable-feature", "Comma separated feature names to enable (only PromQL related and no-default-scrape-port). See https://prometheus.io/docs/prometheus/latest/feature_flags/ for the options and more details.").Default("").Strings()
 
-	documentationCmd := app.Command("write-documentation", "Generate command line documentation. Internal use.").Hidden()
-
 	parsedCmd := kingpin.MustParse(app.Parse(os.Args[1:]))
 
 	var p printer
@@ -347,8 +344,6 @@ func main() {
 
 	case importRulesCmd.FullCommand():
 		os.Exit(checkErr(importRules(serverURL, httpRoundTripper, *importRulesStart, *importRulesEnd, *importRulesOutputDir, *importRulesEvalInterval, *maxBlockDuration, *importRulesFiles...)))
-	case documentationCmd.FullCommand():
-		os.Exit(checkErr(documentcli.GenerateMarkdown(app.Model(), os.Stdout)))
 	}
 }
 
diff --git a/cmd/promtool/main_test.go b/cmd/promtool/main_test.go
index 6cfa487..b757810 100644
--- a/cmd/promtool/main_test.go
+++ b/cmd/promtool/main_test.go
@@ -438,6 +438,7 @@ func TestExitCodes(t *testing.T) {
 }
 
 func TestDocumentation(t *testing.T) {
+	t.Skip("Skipping unsupported test")
 	if runtime.GOOS == "windows" {
 		t.SkipNow()
 	}
diff --git a/util/documentcli/documentcli.go b/util/documentcli/documentcli.go
index c199d8d..255f132 100644
--- a/util/documentcli/documentcli.go
+++ b/util/documentcli/documentcli.go
@@ -17,6 +17,9 @@
 // tailored specifically to the way in which the Prometheus documentation is
 // rendered, and should be avoided for use by third-party users.
 
+//go:build ignore
+// +build ignore
+
 package documentcli
 
 import (
