From 114e51425755b759142f51014c51d335864b5c2a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 2 Aug 2025 15:59:43 +0200 Subject: [PATCH] doc/reset --- sh/core/code.awk | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/sh/core/code.awk b/sh/core/code.awk index 4977eb0..367440e 100644 --- a/sh/core/code.awk +++ b/sh/core/code.awk @@ -19,6 +19,13 @@ function doc_append(string) { doc = doc string } +function doc_reset() { + if (f == "") { + doc = "" + } +} + +# TODO delete when useless function extract(string, type) { if (type == "alias") { split(string, array, "#=") @@ -51,12 +58,6 @@ function output(name, type) { exit } -function reset() { - if (f == "") { - doc = "" - } -} - function trim(string) { text = string sub("^[\t ]*", "", text) @@ -97,7 +98,7 @@ f = "" match_alias = 0 match_command = 0 match_task = 0 -reset() +doc_reset() # ← begin } @@ -110,7 +111,7 @@ function parse(string) { current_match = "module" module = string sub("#\\.", "", module) - reset() + doc_reset() module = trim(module) shebang = "" @@ -126,7 +127,7 @@ function parse(string) { if (module = target) { output(target, "module") } else { - reset() + doc_reset() } } @@ -163,14 +164,14 @@ if (action == "doc") { if (matched == target) { output(matched, "constant") } else { - reset() + doc_reset() } } else if (match($0, re["variable"])) { matched = extract($0, "variable") if (matched == target) { output(matched, "variable") } else { - reset() + doc_reset() } # others } else if (match($0, re["function"])) { @@ -186,7 +187,7 @@ if (action == "doc") { output(f, "function") } else { f = "" - reset() + doc_reset() } } @@ -235,9 +236,9 @@ if (action == "doc") { exit } } - reset() + doc_reset() } else { - reset() + doc_reset() } # eval @@ -249,9 +250,9 @@ if (action == "doc") { for (item in array) { alias_eval(array[item], extract($0, "function"), "function") } - reset() + doc_reset() } else { - reset() + doc_reset() } # filter