ids
All checks were successful
/ job (push) Successful in 3m0s

This commit is contained in:
Marc Beninca 2025-08-03 23:07:28 +02:00
parent 094d69ab32
commit 18bc99c7c6
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -66,6 +66,21 @@ function doc_reset() {
}
}
# ╭──────┬───────────┬─────╮
# │ code │ functions │ ids │
# ╰──────┴───────────┴─────╯
function ids_get(type) {
return ids[type]
}
function ids_put(type, name) {
if (ids[type]) {
ids[type] = ids[type] "\n"
}
ids[type] = ids[type] name
}
# ╭──────┬───────────┬───────╮
# │ code │ functions │ strip │
# ╰──────┴───────────┴───────╯
@ -180,16 +195,19 @@ function parse(string) {
} else if (match(string, re["constant"])) {
current_match = "constant"
constant = strip_value(string)
ids_put(current_match, constant)
# variable
} else if (match(string, re["variable"])) {
current_match = "variable"
variable = strip_value(string)
ids_put(current_match, variable)
# alias
} else if (match(string, re["alias"])) {
current_match = "alias"
alias = strip_first(string, "#=")
ids_put(current_match, alias)
aliases[alias] = ""
doc_append("= " alias)
@ -197,6 +215,7 @@ function parse(string) {
} else if (match(string, re["command"])) {
current_match = "command"
command = strip_first(string, "#/")
ids_put(current_match, command)
commands[command] = ""
doc_append("/ " command)
@ -204,6 +223,7 @@ function parse(string) {
} else if (match(string, re["function"])) {
current_match = "function"
current_function = strip_function(string)
ids_put(current_match, current_function)
# task
} else if (match(string, RE_TASK)) {
@ -357,12 +377,6 @@ if (action == "doc") {
doc_reset()
}
# filter
} else if (action == "filter") {
if (match($0, re[target])) {
unique[extract($0, target)] = ""
}
# lint
} else if (action == "lint") {
parse($0)
@ -380,6 +394,10 @@ if (action == "doc") {
# TODO unique command
# TODO unique function
# filter
} else if (action == "filter") {
parse($0)
# unknown
} else {
print "unknown action: " action
@ -436,9 +454,7 @@ END {
# filter
if (action == "filter") {
for (item in unique) {
print item
}
print ids_get(target)
# lint
} else if (action == "lint") {