~mil/f_scripts

ref: 0.3 f_scripts/genscripts/gen_readmedocupdate.sh -rwxr-xr-x 1.4 KiB
f29da769Miles Alan f_audio, f_youtube: Set dac to 100%, fixed muted sound by default 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env osh

indexscripts() {
  PREFIX_FILENAME="$1"
  for FILE in ../scripts/"$PREFIX_FILENAME"*; do
    unset  DEC
    . "$FILE" nonexistentfn 2>/dev/null
    SCRIPTNAME="$(basename "$FILE")"
    
    echo "- [**$SCRIPTNAME**](#strong${SCRIPTNAME}strong): $DEC"
  done
}

documentscripts() {
  PREFIX_FILENAME="$1"
  for FILE in ../scripts/"$PREFIX_FILENAME"*; do
    unset VAR DOC DEP DEC

    . "$FILE" nonexistentfn 2>/dev/null
    SCRIPTNAME="$(basename "$FILE")"
    SCRIPTNAME_UPPER="$(echo "$SCRIPTNAME" | tr '[a-z]' '[A-Z]')"
    DOCUMENTATION="$(echo "$DOC" | sed '/^[[:space:]]*$/d' | awk '{$1=$1};1')"
    
    echo "### **$SCRIPTNAME**"


    echo 
    echo "-  **Description:** $DEC"
    echo "-  **Documentation:** $DOCUMENTATION"
    echo "-  **Dependencies:** $DEP"

    [ -n "$VAR" ] && {
    echo "-  **Default variables:** (override by setting \`$SCRIPTNAME_UPPER=1\`)"
    echo "    - \`\`\`sh"
    echo "$VAR" | sed '/^[[:space:]]*$/d' | awk '{$1=$1};1'
    echo "       \`\`\`"
    }
    echo "-  **Source:** [${SCRIPTNAME}](./scripts/$SCRIPTNAME)"

    echo
    echo
  done
}

gendoc() {
  echo "---"
  echo "## **Documentation for each f_ script**"
  echo "**Index:**"
  indexscripts "f_"
  echo
  documentscripts "f_"
}

main() {
  cd "$(dirname $(realpath $0))"
  sed -i -n '/---/q;p' ../README.md >/dev/null
  gendoc >> ../README.md
  echo "Updated ../README.md ok"
}

if [ -n "$1" ]; then "$@"; else main; fi