doc/reset
This commit is contained in:
parent
b89db29e79
commit
114e514257
1 changed files with 17 additions and 16 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue