doc/append
This commit is contained in:
parent
1c0a1b5b32
commit
b89db29e79
1 changed files with 13 additions and 9 deletions
|
@ -12,7 +12,7 @@ function alias_eval(alias, name, type) {
|
||||||
print text "; }"
|
print text "; }"
|
||||||
}
|
}
|
||||||
|
|
||||||
function append(string) {
|
function doc_append(string) {
|
||||||
if (doc) {
|
if (doc) {
|
||||||
doc = doc "\n"
|
doc = doc "\n"
|
||||||
}
|
}
|
||||||
|
@ -104,6 +104,7 @@ reset()
|
||||||
|
|
||||||
# parse
|
# parse
|
||||||
function parse(string) {
|
function parse(string) {
|
||||||
|
|
||||||
# module
|
# module
|
||||||
if (match(string, RE_MODULE)) {
|
if (match(string, RE_MODULE)) {
|
||||||
current_match = "module"
|
current_match = "module"
|
||||||
|
@ -112,12 +113,14 @@ function parse(string) {
|
||||||
reset()
|
reset()
|
||||||
module = trim(module)
|
module = trim(module)
|
||||||
shebang = ""
|
shebang = ""
|
||||||
|
|
||||||
# shebang
|
# shebang
|
||||||
} else if (match(string, RE_SHEBANG)) {
|
} else if (match(string, RE_SHEBANG)) {
|
||||||
current_match = "shebang"
|
current_match = "shebang"
|
||||||
shebang = string
|
shebang = string
|
||||||
sub("#!", "", shebang)
|
sub("#!", "", shebang)
|
||||||
shebang = trim(shebang)
|
shebang = trim(shebang)
|
||||||
|
|
||||||
# other
|
# other
|
||||||
} else {
|
} else {
|
||||||
if (module = target) {
|
if (module = target) {
|
||||||
|
@ -126,6 +129,7 @@ function parse(string) {
|
||||||
reset()
|
reset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# → main
|
# → main
|
||||||
|
@ -137,19 +141,19 @@ if (action == "doc") {
|
||||||
# doc
|
# doc
|
||||||
if (match($0, RE_DOC)) {
|
if (match($0, RE_DOC)) {
|
||||||
if (f) {
|
if (f) {
|
||||||
append($0)
|
doc_append($0)
|
||||||
} else {
|
} else {
|
||||||
append(extract($0, "doc"))
|
doc_append(extract($0, "doc"))
|
||||||
}
|
}
|
||||||
} else if (match($0, re["alias"])) {
|
} else if (match($0, re["alias"])) {
|
||||||
matched = extract($0, "alias")
|
matched = extract($0, "alias")
|
||||||
append("= " matched)
|
doc_append("= " matched)
|
||||||
if (matched == target) {
|
if (matched == target) {
|
||||||
match_alias = 1
|
match_alias = 1
|
||||||
}
|
}
|
||||||
} else if (match($0, re["command"])) {
|
} else if (match($0, re["command"])) {
|
||||||
matched = extract($0, "command")
|
matched = extract($0, "command")
|
||||||
append("/ " matched)
|
doc_append("/ " matched)
|
||||||
if (matched == target) {
|
if (matched == target) {
|
||||||
match_command = 1
|
match_command = 1
|
||||||
}
|
}
|
||||||
|
@ -208,9 +212,9 @@ if (action == "doc") {
|
||||||
} else {
|
} else {
|
||||||
match_task = 1
|
match_task = 1
|
||||||
}
|
}
|
||||||
append(line ": " $0)
|
doc_append(line ": " $0)
|
||||||
} else if (match($0, RE_COMMENT)) {
|
} else if (match($0, RE_COMMENT)) {
|
||||||
append(line ": " $0)
|
doc_append(line ": " $0)
|
||||||
} else {
|
} else {
|
||||||
if (match_task) {
|
if (match_task) {
|
||||||
output_tasks = output_tasks "\n" doc
|
output_tasks = output_tasks "\n" doc
|
||||||
|
@ -222,7 +226,7 @@ if (action == "doc") {
|
||||||
# function
|
# function
|
||||||
} else if (action == "function") {
|
} else if (action == "function") {
|
||||||
if (match($0, re["command"])) {
|
if (match($0, re["command"])) {
|
||||||
append(extract($0, "command"))
|
doc_append(extract($0, "command"))
|
||||||
} else if (match($0, re["function"])) {
|
} else if (match($0, re["function"])) {
|
||||||
split(doc, array, "\n")
|
split(doc, array, "\n")
|
||||||
for (item in array) {
|
for (item in array) {
|
||||||
|
@ -239,7 +243,7 @@ if (action == "doc") {
|
||||||
# eval
|
# eval
|
||||||
} else if (action == "eval") {
|
} else if (action == "eval") {
|
||||||
if (match($0, re[target])) {
|
if (match($0, re[target])) {
|
||||||
append(extract($0, target))
|
doc_append(extract($0, target))
|
||||||
} else if (match($0, re["function"])) {
|
} else if (match($0, re["function"])) {
|
||||||
split(doc, array, "\n")
|
split(doc, array, "\n")
|
||||||
for (item in array) {
|
for (item in array) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue