-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.sh
executable file
·320 lines (291 loc) · 9.32 KB
/
README.sh
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#!/bin/bash
#TMPDIR=""
#function finish {
# /bin/rm -rf $TMPDIR
#}
#TMPDIR=$( mktemp -d --suffix=".$( whoami ).mpitest" )
#
#trap finish EXIT
APPNAME=$(basename $0)
APPDIR=$(cd $(dirname $0) ; pwd)
MANHOME=/c/git/man_ompi
BUILDDIR=./_build/
BUILDMAN=./_build/man/
# Note: could use mktemp but for easier to debug if known name
TMPDIR=/tmp/ompiman
mkdir -p $TMPDIR
TMPRST=$TMPDIR/tmprst/
mkdir -p $TMPRST
MDTMPRST=$TMPDIR/tmpmdrst/
mkdir -p $MDTMPRST
MDTMPRST=$( cd $MDTMPRST; pwd -P )
BUILDRST=./rst/
mkdir -p $BUILDDIR
mkdir -p $BUILDRST
[[ -d ../rst ]] || mkdir -p ../rst
[[ -L $BUILDDIR/rst ]] || [[ -f $BUILDDIR/rst ]] || ln -sf ../rst $BUILDDIR/
BUILDHTML=./_build/html/
MANDIRS="ompi/mpi/man ompi/mpiext ompi/tools oshmem/shmem/man opal/tools/wrappers oshmem/tools/oshmem_info "
TSTMAN_ORIG=$TMPDIR/tmpman_orig/
TSTMAN_NEW=$TMPDIR/tmpman_new/
TSTMAN_DIFF=$TMPDIR/tmpman_diff/
TSTMAN_TEXT_DIFF=$TMPDIR/tmpman_text_diff/
mkdir -p $BUILDMAN
BUILDRST=$(cd $BUILDRST ; pwd -P )
[[ -f $BUILDRST/conf.py ]] || cp $APPDIR/conf.py $BUILDRST/
[[ -f $BUILDRST/index.rst ]] || cp $APPDIR/index.rst $BUILDRST/
# For each man page, if the man page includes another,
# convert nroff ".so" command to rst ".. include::"
# else use pandoc to convert the man page to rst.
if [[ 1 -eq 1 ]] ; then
echo "About to convert man to rst"
SAVEME=$( pwd )
ERRORFILE=pandoc_man2rst.output
cat /dev/null > $ERRORFILE
for d in $MANDIRS ; do
for f in $( find $d -name \*.\*in ) ; do
f2=$( echo $f | sed -e "s/\.\([0-9]*\)in/.\1/" )
out=$TMPRST/${f2}.rst
# add labels for files that originally included this file
if [[ $( grep -w '^\.so' $f | wc -l ) -eq 1 ]] ; then
out=$BUILDRST/${f2}.rst
echo "converting $f to $out" >> $ERRORFILE
mkdir -p $( dirname $out )
fname=$( grep -w '^\.so' $f | awk '{printf"%s.rst",$2}' )
[[ -z "${fname}" ]] && echo "WARNING: ERROR: See $fname"
pname=$( basename $out | awk -F\. '{print $1}' )
pnamelower=$( echo $pname | tr 'A-Z' 'a-z')
delim=$( echo $pname | sed -e "s/[a-z,A-Z,0-9,_,\-]/=/g" )
echo ".. _${pnamelower}:" > $out
echo " " >> $out
echo $pname >> $out
echo $delim >> $out
echo " .. include_body" >> $out
echo "" >> $out
echo ".. include:: ../${fname}" >> $out
echo " :start-after: .. include_body" >> $out
echo "" >> $out
else
mkdir -p $( dirname $out )
echo "converting $f to $out" >> $ERRORFILE
cd $( dirname $f )
f2=$( basename $f)
pandoc -f man -t rst $f2 1> $out 2>> $ERRORFILE
cd $SAVEME
fi
done
done
# Check for warning messages
echo "WARNING messages from $ERRORFILE:" $( grep WARNING $ERRORFILE | wc -l )
fi
# For each man md page
# use pandoc to convert the man page to rst.
if [[ 1 -eq 1 ]] ; then
echo "About to convert md to rst"
SAVEME=$( pwd )
ERRORFILE=pandoc_md2rst.output
cat /dev/null > $ERRORFILE
for d in $MANDIRS ; do
for f in $( find $d -name \*.md ) ; do
f2=$( echo $f | sed -e "s/\.\([0-9]*\).md/.\1/" )
out=$MDTMPRST/${f2}.rst
mkdir -p $( dirname $out )
echo "converting $f to $out"
echo "converting $f to $out" >> $ERRORFILE
cd $( dirname $f )
f2=$( basename $f)
pandoc -f gfm -t rst $f2 1> $out 2>> $ERRORFILE
cd $SAVEME
done
done
# Check for warning messages
echo "WARNING messages from $ERRORFILE:" $( grep WARNING $ERRORFILE | wc -l )
fi
# fix up rst files
SAVEME=$( pwd )
if [[ 1 -eq 1 ]] ; then
echo "About to fix up rst"
date
for d in $MANDIRS ; do
for f in $( cd $TMPRST/$d; find . -name \*.rst ) ; do
infile="$TMPRST/$d/$f"
out="$BUILDRST/$d/$f"
mkdir -p $( dirname $out )
echo "Fixing $infile as $out"
python3 $APPDIR/fixup_rst.py $infile $out
done
done
date
fi
# fix up rst files generated from md
SAVEME=$( pwd )
if [[ 1 -eq 1 ]] ; then
echo "About to fix up rst generated from md files"
date
for d in $MANDIRS ; do
if [[ -d $MDTMPRST/$d ]]; then
for f in $( cd $MDTMPRST/$d; find . -name \*.rst ) ; do
infile="$MDTMPRST/$d/$f"
out="$BUILDRST/$d/$f"
mkdir -p $( dirname $out )
echo "MD: Fixing $infile as $out"
python3 $APPDIR/fix_md_rst.py $infile $out
done
fi
done
date
fi
# ARGH. Tables are hard.
if [[ 1 -eq 1 ]] ; then
cp $APPDIR/Open-MPI.5.rst $BUILDRST/ompi/mpi/man/man5/Open-MPI.5.rst
fi
# use sphinx-build to create html files
if [[ 0 -eq 1 ]] ; then
echo "About to create html files"
date
SAVEME=$( pwd )
cd $BUILDDIR
ERRORFILE=sphinx-build_rst2html.output
cat /dev/null > $ERRORFILE
sphinx-build -b html -c rst rst/ html/ >& $ERRORFILE
cd $SAVEME
date
fi
# use sphinx-build to create man files
if [[ 0 -eq 1 ]] ; then
echo "About to create man files"
date
ERRORFILE=sphinx-build_rst2man.output
SAVEME=$( pwd )
cd $BUILDDIR/
sphinx-build -vvv -b man -c rst rst/ man/ >& $ERRORFILE
cd $SAVEME
date
fi
# check the man pages by comparing against original man pages
j=0
if [[ 0 -eq 1 ]] ; then
SAVEME=$( pwd -P )
mkdir -p $TSTMAN_NEW
TSTMAN_NEW=$( cd $TSTMAN_NEW; pwd -P )
echo "TSTMAN_NEW is $TSTMAN_NEW"
echo "TSTMAN_NEW is $TSTMAN_NEW"
cd $BUILDMAN
for i in $( /bin/ls ) ; do
if [[ ! -d $i ]] ; then
out=${TSTMAN_NEW}/${i}
( man ./${i} >& $out ) &
j=$(( j + 1 ))
[[ $(( $j%5 )) -eq 0 ]] && wait
fi
done
echo "new man page output in $TSTMAN_NEW"
cd $SAVEME
fi
wait
if [[ 0 -eq 1 ]] ; then
mkdir -p $TSTMAN_ORIG
TSTMAN_ORIG=$( cd $TSTMAN_ORIG; pwd -P )
SAVEME=$( pwd -P )
cd $MANHOME
i=0
for d in $MANDIRS ; do
for f in $( find $d -name \*.\*in -type f ) ; do
if [[ ! -d $TSTMAN_NEW/$i ]] ; then
sbname=$( basename $f | sed -e "s/in$//" )
out=$TSTMAN_ORIG/$sbname
(man ${f} >& $out) &
i=$(( i + 1 ))
[[ $(( $i%5 )) -eq 0 ]] && wait
fi
done
done
cd $SAVEME
echo "original man page output in $TSTMAN_ORIG"
fi
wait
if [[ 0 -eq 1 ]] ; then
SAVEME=$( pwd -P )
TSTMAN_ORIG=$( cd $TSTMAN_ORIG; pwd -P )
TSTMAN_NEW=$( cd $TSTMAN_NEW; pwd -P )
outdir_orig="${TSTMAN_ORIG}.seealso"
mkdir -p $outdir_orig
outdir_new="${TSTMAN_NEW}.seealso"
mkdir -p $outdir_new
echo "Output dirs: $outdir_orig, $outdir_new"
j=0
for i in $( /bin/ls $TSTMAN_NEW ) ; do
if [[ ! -d $TSTMAN_NEW/$i ]] ; then
f1=${TSTMAN_NEW}/${i}
f1out=$outdir_new/$i
( python3 $APPDIR/extract_seealso.py $f1 >& $f1out )&
f2=${TSTMAN_ORIG}/${i}
f2out=$outdir_orig/$i
[[ -f $f2 ]] && (python3 $APPDIR/extract_seealso.py $f2 >& $f2out ) &
fi
done
cd "$TSTMAN_NEW.seealso"
/bin/rm *.diff
for f in $( ls -l | grep -vw "0 May" | grep -vw total | awk '{print $NF}' ) ; do
orig="${TSTMAN_ORIG}.seealso"/$f
if [[ -f $orig ]] ; then
( diff $f $orig >& "$f.diff" )&
j=$(( j + 1 ))
else
cp $f $f.diff
fi
[[ $(( $j%2 )) -eq 0 ]] && wait
done
fi
wait
if [[ 0 -eq 1 ]] ; then
mkdir -p $TSTMAN_ORIG $TSTMAN_NEW $TSTMAN_DIFF $TSTMAN_TEXT_DIFF
SAVEME=$( pwd -P )
TSTMAN_ORIG=$( cd $TSTMAN_ORIG; pwd -P )
TSTMAN_NEW=$( cd $TSTMAN_NEW; pwd -P )
mkdir -p $TSTMAN_DIFF
TSTMAN_DIFF=$( cd $TSTMAN_DIFF; pwd -P )
echo "TSTMAN_DIFF is $TSTMAN_DIFF"
j=0
for i in $( /bin/ls $TSTMAN_NEW ) ; do
if [[ ! -d $TSTMAN_NEW/$i ]] ; then
out=${TSTMAN_DIFF}/$i
f1=${TSTMAN_NEW}/${i}
f2=${TSTMAN_ORIG}/${i}
if [[ -f $f1 ]] && [[ -f $f2 ]] ; then
( diff $f1 $f2 >& $out ) &
j=$(( j + 1 ))
[[ $(( $j%5 )) -eq 0 ]] && wait
else
echo "Missing: $f1 or $f2"
fi
fi
done
fi
wait
if [[ 0 -eq 1 ]] ; then
mkdir -p $TSTMAN_ORIG $TSTMAN_NEW $TSTMAN_DIFF $TSTMAN_TEXT_DIFF
SAVEME=$( pwd -P )
TSTMAN_ORIG=$( cd $TSTMAN_ORIG; pwd -P )
TSTMAN_NEW=$( cd $TSTMAN_NEW; pwd -P )
mkdir -p $TSTMAN_TEXT_DIFF
TSTMAN_TEXT_DIFF=$( cd $TSTMAN_TEXT_DIFF; pwd -P )
echo "TSTMAN_TEXT_DIFF is $TSTMAN_TEXT_DIFF"
j=0
for i in $( /bin/ls $TSTMAN_NEW ) ; do
if [[ ! -d $TSTMAN_NEW/$i ]] ; then
out=${TSTMAN_TEXT_DIFF}/$i
f1=${TSTMAN_NEW}/${i}
f2=${TSTMAN_ORIG}/${i}
if [[ -f $f1 ]] && [[ -f $f2 ]] ; then
( ./checktext.sh $f1 $f2 >& $out ) &
j=$(( j + 1 ))
[[ $(( $j%5 )) -eq 0 ]] && wait
fi
fi
done
fi
wait
# TO DO LIST:
# Decide what the directory structure should be with docs and man
# Fix the index.rst and make files, which I copied from docs.