5
5
"context"
6
6
"encoding/json"
7
7
"fmt"
8
+ "io/ioutil"
8
9
"os"
9
10
"os/exec"
10
11
"strings"
@@ -13,6 +14,8 @@ import (
13
14
a "testsuites/annotations"
14
15
c "testsuites/collector"
15
16
ex "testsuites/extractor"
17
+
18
+ y "gopkg.in/yaml.v2"
16
19
)
17
20
18
21
type FnLink struct {
@@ -27,6 +30,7 @@ func main() {
27
30
config := NewConfig ()
28
31
29
32
crawlRepoBehaviorsAndSaveToJSON (config )
33
+
30
34
}
31
35
32
36
func crawlRepoBehaviorsAndSaveToJSON (config Config ) {
@@ -87,7 +91,8 @@ func crawlSingleFileForMethods(path string) {
87
91
}
88
92
for _ , fn := range fns {
89
93
fmt .Printf (
90
- "name %s : public %v : params: %s : return values : %s\n " ,
94
+ "ID %d : name %s : public %v : params: %s : return values : %s\n " ,
95
+ fn .ID ,
91
96
fn .Name ,
92
97
fn .Public ,
93
98
fn .InputParams ,
@@ -100,6 +105,32 @@ func extractPublicMethodsFromFile(ctx context.Context, filePath string) ([]c.Fun
100
105
return ex .GetExportedFunctions (ctx , filePath )
101
106
}
102
107
108
+ // makeYAML will make yaml file from public methods.
109
+ func makeYAML (ctx context.Context , filePath string ) error {
110
+
111
+ publicMethods , err := extractPublicMethodsFromFile (ctx , filePath )
112
+ if err != nil {
113
+ fmt .Print (err )
114
+ os .Exit (1 )
115
+ }
116
+
117
+ for i := 0 ; i < len (publicMethods ); i ++ {
118
+ publicMethods [i ].ID = i
119
+ }
120
+
121
+ yamlData , err := y .Marshal (& publicMethods )
122
+ if err != nil {
123
+ fmt .Printf ("Error while Marshaling. %v" , err )
124
+ }
125
+
126
+ fileName := "test.yaml"
127
+ err = ioutil .WriteFile (fileName , yamlData , 0644 )
128
+ if err != nil {
129
+ panic ("Unable to write data into the file" )
130
+ }
131
+ return nil
132
+ }
133
+
103
134
func linkFiles (flist []c.Function ) (links [][]FnLink ) {
104
135
105
136
functions := make (map [string ]c.Function )
0 commit comments