From 231ad793ca218a9b29553c4aca3aa1f891104c05 Mon Sep 17 00:00:00 2001 From: Caleb Foust Date: Sun, 26 Nov 2023 12:18:53 -0500 Subject: [PATCH] feat: better api formatting --- cmd/docs/main.go | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/cmd/docs/main.go b/cmd/docs/main.go index 7e46592a..004119cf 100644 --- a/cmd/docs/main.go +++ b/cmd/docs/main.go @@ -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)