Skip to content

Commit

Permalink
feat: better api formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Nov 26, 2023
1 parent 3ac3679 commit 231ad79
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions cmd/docs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,33 @@ func main() {

source := ""
if len(symbol.Link) > 0 {
source = fmt.Sprintf("[source](%s)\n", symbol.Link)
source = fmt.Sprintf("[source](%s)", symbol.Link)
}

lines := strings.Split(symbol.Docstring, "\n")

if len(lines) == 0 {
continue
}

first := "```janet\n" + lines[0] + "\n```"

rest := ""
if len(lines) > 1 {
rest = "\n" + strings.Join(lines[1:], "\n")
}

output += fmt.Sprintf(`
#### %s
_%s_
%s
%s%s
%s
---
`, symbol.Name, _type, source, symbol.Docstring)
`, symbol.Name, _type, first, rest, source)
}

fmt.Println(output)
Expand Down

0 comments on commit 231ad79

Please sign in to comment.