@@ -40,22 +40,24 @@ func main() {
4040 filePath := filepath .Dir (filename )
4141 message ("generating doc from: %s\n " , filePath )
4242
43- // document for DataSources
44- for k , v := range provider .DataSourcesMap {
45- genDoc ("data_source" , filePath , k , v )
46- }
43+ // document for Index
44+ products := genIdx (filePath )
4745
48- // document for Resources
49- for k , v := range provider .ResourcesMap {
50- genDoc ("resource" , filePath , k , v )
51- }
46+ for _ , product := range products {
47+ // document for DataSources
48+ for _ , dataSource := range product .DataSources {
49+ genDoc (product .Name , "data_source" , filePath , dataSource , provider .DataSourcesMap [dataSource ])
50+ }
5251
53- // document for Index
54- genIdx (filePath )
52+ // document for Resources
53+ for _ , resource := range product .Resources {
54+ genDoc (product .Name , "resource" , filePath , resource , provider .ResourcesMap [resource ])
55+ }
56+ }
5557}
5658
5759// genIdx generating index for resource
58- func genIdx (filePath string ) {
60+ func genIdx (filePath string ) ( prods [] Product ) {
5961 filename := "provider.go"
6062
6163 message ("[START]get description from file: %s\n " , filename )
@@ -81,7 +83,7 @@ func genIdx(filePath string) {
8183 doc := strings .TrimSpace (description [pos + 16 :])
8284 // description = strings.TrimSpace(description[:pos])
8385
84- prods , err : = GetIndex (doc )
86+ prods , err = GetIndex (doc )
8587 if err != nil {
8688 message ("[FAIL!]: %s" , err )
8789 os .Exit (1 )
@@ -111,11 +113,13 @@ func genIdx(filePath string) {
111113 }
112114
113115 message ("[SUCC.]write doc to file success: %s" , filename )
116+ return
114117}
115118
116119// genDoc generating doc for data source and resource
117- func genDoc (dtype , fpath , name string , resource * schema.Resource ) {
120+ func genDoc (product , dtype , fpath , name string , resource * schema.Resource ) {
118121 data := map [string ]string {
122+ "product" : product ,
119123 "name" : name ,
120124 "dtype" : strings .Replace (dtype , "_" , "" , - 1 ),
121125 "resource" : name [len (cloudMark )+ 1 :],
0 commit comments