@@ -40,22 +40,24 @@ func main() {
40
40
filePath := filepath .Dir (filename )
41
41
message ("generating doc from: %s\n " , filePath )
42
42
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 )
47
45
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
+ }
52
51
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
+ }
55
57
}
56
58
57
59
// genIdx generating index for resource
58
- func genIdx (filePath string ) {
60
+ func genIdx (filePath string ) ( prods [] Product ) {
59
61
filename := "provider.go"
60
62
61
63
message ("[START]get description from file: %s\n " , filename )
@@ -81,7 +83,7 @@ func genIdx(filePath string) {
81
83
doc := strings .TrimSpace (description [pos + 16 :])
82
84
// description = strings.TrimSpace(description[:pos])
83
85
84
- prods , err : = GetIndex (doc )
86
+ prods , err = GetIndex (doc )
85
87
if err != nil {
86
88
message ("[FAIL!]: %s" , err )
87
89
os .Exit (1 )
@@ -111,11 +113,13 @@ func genIdx(filePath string) {
111
113
}
112
114
113
115
message ("[SUCC.]write doc to file success: %s" , filename )
116
+ return
114
117
}
115
118
116
119
// 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 ) {
118
121
data := map [string ]string {
122
+ "product" : product ,
119
123
"name" : name ,
120
124
"dtype" : strings .Replace (dtype , "_" , "" , - 1 ),
121
125
"resource" : name [len (cloudMark )+ 1 :],
0 commit comments