Skip to content

Commit 5119be7

Browse files
committed
调整注释
1 parent 1b664cf commit 5119be7

File tree

5 files changed

+211
-215
lines changed

5 files changed

+211
-215
lines changed

gen_context_service_test.go

+14-15
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,19 @@ func TestGenContextService(t *testing.T) {
5656
}
5757

5858
funcName := line[0:strings.Index(line, "(")]
59-
var commandLines []string
60-
var lastComment string
59+
var comment string
6160
var i = row - 1
6261
for {
6362
if !strings.HasPrefix(lines[i], "//") {
6463
break
6564
}
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+
}
6872
i--
6973
}
7074
vv := []rune(funcName)
@@ -74,17 +78,14 @@ func TestGenContextService(t *testing.T) {
7478
if vv[0] >= 97 && vv[0] <= 122 {
7579
continue
7680
}
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) {
8084
continue
8185
}
8286
funcInfo := &context_map.FuncInfo{
8387
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):],
8889
}
8990
fmt.Println(serviceName, ".", funcName)
9091
serviceInfo.FuncList = append(serviceInfo.FuncList, funcInfo)
@@ -104,7 +105,6 @@ func init() {
104105
`
105106
for _, serviceInfo := range serviceList {
106107
comment := serviceInfo.Comment
107-
comment = strings.ReplaceAll(comment, `"`, `\"`)
108108
name := serviceInfo.Name
109109
vv := []rune(name)
110110
if vv[1] >= 97 && vv[1] <= 122 {
@@ -113,12 +113,11 @@ func init() {
113113
genContent += `
114114
` + serviceInfo.Module + `.Service = &context_map.ServiceInfo{
115115
Name: "` + name + `",
116-
Comment: "` + comment + `",
116+
Comment: ` + "`" + comment + "`" + `,
117117
FuncList: []*context_map.FuncInfo{
118118
`
119119
for _, funcInfo := range serviceInfo.FuncList {
120120
comment := funcInfo.Comment
121-
comment = strings.ReplaceAll(comment, `"`, `\"`)
122121
name := funcInfo.Name
123122
vv := []rune(name)
124123
if vv[1] >= 97 && vv[1] <= 122 {
@@ -127,7 +126,7 @@ func init() {
127126
genContent += `
128127
{
129128
Name: "` + name + `",
130-
Comment: "` + comment + `",
129+
Comment: ` + "`" + comment + "`" + `,
131130
},`
132131
fmt.Println(serviceInfo.Name, ".", funcInfo.Name, ":", funcInfo.Comment)
133132
}

gen_func_util_test.go

+5-8
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,18 @@ func TestGenFuncUtil(t *testing.T) {
3434
continue
3535
}
3636
funcName := line[len("func "):strings.Index(line, "(")]
37-
var commandLines []string
38-
var startComment string
3937
var comment string
4038
var i = row - 1
4139
for {
4240
if !strings.HasPrefix(lines[i], "//") {
4341
break
4442
}
45-
startComment = lines[i]
46-
startComment = strings.TrimSpace(startComment[2:])
47-
commandLines = append(commandLines, startComment)
43+
str := lines[i]
44+
str = strings.TrimSpace(str[2:])
4845
if comment != "" {
49-
comment = startComment + "\n" + comment
46+
comment = str + "\n" + comment
5047
} else {
51-
comment = startComment
48+
comment = str
5249
}
5350
i--
5451
}
@@ -91,7 +88,7 @@ func init() {
9188
`
9289
for _, funcInfo := range funcInfoList {
9390
comment := funcInfo.Comment
94-
comment = strings.ReplaceAll(comment, `"`, `\"`)
91+
//comment = strings.ReplaceAll(comment, `"`, `\"`)
9592
name := funcInfo.Name
9693
vv := []rune(name)
9794
if vv[1] >= 97 && vv[1] <= 122 {

0 commit comments

Comments
 (0)