Add types

This commit is contained in:
2024-11-05 23:22:38 +01:00
parent a0fb036da5
commit fd8395fec1
5 changed files with 31 additions and 23 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
main.log main.log
test.html test.html
doc.html

View File

@@ -28,3 +28,7 @@ func FetchFull(url string) (string, error) {
return string(body), nil return string(body), nil
} }
func FetchDocs(url string) (string, error) {
return "", nil
}

View File

@@ -25,25 +25,6 @@ func ParseHTML(html string) ([]string, error) {
return res, nil return res, nil
} }
//doc, err := goquery.NewDocumentFromReader(strings.NewReader(*task.Html)) func ParseDoc(html string) ([]string, error) {
//if err != nil { return nil, nil
// Error.Printf("failed to parse html: %v", err) }
// return
//}
//doc.Find("img").Each(func(i int, s *goquery.Selection) {
// parent := s.Parent()
// if parent.Is("a") {
// href, _ := parent.Attr("href")
// href, ok := fixLink(href)
// if ok {
// hw.output <- &ImageDownloadTask{Url: &href, Topic: task.Topic}
// }
// } else {
// src, _ := s.Attr("src")
// src, ok := fixLink(src)
// if ok {
// hw.output <- &ImageDownloadTask{Url: &src, Topic: task.Topic}
// }
// }
//})

11
main.go
View File

@@ -34,6 +34,9 @@ func init() {
//go:embed test.html //go:embed test.html
var html string var html string
//go:embed doc.html
var doc string
func main() { func main() {
//res, err := FetchFull(url) //res, err := FetchFull(url)
//if err != nil { //if err != nil {
@@ -42,7 +45,13 @@ func main() {
//} //}
//os.WriteFile("test.html", []byte(res), 0644) //os.WriteFile("test.html", []byte(res), 0644)
foo, err := ParseHTML(html) // foo, err := ParseHTML(html)
// if err != nil {
// Error.Printf("Error parsing HTML: %v", err)
// return
// }
// log.Printf("%#v", foo)
foo, err := ParseHTML(doc)
if err != nil { if err != nil {
Error.Printf("Error parsing HTML: %v", err) Error.Printf("Error parsing HTML: %v", err)
return return

13
types.go Normal file
View File

@@ -0,0 +1,13 @@
package main
type (
Function struct {
Arguments []Argument
Returns []Argument
}
Argument struct {
Name string
Type string
Description string
}
)