From d51d6352526f47734c7bdb7c8050a01ab132e82b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 2 Aug 2025 16:02:56 +0200 Subject: [PATCH] doc/output --- sh/core/code.awk | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/sh/core/code.awk b/sh/core/code.awk index 367440e..5edee5b 100644 --- a/sh/core/code.awk +++ b/sh/core/code.awk @@ -19,6 +19,13 @@ function doc_append(string) { doc = doc string } +function doc_output(name, type) { + print "↙ " type + print name + print doc + exit +} + function doc_reset() { if (f == "") { doc = "" @@ -51,13 +58,6 @@ function extract(string, type) { } } -function output(name, type) { - print "↙ " type - print name - print doc - exit -} - function trim(string) { text = string sub("^[\t ]*", "", text) @@ -125,7 +125,7 @@ function parse(string) { # other } else { if (module = target) { - output(target, "module") + doc_output(target, "module") } else { doc_reset() } @@ -162,14 +162,14 @@ if (action == "doc") { } else if (match($0, re["constant"])) { matched = extract($0, "constant") if (matched == target) { - output(matched, "constant") + doc_output(matched, "constant") } else { doc_reset() } } else if (match($0, re["variable"])) { matched = extract($0, "variable") if (matched == target) { - output(matched, "variable") + doc_output(matched, "variable") } else { doc_reset() } @@ -179,12 +179,12 @@ if (action == "doc") { } else if (match($0, RE_CLOSE)) { if (match_alias) { print "= " target - output(f, "function") + doc_output(f, "function") } else if (match_command) { print "/ " target - output(f, "function") + doc_output(f, "function") } else if (f == target) { - output(f, "function") + doc_output(f, "function") } else { f = "" doc_reset()