hare

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

commit 2c516cd6081c4af634355d08afd4fc53fff6aa38
parent 79d63177d7d0e2c18570eb4468ac23699df8a1c5
Author: Alexey Yerin <yyp@disroot.org>
Date:   Mon, 30 Aug 2021 22:06:24 +0300

cmd/haredoc: show README as a comment in -F{hare,tty}

Signed-off-by: Alexey Yerin <yyp@disroot.org>

Diffstat:
Mcmd/haredoc/hare.ha | 15+++++++++++++++
Mcmd/haredoc/tty.ha | 18++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/cmd/haredoc/hare.ha b/cmd/haredoc/hare.ha @@ -1,3 +1,4 @@ +use bufio; use fmt; use hare::ast; use hare::lex; @@ -10,6 +11,20 @@ use strio; // Formats output as Hare source code (prototypes) fn emit_hare(ctx: *context) (void | error) = { const summary = ctx.summary; + + match (ctx.readme) { + readme: *io::stream => { + for (true) match (bufio::scanline(readme)?) { + b: []u8 => { + fmt::printfln("//{}", strings::fromutf8(b))?; + free(b); + }, + io::EOF => break, + }; + }, + null => void, + }; + // XXX: Should we emit the dependencies, too? for (let i = 0z; i < len(summary.types); i += 1) { details_hare(ctx, summary.types[i])?; diff --git a/cmd/haredoc/tty.ha b/cmd/haredoc/tty.ha @@ -1,3 +1,4 @@ +use bufio; use fmt; use hare::ast; use hare::lex; @@ -10,6 +11,23 @@ use strio; // Formats output as Hare source code (prototypes) with syntax highlighting fn emit_tty(ctx: *context) (void | error) = { const summary = ctx.summary; + + match (ctx.readme) { + readme: *io::stream => { + for (true) match (bufio::scanline(readme)?) { + b: []u8 => { + fmt::printfln( + "\x1b[1m" "// {}" "\x1b[0m", + strings::fromutf8(b))?; + free(b); + }, + io::EOF => break, + }; + fmt::println()?; + }, + null => void, + }; + // XXX: Should we emit the dependencies, too? for (let i = 0z; i < len(summary.types); i += 1) { details_tty(ctx, summary.types[i])?;