diff --git a/sh/core/code.awk b/sh/core/code.awk index 0e88734..4977eb0 100644 --- a/sh/core/code.awk +++ b/sh/core/code.awk @@ -12,7 +12,7 @@ function alias_eval(alias, name, type) { print text "; }" } -function append(string) { +function doc_append(string) { if (doc) { doc = doc "\n" } @@ -104,6 +104,7 @@ reset() # parse function parse(string) { + # module if (match(string, RE_MODULE)) { current_match = "module" @@ -112,12 +113,14 @@ function parse(string) { reset() module = trim(module) shebang = "" + # shebang } else if (match(string, RE_SHEBANG)) { current_match = "shebang" shebang = string sub("#!", "", shebang) shebang = trim(shebang) + # other } else { if (module = target) { @@ -126,6 +129,7 @@ function parse(string) { reset() } } + } # → main @@ -137,19 +141,19 @@ if (action == "doc") { # doc if (match($0, RE_DOC)) { if (f) { - append($0) + doc_append($0) } else { - append(extract($0, "doc")) + doc_append(extract($0, "doc")) } } else if (match($0, re["alias"])) { matched = extract($0, "alias") - append("= " matched) + doc_append("= " matched) if (matched == target) { match_alias = 1 } } else if (match($0, re["command"])) { matched = extract($0, "command") - append("/ " matched) + doc_append("/ " matched) if (matched == target) { match_command = 1 } @@ -208,9 +212,9 @@ if (action == "doc") { } else { match_task = 1 } - append(line ": " $0) + doc_append(line ": " $0) } else if (match($0, RE_COMMENT)) { - append(line ": " $0) + doc_append(line ": " $0) } else { if (match_task) { output_tasks = output_tasks "\n" doc @@ -222,7 +226,7 @@ if (action == "doc") { # function } else if (action == "function") { if (match($0, re["command"])) { - append(extract($0, "command")) + doc_append(extract($0, "command")) } else if (match($0, re["function"])) { split(doc, array, "\n") for (item in array) { @@ -239,7 +243,7 @@ if (action == "doc") { # eval } else if (action == "eval") { if (match($0, re[target])) { - append(extract($0, target)) + doc_append(extract($0, target)) } else if (match($0, re["function"])) { split(doc, array, "\n") for (item in array) {