hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit c34520895c0bcf96d93caeb125368d250267b5e2
parent 2d498a17ab8f34b2182a029b3f4acc0a865158fa
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue, 20 Apr 2021 14:22:58 -0400

haredoc: visually distinguish undocumented members

Diffstat:
Mbufio/buffered.ha | 2--
Mcmd/haredoc/html.ha | 60+++++++++++++++++++++++++-----------------------------------
2 files changed, 25 insertions(+), 37 deletions(-)

diff --git a/bufio/buffered.ha b/bufio/buffered.ha @@ -4,8 +4,6 @@ use errors; use io; use strings; -// This type is not stable, and is exported for internal use in the standard -// library. export type bufstream = struct { stream: io::stream, source: *io::stream, diff --git a/cmd/haredoc/html.ha b/cmd/haredoc/html.ha @@ -61,41 +61,10 @@ fn emit_html(ctx: *context) (void | error) = { }; fmt::println("<h3>Index</h3>")?; - if (len(decls.types) != 0) { - fmt::println("<h4>Types</h4>")?; - fmt::println("<pre>")?; - for (let i = 0z; i < len(decls.types); i += 1) { - tocentry(decls.types[i])?; - }; - fmt::print("</pre>")?; - }; - - if (len(decls.errors) != 0) { - fmt::println("<h4>Errors</h4>")?; - fmt::println("<pre>")?; - for (let i = 0z; i < len(decls.errors); i += 1) { - tocentry(decls.errors[i])?; - }; - fmt::print("</pre>")?; - }; - - if (len(decls.globals) != 0) { - fmt::println("<h4>Globals</h4>")?; - fmt::print("<pre>")?; - for (let i = 0z; i < len(decls.globals); i += 1) { - tocentry(decls.globals[i])?; - }; - fmt::print("</pre>")?; - }; - - if (len(decls.funcs) != 0) { - fmt::println("<h4>Functions</h4>")?; - fmt::print("<pre>")?; - for (let i = 0z; i < len(decls.funcs); i += 1) { - tocentry(decls.funcs[i])?; - }; - fmt::println("</pre>")?; - }; + tocentries(decls.types, "Types", "types")?; + tocentries(decls.errors, "Errors", "Errors")?; + tocentries(decls.globals, "Globals", "globals")?; + tocentries(decls.funcs, "Functions", "functions")?; if (len(decls.types) != 0) { fmt::println("<h3>Types</h3>")?; @@ -126,6 +95,27 @@ fn emit_html(ctx: *context) (void | error) = { }; }; +fn tocentries(decls: []ast::decl, name: str, lname: str) (void | error) = { + if (len(decls) == 0) { + return; + }; + fmt::printfln("<h4>{}</h4>", name)?; + fmt::println("<pre>")?; + let undoc = false; + for (let i = 0z; i < len(decls); i += 1) { + if (!undoc && decls[i].docs == "") { + fmt::printfln( + "{}<span style='color: #444'>// Undocumented {}:</span>", + if (i == 0) "" else "\n", + lname)?; + undoc = true; + }; + tocentry(decls[i])?; + }; + fmt::print("</pre>")?; + return; +}; + fn tocentry(decl: ast::decl) (void | error) = { fmt::printf("{} ", match (decl.decl) {