@@ -90,25 +90,29 @@ func buildMarkdown(nodes []rootNode, outputFile string) error {
9090
9191 m := md .NewMarkdown (f )
9292 for _ , node := range nodes {
93+ m = m .LF ()
9394 if node .TopLevel {
9495 m = m .H2 (node .Title )
9596 } else {
9697 m = m .H3 (node .Title )
9798 }
9899 m = m .PlainText (node .Description )
100+ m = m .LF ()
99101
100102 if len (node .ObjectKeyAttributes ) > 0 {
101103 m = buildAttributeTable (m , []attributeNode {
102104 {Title : AdditionalPropertiesAttributeTitle , Type : "Map" , Description : AdditionalPropertiesAttributeDescription },
103105 })
104106 m = m .PlainText ("Each item has the following attributes:" )
107+ m = m .LF ()
105108 m = buildAttributeTable (m , node .ObjectKeyAttributes )
106-
107109 } else if len (node .ArrayItemAttributes ) > 0 {
108- m = m .PlainText (fmt .Sprintf ("Each item of `%s` has the following attributes:" , node .Title ))
110+ m = m .PlainTextf ("Each item of `%s` has the following attributes:" , node .Title )
111+ m = m .LF ()
109112 m = buildAttributeTable (m , node .ArrayItemAttributes )
110113 } else if len (node .Attributes ) > 0 {
111114 m = m .H4 ("Attributes" )
115+ m = m .LF ()
112116 m = buildAttributeTable (m , node .Attributes )
113117 }
114118 }
@@ -122,6 +126,7 @@ func buildMarkdown(nodes []rootNode, outputFile string) error {
122126}
123127
124128func buildAttributeTable (m * md.Markdown , attributes []attributeNode ) * md.Markdown {
129+ return buildCustomAttributeTable (m , attributes )
125130 rows := [][]string {}
126131 for _ , n := range attributes {
127132 rows = append (rows , []string {fmt .Sprintf ("`%s`" , n .Title ), n .Type , formatDescription (n .Description )})
@@ -135,25 +140,26 @@ func buildAttributeTable(m *md.Markdown, attributes []attributeNode) *md.Markdow
135140}
136141
137142func formatDescription (s string ) string {
138- if s == "" {
139- return "-"
140- }
141143 return strings .ReplaceAll (s , "\n " , " " )
142144}
143145
144146// Build a custom table which we use in Databricks website
145147func buildCustomAttributeTable (m * md.Markdown , attributes []attributeNode ) * md.Markdown {
148+ m = m .LF ()
146149 m = m .PlainText (".. list-table::" )
147150 m = m .PlainText (" :header-rows: 1" )
151+ m = m .LF ()
148152
149153 m = m .PlainText (" * - Key" )
150154 m = m .PlainText (" - Type" )
151155 m = m .PlainText (" - Description" )
156+ m = m .LF ()
152157
153158 for _ , a := range attributes {
154159 m = m .PlainText (" * - " + a .Title )
155160 m = m .PlainText (" - " + a .Type )
156- m = m .PlainText (" - " + a .Description )
161+ m = m .PlainText (" - " + formatDescription (a .Description ))
162+ m = m .LF ()
157163 }
158164 return m
159165}
0 commit comments