github.com/mineiros-io/terradoc@v0.0.9-0.20220711062319-018bd4ae81f5/internal/entities/doc.go (about) 1 package entities 2 3 // Doc represents a parsed source file. 4 type Doc struct { 5 // Header is the header section block from the source file 6 Header Header 7 // Sections is a collection of sections defined in the source file. 8 Sections []Section `json:"sections"` 9 // References is a collection of references defined in the source file. 10 References []Reference `json:"references"` 11 } 12 13 // Header represents the `header` block on the parsed source file 14 type Header struct { 15 Image string `json:"image"` // Image is the image url to be displayed on the header 16 URL string `json:"url"` // URL is the target url for the image 17 Badges []Badge `json:"badges"` // Badges is a collection of Badge entities 18 } 19 20 // Badge represents a `badge` block on the parsed source file 21 type Badge struct { 22 Image string `json:"image"` // Image is the badge's image url 23 URL string `json:"url"` // URL is the target url for the badge 24 Text string `json:"text"` // Text is the text label for the badge 25 Name string `json:"name"` // Name is an identifier for the badge 26 } 27 28 func (d Doc) AllVariables() (result []Variable) { 29 for _, s := range d.Sections { 30 result = append(result, s.AllVariables()...) 31 } 32 33 return result 34 } 35 36 func (d Doc) AllOutputs() (result []Output) { 37 for _, s := range d.Sections { 38 result = append(result, s.AllOutputs()...) 39 } 40 41 return result 42 }