]> Creatis software - clitk.git/blob - docWiki.sh
Debug RTStruct conversion with empty struc
[clitk.git] / docWiki.sh
1 #Write all help of syd tools in a file sydTool.md
2 #Execute it in src folder but the tools have to be into ../bin/bin (or change it)
3 #Results are in src folder
4
5 #!/bin/bash
6 set -ev
7 currentFolder=$PWD
8 #Copy all help into a temporary file
9 tempFile=tempDoc.txt
10 cd ./vv_bin/bin
11 clitkTools=`ls clitk*`
12 echo "This page contains additional information on how to use clitk tools:" > $tempFile
13 echo "<<TableOfContents()>>" >> $tempFile
14 echo "" >> $tempFile
15 for tool in $clitkTools
16 do
17   echo "==== " $tool " ====" >> $tempFile
18   $tool -h >> $tempFile
19   echo "" >> $tempFile
20   echo "" >> $tempFile
21   echo "" >> $tempFile
22   echo "" >> $tempFile
23 done
24
25 #Write the .md file
26 docFile="$currentFolder/clitkTool.txt"
27 rm $docFile
28 helpLine=false  #Boolean to know if we are reading the command lines starting with '-h, --help' and finishing with '##' or just the help
29 echoLine=""
30 writeLine=false;
31 while IFS='' read -r line || [[ -n "$line" ]]; do #read all lines
32     copyLine=$line;
33     line=`echo "$line" | sed -e 's/^[ \t]*//'`; # prevent whitespace at the begining of the line
34     if [[ $line == *"-h, --help"* ]]; then
35       helpLine=true;
36     fi
37     if [[ $line == *"===="* ]]; then
38       if $writeLine; then
39         echo "$echoLine||" >> $docFile;
40       fi
41       echoLine="";
42       echo "" >> $docFile;
43       echo "" >> $docFile;
44       echo "" >> $tempFile
45       echo "" >> $tempFile
46       writeLine=false;
47       helpLine=false;
48     fi
49
50     if $helpLine; then
51       if [[ $line == "" ]]; then
52         continue;
53       fi
54       #Create the string according to the different case of ggo
55       #Start with -h
56       #Start with --help
57       #Start with comment
58       #Start with title
59       if [[ $line == "-"[a-zA-Z]* ]]; then
60         if $writeLine; then
61           echoLine="$echoLine||";
62           echo "$echoLine" >> $docFile;
63         fi
64         writeLine=true;
65         echoLine="||";
66         tempString=`echo "$line" | cut -c1-2`; # eg take the -h
67         echoLine="$echoLine$tempString";
68         line=`echo "$line" | cut -d' ' -f2-`; # remove -h, (first word)
69         line=`echo "$line" | sed -e 's/^[ \t]*//'`; # prevent whitespace at the begining of the line
70         echoLine="$echoLine||";
71         tempString=`echo "$line" | cut -f 1 -d " "`; # eg take the --help (first word)
72         echoLine="$echoLine$tempString";
73         line=`echo "$line" | cut -d' ' -f2-`; # remove --help (first word)
74         line=`echo "$line" | sed -e 's/^[ \t]*//'`; # prevent whitespace at the begining of the line
75         echoLine="$echoLine||$line";
76       elif [[ $line == "--"* ]]; then
77         if $writeLine; then
78           echoLine="$echoLine||";
79           echo "$echoLine" >> $docFile;
80         fi
81         writeLine=true;
82         echoLine="|| ||";
83         tempString=`echo "$line" | cut -f 1 -d " "`; # eg take the --help (first word)
84         echoLine="$echoLine$tempString";
85         line=`echo "$line" | cut -d' ' -f2-`; # remove --help (first word)
86         line=`echo "$line" | sed -e 's/^[ \t]*//'`; # prevent whitespace at the begining of the line
87         echoLine="$echoLine||$line";
88       elif [[ $copyLine == " "* ]]; then
89         echoLine="$echoLine$line";
90       else
91         if $writeLine; then
92           echoLine="$echoLine||";
93           echo "$echoLine" >> $docFile;
94         fi
95         echoLine="||||||<style=\"&quot; &amp; quot;text-align:center&amp; quot; &quot;\">$line||";
96         echo "$echoLine" >> $docFile;
97         echoLine="";
98         writeLine=false;
99       fi
100     else
101       if [[ `echo "$line" | cut -c1-1` = "-" ]]; then
102         echo "  " >> $docFile;
103         echo "\\$line" >> $docFile;
104       else
105         echo "$line" >> $docFile;
106       fi
107     fi
108 done < "$tempFile"
109 echo "$echoLine||" >> $docFile
110 rm $tempFile
111 cd $currentFolder