From 02861830562fda1ed12e4cd528602bd18cd4fb14 Mon Sep 17 00:00:00 2001 From: tbaudier Date: Mon, 25 Sep 2017 17:15:03 +0200 Subject: [PATCH] Add doc tool for th wiki --- docWiki.sh | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100755 docWiki.sh diff --git a/docWiki.sh b/docWiki.sh new file mode 100755 index 0000000..4017f7c --- /dev/null +++ b/docWiki.sh @@ -0,0 +1,110 @@ +#Write all help of syd tools in a file sydTool.md +#Execute it in src folder but the tools have to be into ../bin/bin (or change it) +#Results are in src folder + +#!/bin/bash +set -ev +currentFolder=$PWD +#Copy all help into a temporary file +tempFile=tempDoc.txt +cd ./vv_bin/bin +clitkTools=`ls clitk*` +echo "This page contains additional information on how to use clitk tools:" > $tempFile +echo "" >> $tempFile +for tool in $clitkTools +do + echo "==== " $tool " ====" >> $tempFile + $tool -h >> $tempFile + echo "" >> $tempFile + echo "" >> $tempFile + echo "" >> $tempFile + echo "" >> $tempFile +done + +#Write the .md file +docFile="$currentFolder/clitkTool.txt" +rm $docFile +helpLine=false #Boolean to know if we are reading the command lines starting with '-h, --help' and finishing with '##' or just the help +echoLine="" +writeLine=false; +while IFS='' read -r line || [[ -n "$line" ]]; do #read all lines + copyLine=$line; + line=`echo "$line" | sed -e 's/^[ \t]*//'`; # prevent whitespace at the begining of the line + if [[ $line == *"-h, --help"* ]]; then + helpLine=true; + fi + if [[ $line == *"===="* ]]; then + if $writeLine; then + echo "$echoLine||" >> $docFile; + fi + echoLine=""; + echo "" >> $docFile; + echo "" >> $docFile; + echo "" >> $tempFile + echo "" >> $tempFile + writeLine=false; + helpLine=false; + fi + + if $helpLine; then + if [[ $line == "" ]]; then + continue; + fi + #Create the string according to the different case of ggo + #Start with -h + #Start with --help + #Start with comment + #Start with title + if [[ $line == "-"[a-zA-Z]* ]]; then + if $writeLine; then + echoLine="$echoLine||"; + echo "$echoLine" >> $docFile; + fi + writeLine=true; + echoLine="||"; + tempString=`echo "$line" | cut -c1-2`; # eg take the -h + echoLine="$echoLine$tempString"; + line=`echo "$line" | cut -d' ' -f2-`; # remove -h, (first word) + line=`echo "$line" | sed -e 's/^[ \t]*//'`; # prevent whitespace at the begining of the line + echoLine="$echoLine||"; + tempString=`echo "$line" | cut -f 1 -d " "`; # eg take the --help (first word) + echoLine="$echoLine$tempString"; + line=`echo "$line" | cut -d' ' -f2-`; # remove --help (first word) + line=`echo "$line" | sed -e 's/^[ \t]*//'`; # prevent whitespace at the begining of the line + echoLine="$echoLine||$line"; + elif [[ $line == "--"* ]]; then + if $writeLine; then + echoLine="$echoLine||"; + echo "$echoLine" >> $docFile; + fi + writeLine=true; + echoLine="|| ||"; + tempString=`echo "$line" | cut -f 1 -d " "`; # eg take the --help (first word) + echoLine="$echoLine$tempString"; + line=`echo "$line" | cut -d' ' -f2-`; # remove --help (first word) + line=`echo "$line" | sed -e 's/^[ \t]*//'`; # prevent whitespace at the begining of the line + echoLine="$echoLine||$line"; + elif [[ $copyLine == " "* ]]; then + echoLine="$echoLine$line"; + else + if $writeLine; then + echoLine="$echoLine||"; + echo "$echoLine" >> $docFile; + fi + echoLine="||||||$line||"; + echo "$echoLine" >> $docFile; + echoLine=""; + writeLine=false; + fi + else + if [[ `echo "$line" | cut -c1-1` = "-" ]]; then + echo " " >> $docFile; + echo "\\$line" >> $docFile; + else + echo "$line" >> $docFile; + fi + fi +done < "$tempFile" +echo "$echoLine||" >> $docFile +rm $tempFile +cd $currentFolder -- 2.47.1