@@ -56,15 +56,19 @@ func TestGenContextService(t *testing.T) {
56
56
}
57
57
58
58
funcName := line [0 :strings .Index (line , "(" )]
59
- var commandLines []string
60
- var lastComment string
59
+ var comment string
61
60
var i = row - 1
62
61
for {
63
62
if ! strings .HasPrefix (lines [i ], "//" ) {
64
63
break
65
64
}
66
- lastComment = lines [i ]
67
- commandLines = append (commandLines , lastComment )
65
+ str := lines [i ]
66
+ str = strings .TrimSpace (str [2 :])
67
+ if comment != "" {
68
+ comment = str + "\n " + comment
69
+ } else {
70
+ comment = str
71
+ }
68
72
i --
69
73
}
70
74
vv := []rune (funcName )
@@ -74,17 +78,14 @@ func TestGenContextService(t *testing.T) {
74
78
if vv [0 ] >= 97 && vv [0 ] <= 122 {
75
79
continue
76
80
}
77
- var fS = "// " + funcName + " "
78
- //fmt.Println("lastComment", lastComment, ",fS", fS)
79
- if ! strings .HasPrefix (lastComment , fS ) {
81
+ fmt . Println ( comment )
82
+ var fS = funcName + " "
83
+ if ! strings .HasPrefix (comment , fS ) {
80
84
continue
81
85
}
82
86
funcInfo := & context_map.FuncInfo {
83
87
Name : funcName ,
84
- Comment : lastComment [len (fS ):],
85
- }
86
- for i = len (commandLines ) - 1 ; i >= 0 ; i -- {
87
- fmt .Println (commandLines [i ])
88
+ Comment : comment [len (fS ):],
88
89
}
89
90
fmt .Println (serviceName , "." , funcName )
90
91
serviceInfo .FuncList = append (serviceInfo .FuncList , funcInfo )
@@ -104,7 +105,6 @@ func init() {
104
105
`
105
106
for _ , serviceInfo := range serviceList {
106
107
comment := serviceInfo .Comment
107
- comment = strings .ReplaceAll (comment , `"` , `\"` )
108
108
name := serviceInfo .Name
109
109
vv := []rune (name )
110
110
if vv [1 ] >= 97 && vv [1 ] <= 122 {
@@ -113,12 +113,11 @@ func init() {
113
113
genContent += `
114
114
` + serviceInfo .Module + `.Service = &context_map.ServiceInfo{
115
115
Name: "` + name + `",
116
- Comment: "` + comment + `" ,
116
+ Comment: ` + "`" + comment + "`" + ` ,
117
117
FuncList: []*context_map.FuncInfo{
118
118
`
119
119
for _ , funcInfo := range serviceInfo .FuncList {
120
120
comment := funcInfo .Comment
121
- comment = strings .ReplaceAll (comment , `"` , `\"` )
122
121
name := funcInfo .Name
123
122
vv := []rune (name )
124
123
if vv [1 ] >= 97 && vv [1 ] <= 122 {
@@ -127,7 +126,7 @@ func init() {
127
126
genContent += `
128
127
{
129
128
Name: "` + name + `",
130
- Comment: "` + comment + `" ,
129
+ Comment: ` + "`" + comment + "`" + ` ,
131
130
},`
132
131
fmt .Println (serviceInfo .Name , "." , funcInfo .Name , ":" , funcInfo .Comment )
133
132
}
0 commit comments