Add function description parsing
This commit is contained in:
@@ -30,6 +30,7 @@ func init() {
|
||||
type (
|
||||
Function struct {
|
||||
Name string
|
||||
Description string
|
||||
Arguments []Parameter
|
||||
Returns []Parameter
|
||||
}
|
||||
|
@@ -1,8 +1,10 @@
|
||||
---@diagnostic disable: missing-return, lowercase-global
|
||||
|
||||
{{range .Arguments -}}
|
||||
---@param {{.Name}} {{.Type}} {{.Description}}
|
||||
{{end -}}
|
||||
{{range .Returns -}}
|
||||
---@return {{.Type}} {{.Name}} {{if .Description}}#{{.Description}}{{end}}
|
||||
{{end -}}
|
||||
{{if .Description}}---{{.Description}}{{end}}
|
||||
function {{.Name}}({{range $index, $param := .Arguments}}{{if $index}}, {{end}}{{$param.Name}}{{end}}) end
|
@@ -38,6 +38,16 @@ func ParseDoc(html string) (Function, error) {
|
||||
return res, fmt.Errorf("failed parsing html: %v", err)
|
||||
}
|
||||
|
||||
doc.Find("div.api-desc").Each(func(i int, s *goquery.Selection) {
|
||||
log.Printf("Parsing description %s", s.Text())
|
||||
desc := s.Text()
|
||||
desc = strings.ReplaceAll(desc, "\n", " ")
|
||||
desc = strings.ReplaceAll(desc, "\t", " ")
|
||||
desc = strings.ReplaceAll(desc, " ", " ")
|
||||
desc = strings.TrimSpace(desc)
|
||||
res.Description = desc
|
||||
})
|
||||
|
||||
isArgs := false
|
||||
isReturn := false
|
||||
doc.Find("div.api-listing > p, div.api-listing > ul").Each(func(i int, s *goquery.Selection) {
|
||||
|
Reference in New Issue
Block a user