diff --git a/class.go b/class.go index d068ab2..d10d09f 100644 --- a/class.go +++ b/class.go @@ -11,7 +11,6 @@ import ( "text/template" "github.com/PuerkitoBio/goquery" - "github.com/davecgh/go-spew/spew" ) //go:embed class.tmpl @@ -385,72 +384,50 @@ func parseMethod(s *goquery.Selection) (Method, error) { return } } else { - 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, "") { - line = strings.TrimSpace(line) - line = strings.ReplaceAll(line, "", "") - line = strings.ReplaceAll(line, "", "") - parameter = line - continue + if s.Is("div.indented") { + if state == 1 { + parameter := "" + html, err := s.Html() + if err != nil { + Error.Printf("Error parsing html: %v", err) + return } - if strings.Contains(line, "
") { - comment := strings.TrimSpace(line) - comment = strings.ReplaceAll(comment, "
", "") - for i := range res.Params { - if res.Params[i].Name == parameter { - res.Params[i].Comment = comment - break + html = strings.ReplaceAll(html, "\t", "") + htmlLines := strings.Split(html, "\n") + for _, line := range htmlLines { + if strings.Contains(line, "") { + line = strings.TrimSpace(line) + line = strings.ReplaceAll(line, "", "") + line = strings.ReplaceAll(line, "", "") + parameter = line + continue + } + if strings.Contains(line, "
") { + comment := strings.TrimSpace(line) + comment = strings.ReplaceAll(comment, "
", "") + for i := range res.Params { + if res.Params[i].Name == parameter { + res.Params[i].Comment = comment + break + } } } } + } else if state == 2 { + text := CleanUp(s.Text()) + if text == "" { + return + } + // TODO: Figure out what to do when a function + if res.Returns[0].Comment != "" { + res.Returns[0].Comment += "\n" + } + res.Returns[0].Comment += text } } } }) - //
- //
- //

- // function unsigned int addCargo(TradingGood - // good, int amount)
- //

- //
- //
- //

- // Adds cargo to the entity. If the amount specified exceeds the maximum capacity of the cargo - // bay, as - // much cargo as still fits in will be added. - //

- //

Parameters

- //
- // good - // TradingGood that is to be added.
- // amount - // The amount of cargo that should be added.
- //
- //

Returns

- //
- //

- // How much was actually added (can be less than amount when cargo bay is full) - //

- //
- //

- //
- //
- - spew.Dump(res) return res, nil }