doc/reset

This commit is contained in:
Marc Beninca 2025-08-02 15:59:43 +02:00
parent b89db29e79
commit 114e514257
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -19,6 +19,13 @@ function doc_append(string) {
doc = doc string doc = doc string
} }
function doc_reset() {
if (f == "") {
doc = ""
}
}
# TODO delete when useless
function extract(string, type) { function extract(string, type) {
if (type == "alias") { if (type == "alias") {
split(string, array, "#=") split(string, array, "#=")
@ -51,12 +58,6 @@ function output(name, type) {
exit exit
} }
function reset() {
if (f == "") {
doc = ""
}
}
function trim(string) { function trim(string) {
text = string text = string
sub("^[\t ]*", "", text) sub("^[\t ]*", "", text)
@ -97,7 +98,7 @@ f = ""
match_alias = 0 match_alias = 0
match_command = 0 match_command = 0
match_task = 0 match_task = 0
reset() doc_reset()
# ← begin # ← begin
} }
@ -110,7 +111,7 @@ function parse(string) {
current_match = "module" current_match = "module"
module = string module = string
sub("#\\.", "", module) sub("#\\.", "", module)
reset() doc_reset()
module = trim(module) module = trim(module)
shebang = "" shebang = ""
@ -126,7 +127,7 @@ function parse(string) {
if (module = target) { if (module = target) {
output(target, "module") output(target, "module")
} else { } else {
reset() doc_reset()
} }
} }
@ -163,14 +164,14 @@ if (action == "doc") {
if (matched == target) { if (matched == target) {
output(matched, "constant") output(matched, "constant")
} else { } else {
reset() doc_reset()
} }
} else if (match($0, re["variable"])) { } else if (match($0, re["variable"])) {
matched = extract($0, "variable") matched = extract($0, "variable")
if (matched == target) { if (matched == target) {
output(matched, "variable") output(matched, "variable")
} else { } else {
reset() doc_reset()
} }
# others # others
} else if (match($0, re["function"])) { } else if (match($0, re["function"])) {
@ -186,7 +187,7 @@ if (action == "doc") {
output(f, "function") output(f, "function")
} else { } else {
f = "" f = ""
reset() doc_reset()
} }
} }
@ -235,9 +236,9 @@ if (action == "doc") {
exit exit
} }
} }
reset() doc_reset()
} else { } else {
reset() doc_reset()
} }
# eval # eval
@ -249,9 +250,9 @@ if (action == "doc") {
for (item in array) { for (item in array) {
alias_eval(array[item], extract($0, "function"), "function") alias_eval(array[item], extract($0, "function"), "function")
} }
reset() doc_reset()
} else { } else {
reset() doc_reset()
} }
# filter # filter