package api_gen import ( "bytes" "os" "path/filepath" "text/template" ) func generateDocs(outputDir string, pkg *APIPackage) error { tmpl := `# API Documentation {{- range .Endpoints}} ## {{.Method}} {{.Path}} {{- end}} ` tmplObj := template.Must(template.New("docs").Parse(tmpl)) var buf bytes.Buffer if err := tmplObj.Execute(&buf, pkg); err != nil { return err } return os.WriteFile(filepath.Join(outputDir, "API.md"), buf.Bytes(), 0644) }