File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -234,10 +234,20 @@ type TemplateData struct {
234234 EntityNamePlural string
235235 EntityFields []EntityField
236236
237+ // Entities (for documentation generation)
238+ Entities []EntityInfo
239+
237240 // Computed
238241 Timestamp string
239242}
240243
244+ // EntityInfo represents entity information for documentation
245+ type EntityInfo struct {
246+ Name string
247+ PluralName string
248+ Fields []EntityField
249+ }
250+
241251// EntityField represents a field in an entity
242252type EntityField struct {
243253 Name string
@@ -569,6 +579,7 @@ func loadTemplate(name string) (*template.Template, error) {
569579 "trimSuffix" : strings .TrimSuffix ,
570580 "trimPrefix" : strings .TrimPrefix ,
571581 "add" : func (a , b int ) int { return a + b },
582+ "isLast" : func (i int , slice interface {}) bool { return isLastIndex (i , slice ) },
572583 }
573584
574585 if templateDir != "" {
@@ -687,3 +698,17 @@ func pluralize(s string) string {
687698 }
688699 return s + "s"
689700}
701+
702+ // isLastIndex checks if the index is the last element in a slice
703+ func isLastIndex (i int , slice interface {}) bool {
704+ switch s := slice .(type ) {
705+ case []EntityField :
706+ return i == len (s )- 1
707+ case []EntityInfo :
708+ return i == len (s )- 1
709+ case []string :
710+ return i == len (s )- 1
711+ default :
712+ return false
713+ }
714+ }
You can’t perform that action at this time.
0 commit comments