MCPcopy Index your code
hub / github.com/cloudquery/cloudquery / renderTable

Method renderTable

cli/internal/docs/markdown.go:58–79  ·  view source on GitHub ↗
(dir string, table *schema.Table)

Source from the content-addressed store, hash-verified

56}
57
58func (*Generator) renderTable(dir string, table *schema.Table) error {
59 t := template.New("")
60 t, err := t.New("table.md.go.tpl").ParseFS(templatesFS, "templates/table.md.go.tpl")
61 if err != nil {
62 return fmt.Errorf("failed to parse template: %v", err)
63 }
64
65 outputPath := filepath.Join(dir, table.Name+".md")
66
67 var b bytes.Buffer
68 if err := t.Execute(&b, table); err != nil {
69 return fmt.Errorf("failed to execute template: %v", err)
70 }
71 content := formatMarkdown(b.String())
72 f, err := os.Create(outputPath)
73 if err != nil {
74 return fmt.Errorf("failed to create file %v: %v", outputPath, err)
75 }
76 defer f.Close()
77 f.WriteString(content)
78 return f.Close()
79}
80
81func formatMarkdown(s string) string {
82 s = reMatchNewlines.ReplaceAllString(s, "\n\n")

Callers 1

renderAllTablesMethod · 0.95

Calls 4

formatMarkdownFunction · 0.85
ErrorfMethod · 0.80
CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected