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: 2025-02-08

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            |  6 ------
 cmd/promtool/main_test.go       |  1 +
 util/documentcli/documentcli.go |  3 +++
 5 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go
index f2c88c9..646d7da 100644
--- a/cmd/prometheus/main.go
+++ b/cmd/prometheus/main.go
@@ -77,7 +77,6 @@ import (
 	"github.com/prometheus/prometheus/tsdb"
 	"github.com/prometheus/prometheus/tsdb/agent"
 	"github.com/prometheus/prometheus/tsdb/wlog"
-	"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"
@@ -471,15 +470,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 command line arguments: %w", err))
diff --git a/cmd/prometheus/main_test.go b/cmd/prometheus/main_test.go
index 6cb53db..3202d2c 100644
--- a/cmd/prometheus/main_test.go
+++ b/cmd/prometheus/main_test.go
@@ -474,6 +474,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 c091c87..c5a9e32 100644
--- a/cmd/promtool/main.go
+++ b/cmd/promtool/main.go
@@ -59,7 +59,6 @@ import (
 	"github.com/prometheus/prometheus/promql/parser"
 	"github.com/prometheus/prometheus/promql/promqltest"
 	"github.com/prometheus/prometheus/scrape"
-	"github.com/prometheus/prometheus/util/documentcli"
 )
 
 const (
@@ -286,8 +285,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
@@ -411,9 +408,6 @@ func main() {
 	case queryAnalyzeCmd.FullCommand():
 		os.Exit(checkErr(queryAnalyzeCfg.run(serverURL, httpRoundTripper)))
 
-	case documentationCmd.FullCommand():
-		os.Exit(checkErr(documentcli.GenerateMarkdown(app.Model(), os.Stdout)))
-
 	case promQLFormatCmd.FullCommand():
 		checkExperimental(*experimental)
 		os.Exit(checkErr(formatPromQL(*promQLFormatQuery)))
diff --git a/cmd/promtool/main_test.go b/cmd/promtool/main_test.go
index 78500fe..909e336 100644
--- a/cmd/promtool/main_test.go
+++ b/cmd/promtool/main_test.go
@@ -439,6 +439,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 720a7c9..417494a 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 (
