test/doc
This commit is contained in:
parent
e157a1ecf7
commit
060a84abda
4 changed files with 51 additions and 44 deletions
20
sh/code.sh
20
sh/code.sh
|
@ -11,10 +11,10 @@ rwx_code() {
|
|||
echo "${_rwx_code}"
|
||||
}
|
||||
|
||||
# show the cached aliases
|
||||
#= rcac
|
||||
rwx_code_aliases_commands() {
|
||||
echo "${_rwx_code_aliases_commands}"
|
||||
# show the cached aliases and functions
|
||||
#= rcaf
|
||||
rwx_code_aliases_functions() {
|
||||
echo "${_rwx_code_aliases_functions}"
|
||||
}
|
||||
|
||||
# show the cached constants
|
||||
|
@ -48,3 +48,15 @@ rwx_code_check() {
|
|||
rwx_log
|
||||
rwx_shellcheck "${RWX_ROOT_SYSTEM}"
|
||||
}
|
||||
|
||||
# fetch matching doc for given name
|
||||
#= rcd
|
||||
rwx_code_doc() {
|
||||
local name="${1}"
|
||||
[ -n "${name}" ] || return
|
||||
printf "%s" "${_rwx_code}" |
|
||||
awk \
|
||||
--assign action="doc" \
|
||||
--assign target="${name}" \
|
||||
--file "${RWX_AWK}"
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ _rwx_code_variables=""
|
|||
rwx_parse_code() {
|
||||
# parse aliases commands
|
||||
local line text
|
||||
_rwx_code_aliases_commands="$(rwx_parse_aliases_commands)"
|
||||
_rwx_code_aliases_functions="$(rwx_parse_aliases_functions)"
|
||||
while IFS= read -r line; do
|
||||
text="$(echo "${line}" | sed "s| |() { |")"
|
||||
text="${text} \"\${@}\"; }"
|
||||
|
@ -221,7 +221,7 @@ EOF
|
|||
# parse variables
|
||||
_rwx_code_variables="$(rwx_parse_variables)"
|
||||
}
|
||||
rwx_parse_aliases_commands() {
|
||||
rwx_parse_aliases_functions() {
|
||||
printf "%s" "${_rwx_code}" |
|
||||
awk \
|
||||
--assign action="alias" \
|
||||
|
|
38
sh/self.sh
38
sh/self.sh
|
@ -1,18 +1,6 @@
|
|||
# self
|
||||
# module
|
||||
|
||||
# meta doc
|
||||
#= rd
|
||||
rwx_doc() {
|
||||
local name="${1}"
|
||||
[ -n "${name}" ] || return
|
||||
printf "%s" "${_rwx_code}" |
|
||||
awk \
|
||||
--assign action="doc" \
|
||||
--assign target="${name}" \
|
||||
--file "${RWX_AWK}"
|
||||
}
|
||||
|
||||
# ╭──────┬──────────╮
|
||||
# │ self │ commands │
|
||||
# ╰──────┴──────────╯
|
||||
|
@ -109,32 +97,6 @@ rwx_self_subset() {
|
|||
done
|
||||
}
|
||||
|
||||
# ╭──────┬──────╮
|
||||
# │ self │ test │
|
||||
# ╰──────┴──────╯
|
||||
|
||||
#= rst
|
||||
rwx_self_test() {
|
||||
local item
|
||||
set \
|
||||
"main" \
|
||||
"alias/git" \
|
||||
\
|
||||
"RWX_MAIN_NAME" \
|
||||
\
|
||||
"_rwx_code" \
|
||||
\
|
||||
"rwx_cache" \
|
||||
\
|
||||
"alias/batcat" \
|
||||
"b" \
|
||||
|
||||
for item in "${@}"; do
|
||||
echo
|
||||
rwx_doc "${item}"
|
||||
done
|
||||
}
|
||||
|
||||
# ╭──────┬───────╮
|
||||
# │ self │ write │
|
||||
# ╰──────┴───────╯
|
||||
|
|
33
sh/test.sh
Normal file
33
sh/test.sh
Normal file
|
@ -0,0 +1,33 @@
|
|||
# test
|
||||
# module
|
||||
# * code
|
||||
# * doc
|
||||
|
||||
# ╭──────┬──────╮
|
||||
# │ test │ code │
|
||||
# ╰──────┴──────╯
|
||||
|
||||
# ╭──────┬─────╮
|
||||
# │ test │ doc │
|
||||
# ╰──────┴─────╯
|
||||
|
||||
rwx_test_doc() {
|
||||
local item
|
||||
set \
|
||||
"main" \
|
||||
"alias/git" \
|
||||
\
|
||||
"RWX_MAIN_NAME" \
|
||||
\
|
||||
"_rwx_code" \
|
||||
\
|
||||
"rwx_cache" \
|
||||
\
|
||||
"alias/batcat" \
|
||||
"b" \
|
||||
|
||||
for item in "${@}"; do
|
||||
echo
|
||||
rwx_code_doc "${item}"
|
||||
done
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue