doc/output

This commit is contained in:
Marc Beninca 2025-08-02 16:02:56 +02:00
parent 114e514257
commit d51d635252
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -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()