github.com/nguyentm83/docker@v1.5.0/docs/build.sh (about) 1 #!/usr/bin/env bash 2 set -e 3 4 set -o pipefail 5 6 usage() { 7 exit 1 8 } 9 10 11 extrafiles=($(find . -name "mkdocs-*.yml")) 12 extralines=() 13 14 for file in "${extrafiles[@]}" 15 do 16 #echo "LOADING $file" 17 while read line 18 do 19 if [[ "$line" != "" ]] 20 then 21 extralines+=("$line") 22 23 #echo "LINE (${#extralines[@]}): $line" 24 fi 25 done < <(cat "$file") 26 done 27 28 #echo "extra count (${#extralines[@]})" 29 mv mkdocs.yml mkdocs.yml.bak 30 echo "# Generated mkdocs.yml from ${extrafiles[@]}" 31 echo "# Generated mkdocs.yml from ${extrafiles[@]}" > mkdocs.yml 32 33 while read line 34 do 35 menu=$(echo $line | sed "s/^- \['\([^']*\)', '\([^']*\)'.*/\2/") 36 if [[ "$menu" != "**HIDDEN**" ]] 37 # or starts with a '#'? 38 then 39 if [[ "$lastmenu" != "" && "$lastmenu" != "$menu" ]] 40 then 41 # insert extra elements here 42 for extra in "${extralines[@]}" 43 do 44 #echo "EXTRA $extra" 45 extramenu=$(echo $extra | sed "s/^- \['\([^']*\)', '\([^']*\)'.*/\2/") 46 if [[ "$extramenu" == "$lastmenu" ]] 47 then 48 echo "$extra" >> mkdocs.yml 49 fi 50 done 51 #echo "# JUST FINISHED $lastmenu" 52 fi 53 lastmenu="$menu" 54 fi 55 echo "$line" >> mkdocs.yml 56 57 done < <(cat "mkdocs.yml.bak")