Implement parameter comment parsing

This commit is contained in:
2024-09-15 14:24:20 +02:00
parent e556e9d23f
commit 2f886a474d

View File

@@ -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
}
}
}
}
}
}
})