Skip to content

Commit cd18cea

Browse files
committed
Expose cmt.FixGrammar for external use
1 parent e68208b commit cd18cea

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

gir/girgen/cmt/cmt.go

+5-8
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ func goDoc(v interface{}, indentLvl int, opts []Option) string {
255255

256256
synopsize := searchOptsBool(opts, synopsize{})
257257

258-
docStr := preprocessMarkdown(self, docBuilder.String(), append(opts, originalTypeName(orig)))
258+
docStr := FixGrammar(self, docBuilder.String(), append(opts, originalTypeName(orig))...)
259259
if synopsize && docStr == "" {
260260
return ""
261261
}
@@ -335,9 +335,7 @@ func writeParamDocs(tail *strings.Builder, label string, params []ParamDoc) {
335335

336336
var doc string
337337
if param.InfoElements.Doc != nil {
338-
doc = preprocessMarkdown(name, param.InfoElements.Doc.String, []Option{
339-
originalTypeName(param.Name),
340-
})
338+
doc = FixGrammar(name, param.InfoElements.Doc.String, originalTypeName(param.Name))
341339
// Insert a dash space into the lines.
342340
doc = transformLines(doc, func(i, _ int, line string) string {
343341
if i == 0 {
@@ -387,10 +385,9 @@ func trimFirstWord(paragraph string) string {
387385
return parts[1]
388386
}
389387

390-
// preprocessMarkdown takes a (GTK-Doc-flavored / GI-DocGen-flavored)
391-
// markdown string makes some stylistic changes to it. The return
392-
// value is still markdown.
393-
func preprocessMarkdown(self, cmt string, opts []Option) string {
388+
// FixGrammar takes a comment and fixes its grammar by adding the [self] name
389+
// where appropriate to make it more idiomatic.
390+
func FixGrammar(self, cmt string, opts ...Option) string {
394391
if cmt == "" {
395392
return ""
396393
}

0 commit comments

Comments
 (0)