diff --git a/sh/core/code.awk b/sh/core/code.awk index 3bd8b75..d9829c1 100644 --- a/sh/core/code.awk +++ b/sh/core/code.awk @@ -176,7 +176,7 @@ BEGIN { # │ code │ parse │ # ╰──────┴───────╯ -function parse(string) { +function parse(string, command) { # module if (match(string, RE_MODULE)) { @@ -224,6 +224,9 @@ function parse(string) { current_match = "function" current_function = strip_function(string) ids_put(current_match, current_function) + for (command in commands) { + commands[command] = current_function + } # task } else if (match(string, RE_TASK)) { @@ -348,21 +351,13 @@ if (action == "doc") { # function } else if (action == "function") { - # TODO parse($0) + parse($0) - if (match($0, re["command"])) { - doc_append(extract($0, "command")) - } else if (match($0, re["function"])) { - split(doc, array, "\n") - for (item in array) { - if (array[item] == target) { - print extract($0, "function") - exit - } + if (current_match == "function") { + if (target in commands) { + print commands[target] + exit } - doc_reset() - } else { - doc_reset() } # eval