diff --git a/.remarkrc b/.remarkrc index 7f65681..2f490dd 100644 --- a/.remarkrc +++ b/.remarkrc @@ -2,6 +2,7 @@ "plugins": [ "remark-preset-lint-markdown-style-guide", ["remark-lint-list-item-spacing", false], - ["remark-lint-maximum-line-length", false] + ["remark-lint-maximum-line-length", false], + ["remark-lint-no-duplicate-headings", false], ] -} \ No newline at end of file +} diff --git a/bin/generate_readme.sh b/bin/generate_readme.sh index c143e33..5276fd5 100755 --- a/bin/generate_readme.sh +++ b/bin/generate_readme.sh @@ -4,7 +4,7 @@ README="README.md" _setup() { INVALID_CHARS="'[]/?!:\`.,()*\";{}+=<>~$|#@&–—" MINLEVEL=1 - MAXLEVEL=2 + MAXLEVEL=3 SCRIPT_FILE=$(basename $0) SCRIPT_FILENAME="${SCRIPT_FILE%.*}" rm README.md @@ -103,7 +103,7 @@ _insert_toc_to_file() { declare info_toc="" declare end_toc="" - toc_block="$start_toc\n$info_toc\n**Table of Contents**\n\n$toc_text\n$end_toc" + toc_block="$start_toc\n$info_toc\n## Table of Contents\n\n$toc_text\n$end_toc" # temporary replace of '/' (confused with separator of substitutions) and '&' (confused with match regex symbol) to run the special sed command utext_ampersand="id8234923000230gzz" @@ -114,12 +114,14 @@ _insert_toc_to_file() { # search multiline toc block -> https://stackoverflow.com/questions/2686147/how-to-find-patterns-across-multiple-lines-using-grep/2686705 # grep color for debugging -> https://superuser.com/questions/914856/grep-display-all-output-but-highlight-search-matches if grep --color=always -Pzl "(?s)$start_toc.*\n.*$end_toc" $1 &> /dev/null; then - echo -e "\n Updated content of $appname block in $1 succesfully\n" # src https://askubuntu.com/questions/533221/how-do-i-replace-multiple-lines-with-single-word-in-fileinplace-replace sed -i ":a;N;\$!ba;s/$start_toc.*$end_toc/$toc_block/g" $1 + echo -e "\n Updated TOC content in $1 succesfully\n" + else - echo -e "\n Created $appname block in $1 succesfully\n" sed -i 1i"$toc_block" "$1" + echo -e "\n Created TOC in $1 succesfully\n" + fi # undo symbol replacements diff --git a/bin/shdoc.awk b/bin/shdoc.awk index 01bafc9..67fb819 100755 --- a/bin/shdoc.awk +++ b/bin/shdoc.awk @@ -59,7 +59,7 @@ function reset() { /^[[:space:]]*# @file/ { sub(/^[[:space:]]*# @file /, "") - filedoc = render("h1", $0) "\n" + filedoc = render("h2", $0) "\n" } /^[[:space:]]*# @brief/ { @@ -106,7 +106,7 @@ in_example { /^[[:space:]]*# @example/ { in_example = 1 - docblock = docblock "\n" render("h3", "Example") + docblock = docblock "\n" render("h4", "Example") docblock = docblock "\n\n" render("code", "bash") } @@ -114,7 +114,7 @@ in_example { if (!has_args) { has_args = 1 - docblock = docblock "\n" render("h3", "Arguments") "\n\n" + docblock = docblock "\n" render("h4", "Arguments") "\n\n" } sub(/^[[:space:]]*# @arg /, "") @@ -133,7 +133,7 @@ in_example { if (!has_exitcode) { has_exitcode = 1 - docblock = docblock "\n" render("h3", "Exit codes") "\n\n" + docblock = docblock "\n" render("h4", "Exit codes") "\n\n" } sub(/^[[:space:]]*# @exitcode /, "") @@ -157,7 +157,7 @@ in_example { sub(/^[[:space:]]*# @stdout /, "") - docblock = docblock "\n" render("h3", "Output on stdout") + docblock = docblock "\n" render("h4", "Output on stdout") docblock = docblock "\n\n" render("li", $0) "\n" } @@ -171,15 +171,15 @@ in_example { "g" \ ) - doc = doc "\n" render("h2", func_name) "\n" docblock + doc = doc "\n" render("h3", func_name) "\n" docblock - url = func_name - # https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/toc_filter.rb#L44-L45 - url = tolower(url) - gsub(/[^[:alnum:] -]/, "", url) - gsub(/ /, "-", url) + # url = func_name + # # https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/toc_filter.rb#L44-L45 + # url = tolower(url) + # gsub(/[^[:alnum:] -]/, "", url) + # gsub(/ /, "-", url) - toc = toc "\n" "- [" func_name "](#" url ")" + # toc = toc "\n" "- [" func_name "](#" url ")" } docblock = "" @@ -190,7 +190,7 @@ END { if (filedoc != "") { print filedoc } - print toc - print "" + #print toc + # print "" print doc } diff --git a/src/string.sh b/src/string.sh index e244e13..0a62c5c 100644 --- a/src/string.sh +++ b/src/string.sh @@ -101,7 +101,7 @@ string::to_lower() { if [[ ${BASH_VERSINFO:-0} -ge 4 ]]; then printf '%s\n' "${1,,}" else - printf "${@}\n" | tr '[A-Z]' '[a-z]' + printf "%s\n" "${@}" | tr 'A-Z' 'a-z' fi } @@ -123,7 +123,7 @@ string::to_upper() { if [[ ${BASH_VERSINFO:-0} -ge 4 ]]; then printf '%s\n' "${1^^}" else - printf "${@}\n" | tr '[a-z]' '[A-Z]' + printf "%s\n" "${@}" | tr 'a-z' 'A-Z' fi }