Skip to content

Commit 2773bb9

Browse files
committedNov 19, 2020
added format_comment_line - single line comment
1 parent 2e371cf commit 2773bb9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
 

‎render/render.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"go/doc"
77
"html/template"
8+
"strings"
89

910
"github.com/fatih/structtag"
1011
"github.com/gobuffalo/plush"
@@ -22,7 +23,7 @@ func Render(template string, def parser.Definition, params map[string]interface{
2223
ctx.Set("def", def)
2324
ctx.Set("params", params)
2425
ctx.Set("json", toJSONHelper)
25-
ctx.Set("format_comment", formatComment)
26+
ctx.Set("format_comment_line", formatCommentLine)
2627
ctx.Set("format_comment_text", formatCommentText)
2728
ctx.Set("format_comment_html", formatCommentHTML)
2829
ctx.Set("format_tags", formatTags)
@@ -41,10 +42,11 @@ func toJSONHelper(v interface{}) (template.HTML, error) {
4142
return template.HTML(b), nil
4243
}
4344

44-
func formatComment(s string, linePrefix string) template.HTML {
45+
func formatCommentLine(s string) template.HTML {
4546
var buf bytes.Buffer
46-
doc.ToText(&buf, s, linePrefix, linePrefix, 80)
47-
return template.HTML(buf.String())
47+
doc.ToText(&buf, s, "", "", 2000)
48+
s = strings.TrimSpace(buf.String())
49+
return template.HTML(s)
4850
}
4951

5052
func formatCommentText(s string) template.HTML {

0 commit comments

Comments
 (0)
Please sign in to comment.