Implement parameter comment parsing
This commit is contained in:
31
class.go
31
class.go
@@ -385,7 +385,36 @@ func parseMethod(s *goquery.Selection) (Method, error) {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
log.Printf("%#v", state)
|
||||
if s.Is("div.indented") && state == 1 {
|
||||
log.Printf("%#v", state)
|
||||
parameter := ""
|
||||
html, err := s.Html()
|
||||
if err != nil {
|
||||
Error.Printf("Error parsing html: %v", err)
|
||||
return
|
||||
}
|
||||
html = strings.ReplaceAll(html, "\t", "")
|
||||
htmlLines := strings.Split(html, "\n")
|
||||
for _, line := range htmlLines {
|
||||
if strings.Contains(line, "<span class=\"parameter\">") {
|
||||
line = strings.TrimSpace(line)
|
||||
line = strings.ReplaceAll(line, "<span class=\"parameter\">", "")
|
||||
line = strings.ReplaceAll(line, "</span>", "")
|
||||
parameter = line
|
||||
continue
|
||||
}
|
||||
if strings.Contains(line, "<br/>") {
|
||||
comment := strings.TrimSpace(line)
|
||||
comment = strings.ReplaceAll(comment, "<br/>", "")
|
||||
for i := range res.Params {
|
||||
if res.Params[i].Name == parameter {
|
||||
res.Params[i].Comment = comment
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user