hare

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

commit 28a6302007dddb1a92c279dbb5bf6e6b20635a00
parent eabd5cd08462c5731fa5156d8e58c664ff671df2
Author: Alexey Yerin <yyp@disroot.org>
Date:   Fri, 12 Apr 2024 22:32:23 +0300

cmd/haredoc: Correctly display HTML module references

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

Diffstat:
Mcmd/haredoc/doc/html.ha | 16+++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/cmd/haredoc/doc/html.ha b/cmd/haredoc/doc/html.ha @@ -235,7 +235,7 @@ fn details(ctx: *context, decl: *ast::decl) (void | error) = { return; }; -fn htmlref(ctx: *context, ref: ast::ident) (void | error) = { +fn html_decl_ref(ctx: *context, ref: ast::ident) (void | error) = { const ik = match (resolve(ctx, ref)?) { case let ik: (ast::ident, symkind) => @@ -279,6 +279,16 @@ fn htmlref(ctx: *context, ref: ast::ident) (void | error) = { free(ident); }; +fn html_mod_ref(ctx: *context, ref: ast::ident) (void | error) = { + const ident = unparse::identstr(ref); + defer free(ident); + let ipath = strings::join("/", ref...); + defer free(ipath); + fmt::fprintf(ctx.out, "<a href='/{}' class='ref'>{}::</a>", + ipath, ident)?; +}; + + fn html_paragraph(ctx: *context, p: doc::paragraph) (void | error) = { for (let elem .. p) { match (elem) { @@ -299,9 +309,9 @@ fn html_paragraph(ctx: *context, p: doc::paragraph) (void | error) = { html_escape(ctx.out, s)?; }; case let d: doc::decl_ref => - htmlref(ctx, d)?; + html_decl_ref(ctx, d)?; case let m: doc::mod_ref => - htmlref(ctx, m)?; + html_mod_ref(ctx, m)?; }; }; };