From fd8395fec116c0a5ee441f0dfab91f9f25296755 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Tue, 5 Nov 2024 23:22:38 +0100 Subject: [PATCH] Add types --- .gitignore | 1 + html-getter.go | 4 ++++ html-parser.go | 25 +++---------------------- main.go | 11 ++++++++++- types.go | 13 +++++++++++++ 5 files changed, 31 insertions(+), 23 deletions(-) create mode 100644 types.go diff --git a/.gitignore b/.gitignore index 0c6bcc4..2ffe895 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ main.log test.html +doc.html diff --git a/html-getter.go b/html-getter.go index 28a2e36..9e381b8 100644 --- a/html-getter.go +++ b/html-getter.go @@ -28,3 +28,7 @@ func FetchFull(url string) (string, error) { return string(body), nil } + +func FetchDocs(url string) (string, error) { + return "", nil +} \ No newline at end of file diff --git a/html-parser.go b/html-parser.go index f653bcf..195fda0 100644 --- a/html-parser.go +++ b/html-parser.go @@ -25,25 +25,6 @@ func ParseHTML(html string) ([]string, error) { return res, nil } -//doc, err := goquery.NewDocumentFromReader(strings.NewReader(*task.Html)) -//if err != 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} -// } -// } -//}) +func ParseDoc(html string) ([]string, error) { + return nil, nil +} \ No newline at end of file diff --git a/main.go b/main.go index 8a23b43..02d1716 100644 --- a/main.go +++ b/main.go @@ -34,6 +34,9 @@ func init() { //go:embed test.html var html string +//go:embed doc.html +var doc string + func main() { //res, err := FetchFull(url) //if err != nil { @@ -42,7 +45,13 @@ func main() { //} //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 { Error.Printf("Error parsing HTML: %v", err) return diff --git a/types.go b/types.go new file mode 100644 index 0000000..bd87360 --- /dev/null +++ b/types.go @@ -0,0 +1,13 @@ +package main + +type ( + Function struct { + Arguments []Argument + Returns []Argument + } + Argument struct { + Name string + Type string + Description string + } +) \ No newline at end of file