@@ -24,6 +24,9 @@ var headerBuilders = map[string]fileHeaderBuildFunc{
2424
2525 ".rs" : singleCStyle ,
2626
27+ ".cs" : singleCStyle ,
28+ ".css" : multiCStyle ,
29+
2730 ".c" : singleCStyle ,
2831 ".cxx" : singleCStyle ,
2932 ".cc" : singleCStyle ,
@@ -34,20 +37,22 @@ var headerBuilders = map[string]fileHeaderBuildFunc{
3437 ".m" : singleCStyle ,
3538
3639 ".java" : singleCStyle ,
37- ".kt" : singleCStyle ,
38- ".kts" : singleCStyle ,
40+ ".kt" : singleCStyle ,
41+ ".kts" : singleCStyle ,
3942
4043 ".swift" : singleCStyle ,
4144
4245 ".py" : singlePythonStyle ,
4346
44- ".sh" : singlePythonStyle ,
45- ".rb" : singlePythonStyle ,
46- ".ps1" : singlePythonStyle ,
47+ ".clj" : func (s []string ) string { return singleStyle ([]byte ("; " ), s ) },
48+
49+ ".sh" : singlePythonStyle ,
50+ ".rb" : singlePythonStyle ,
51+ ".ps1" : singlePythonStyle ,
4752 ".psm1" : singlePythonStyle ,
4853
4954 ".yaml" : singlePythonStyle ,
50- ".yml" : singlePythonStyle ,
55+ ".yml" : singlePythonStyle ,
5156 ".toml" : singlePythonStyle ,
5257}
5358
@@ -109,18 +114,43 @@ func singleCStyle(s []string) string { return singleStyle([]byte("// "), s) }
109114
110115func singlePythonStyle (s []string ) string { return singleStyle ([]byte ("# " ), s ) }
111116
117+ func multiCStyle (s []string ) string {
118+ return multiStyle ([]byte ("/*" ), []byte (" */" ), []byte (" * " ), s )
119+ }
120+
112121func singleStyle (prefix []byte , s []string ) string {
113- var l = 0
122+ l := 5 * len (s )
123+ for _ , v := range s {
124+ l += len (v )
125+ }
126+
127+ b := make ([]byte , 0 , l )
128+ for _ , v := range s {
129+ b = append (b , prefix ... )
130+ b = append (b , v ... )
131+ b = append (b , '\n' )
132+ }
133+ b = append (b , '\n' ) // 空行
134+
135+ return string (b )
136+ }
137+
138+ func multiStyle (start , end , prefix []byte , s []string ) string {
139+ l := + 5 * len (s ) + len (start ) + len (end )
114140 for _ , v := range s {
115141 l += len (v )
116142 }
117143
118- b := make ([]byte , 0 , l + 5 * len (s ))
144+ b := make ([]byte , 0 , l )
145+ b = append (b , start ... )
146+ b = append (b , '\n' )
119147 for _ , v := range s {
120148 b = append (b , prefix ... )
121149 b = append (b , v ... )
122150 b = append (b , '\n' )
123151 }
152+ b = append (b , end ... )
153+ b = append (b , '\n' ) // 换行
124154 b = append (b , '\n' ) // 空行
125155
126156 return string (b )
0 commit comments