diff --git a/sh/doc.awk b/sh/doc.awk deleted file mode 100644 index f36b7b6..0000000 --- a/sh/doc.awk +++ /dev/null @@ -1,83 +0,0 @@ -function append(line) { - if (doc) { - doc = doc "\n" - } - doc = doc line -} - -function output(name) { - print name - print doc - exit -} - -function reset() { - doc = "" -} - -BEGIN { - RE_ANY = "(.*)" - RE_NAME = "([_A-Za-z][_0-9A-Za-z]*)" - RE_SPACE = "[[:space:]]" - RE_SPACES = RE_SPACE "*" - - RE_BEGIN = "^" - RE_END = RE_SPACES "$" - RE_FUNC = RE_SPACES "\\(" RE_SPACES "\\)" RE_SPACES "{" - - RE_ALIAS = RE_BEGIN "#\\(" RE_SPACES RE_NAME RE_END - RE_DOC = RE_BEGIN "#" RE_SPACE RE_ANY RE_END - RE_FUNCTION = RE_BEGIN RE_NAME RE_FUNC RE_END - RE_MODULE = RE_BEGIN "#." RE_SPACES RE_NAME RE_END - RE_SET = RE_BEGIN RE_NAME "=.*" RE_END - RE_SHEBANG = RE_BEGIN "#!" RE_SPACES RE_ANY RE_END - - alias = 0 - reset() - module = 0 -} - -{ - # doc - if (match($0, RE_SHEBANG, m)) { - append("shebang: " m[1]) - } else if (match($0, RE_DOC, m)) { - append(m[1]) - } else if (match($0, RE_ALIAS, m)) { - append("alias: " m[1]) - if (m[1] == target) { - alias = 1 - } - # not doc - } else if (match($0, RE_MODULE, m)) { - reset() - if (m[1] == target) { - module = 1 - } - } else if (match($0, RE_SET, m)) { - if (m[1] == target) { - printf "set: " - output(m[1]) - } else { - reset() - } - } else if (match($0, RE_FUNCTION, m)) { - if (alias) { - print "alias: " target - printf "function: " - output(m[1]) - } else if (m[1] == target) { - printf "function: " - output(target) - } else { - reset() - } - } else { - if (module) { - printf "module: " - output(target) - } else { - reset() - } - } -} diff --git a/sh/main.sh b/sh/main.sh index fb323d8..343cbe3 100755 --- a/sh/main.sh +++ b/sh/main.sh @@ -1,8 +1,9 @@ #! /usr/bin/env sh +# main module + # ╭──────╮ # │ main │ # ╰──────╯ -# main module # ╭──────┬───────────╮ # │ main │ constants │ @@ -10,10 +11,8 @@ # name of the entrypoint file RWX_MAIN_NAME="main.sh" -# name of the project itself RWX_SELF_NAME="rwx" -# prefix for command functions RWX_SELF_COMMAND="_${RWX_SELF_NAME}_cmd_" # ╭──────┬───────────╮ @@ -65,7 +64,6 @@ rwx_main() { # ╰──────┴───────╯ # cache source code of a module -# inside a global code variable rwx_cache() { local root="${1}" local module="${2}" @@ -195,31 +193,6 @@ rwx_parse_functions() { sed --silent "s|${RWX_REGEX_TARGET_FUNCTION}|\\1|p" } -# ╭──────┬──────╮ -# │ main │ test │ -# ╰──────┴──────╯ - -rwx_test() { - local item - # TODO CODE - # TODO CONSTANTS - # TODO functions - # TODO variables - set \ - "main" \ - "self" \ - \ - "RWX_MAIN_NAME" \ - \ - "rwx_cache" \ - \ - "gsc" - for item in "${@}"; do - echo - rwx_doc "${item}" - done -} - # ╭──────┬─────╮ # │ main │ run │ # ╰──────┴─────╯ diff --git a/sh/self.sh b/sh/self.sh index 169921a..c181112 100644 --- a/sh/self.sh +++ b/sh/self.sh @@ -1,17 +1,7 @@ -# self -# module +# self module # meta doc rwx_doc() { - local name="${1}" - [ -n "${name}" ] || return - printf "%s" "${RWX_CODE}" | - awk \ - -f "${RWX_ROOT_SYSTEM}/doc.awk" \ - -v target="${name}" -} - -rwx_doc_old() { local name="${1}" [ -n "${name}" ] || return local constant doc func line module