diff --git a/sh/code.awk b/sh/code.awk index 0d23127..053f1be 100644 --- a/sh/code.awk +++ b/sh/code.awk @@ -50,18 +50,6 @@ BEGIN { if (match($0, RE_ALIAS, m)) { print m[1] } - } else if (action == "constants") { - if (match($0, RE_CONSTANT, m)) { - print m[1] - } - } else if (action == "functions") { - if (match($0, RE_FUNCTION, m)) { - print m[1] - } - } else if (action == "variables") { - if (match($0, RE_VARIABLE, m)) { - print m[1] - } } else if (action == "aliases functions") { if (match($0, RE_ALIAS, m)) { append(m[1]) diff --git a/sh/code.sh b/sh/code.sh index e5a898b..8838276 100644 --- a/sh/code.sh +++ b/sh/code.sh @@ -6,18 +6,8 @@ # │ code │ variables │ # ╰──────┴───────────╯ -# cache for the parsing awk script +# path to the required parsing awk script _rwx_code_awk="$(cat "${RWX_ROOT_SYSTEM}/code.awk")" -# cache for code aliases -_rwx_code_aliases="" -# cache for code aliases functions -_rwx_code_aliases_functions="" -# cache for code constants -_rwx_code_constants="" -# cache for code functions -_rwx_code_functions="" -# cache for code variables -_rwx_code_variables="" # ╭──────┬───────╮ # │ code │ parts │ @@ -29,11 +19,6 @@ rwx_code() { echo "${_rwx_code}" } -# show the cached awk script -rwx_code_awk() { - echo "${_rwx_code_awk}" -} - # show the cached aliases #= rca rwx_code_aliases() { @@ -46,6 +31,11 @@ rwx_code_aliases_functions() { echo "${_rwx_code_aliases_functions}" } +# show the cached awk script +rwx_code_awk() { + echo "${_rwx_code_awk}" +} + # show the cached constants #= rcc rwx_code_constants() { @@ -83,38 +73,9 @@ rwx_code_check() { rwx_code_doc() { local name="${1}" [ -n "${name}" ] || return - rwx_code | + printf "%s" "${_rwx_code}" | awk \ --assign action="doc" \ --assign target="${name}" \ - "${_rwx_code_awk}" -} - -rwx_code_load() { - # parse aliases - _rwx_code_aliases="$(rwx_code_parse "aliases")" - # parse aliases functions - local line text - _rwx_code_aliases_functions="$(rwx_code_parse "aliases functions")" - while IFS= read -r line; do - text="$(echo "${line}" | sed "s| |() { |")" - text="${text} \"\${@}\"; }" - eval "${text}" - done <