2024-05-07 13:03:20 +00:00
|
|
|
//go:build generate
|
|
|
|
// +build generate
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"flag"
|
|
|
|
"net/http"
|
|
|
|
"os"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/thegeeklab/wp-github-comment/plugin"
|
2024-05-17 19:50:16 +00:00
|
|
|
plugin_docs "github.com/thegeeklab/wp-plugin-go/v3/docs"
|
|
|
|
plugin_template "github.com/thegeeklab/wp-plugin-go/v3/template"
|
2024-05-07 13:03:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
tmpl := "https://raw.githubusercontent.com/thegeeklab/woodpecker-plugins/main/templates/docs-data.yaml.tmpl"
|
|
|
|
client := http.Client{
|
|
|
|
Timeout: 30 * time.Second,
|
|
|
|
}
|
|
|
|
|
|
|
|
p := plugin.New(nil)
|
|
|
|
|
2024-05-17 19:50:16 +00:00
|
|
|
out, err := plugin_template.Render(context.Background(), client, tmpl, plugin_docs.GetTemplateData(p.App))
|
2024-05-07 13:03:20 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
outputFile := flag.String("output", "", "Output file path")
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
if *outputFile == "" {
|
|
|
|
panic("no output file specified")
|
|
|
|
}
|
|
|
|
|
|
|
|
err = os.WriteFile(*outputFile, []byte(out), 0o644)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|