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