Skip to content

Commit

Permalink
Fix getGoDocString for go>=1.13
Browse files Browse the repository at this point in the history
The go documentation formatting has been changed slightly in go 1.13.
This commit takes care of these changes.
  • Loading branch information
JeroenMulkers committed Aug 10, 2020
1 parent 3708c49 commit dae467d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions doc/apigen.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ func getGoDocString(packageName, identifier string) string {
docString := ""
cmd := exec.Command("go", "doc", packageName, identifier)
stdout, err := cmd.Output()
if err == nil && string(stdout)[:4] == "func" { // we only look for doc strings of functions
// the doc string of a function is on the second line
// (and possible continued on the third line, if not, then the third line is empty)
docString = strings.Join(strings.SplitAfterN(string(stdout), "\n", 4)[1:3], " ")
outputLines := strings.Split(string(stdout), "\n")
if err == nil && outputLines[2][:4] == "func" { // we only look for doc strings of functions
// the doc string of a function is on the fourth line
// (and possible continued on the fifth line, if not, then the fifth line is empty)
docString = strings.Join(outputLines[3:5], " ")
}
return docString
}
Expand Down

0 comments on commit dae467d

Please sign in to comment.