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 {
@@ -87,7 +90,8 @@ func crawlSingleFileForMethods(path string) {
87
90
}
88
91
for _ , fn := range fns {
89
92
fmt .Printf (
90
- "name %s : public %v : params: %s : return values : %s\n " ,
93
+ "ID %d : name %s : public %v : params: %s : return values : %s\n " ,
94
+ fn .ID ,
91
95
fn .Name ,
92
96
fn .Public ,
93
97
fn .InputParams ,
@@ -100,6 +104,36 @@ func extractPublicMethodsFromFile(ctx context.Context, filePath string) ([]c.Fun
100
104
return ex .GetExportedFunctions (ctx , filePath )
101
105
}
102
106
107
+ // makeYAML will make yaml file from public methods.
108
+ func makeYAML (ctx context.Context , filePath string ) ([]byte , error ) {
109
+
110
+ publicMethods , err := extractPublicMethodsFromFile (ctx , filePath )
111
+ if err != nil {
112
+ fmt .Print (err )
113
+ os .Exit (1 )
114
+ }
115
+
116
+ var count int
117
+ for _ , fn := range publicMethods {
118
+ count ++
119
+ fn .ID = count
120
+ publicMethods = append (publicMethods [1 :], fn )
121
+
122
+ }
123
+
124
+ yamlData , err := y .Marshal (& publicMethods )
125
+ if err != nil {
126
+ fmt .Printf ("Error while Marshaling. %v" , err )
127
+ }
128
+
129
+ fileName := "test.yaml"
130
+ err = ioutil .WriteFile (fileName , yamlData , 0644 )
131
+ if err != nil {
132
+ panic ("Unable to write data into the file" )
133
+ }
134
+ return yamlData , nil
135
+ }
136
+
103
137
func linkFiles (flist []c.Function ) (links [][]FnLink ) {
104
138
105
139
functions := make (map [string ]c.Function )
0 commit comments