forked from plumed/plumed2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract
executable file
·431 lines (367 loc) · 14.1 KB
/
extract
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
#! /bin/bash
source ../sourceme.sh
# initial cleanup
rm -f errors
rm -rf automatic
mkdir automatic
# Check for files that register actions with no documentation
for file in ../src/*/*.cpp
do
nreg=`grep "PLUMED_REGISTER_ACTION" $file | wc -l | awk '{print $1}'`
if [ $nreg -gt 0 ] ; then
ndoc=`grep PLUMEDOC $file | wc -l | awk '{print $1}'`
if [ $ndoc -eq 0 ] ; then
echo The following file registered an action but provided no documentation: $file >> errors
fi
fi
done
# Create the list of codes that plumed works with from the set of available patches
for file in ../patches/*.diff
do
myengine=`echo "$file" | sed -e 's/.diff//' | sed -e 's/..\/patches\///'`
mytag=`echo "$myengine" | sed -e 's/\./-/g'`
echo "- $mytag" >> automatic/CODESL.list # list only, for Intro
echo "- \subpage $mytag " >> automatic/CODES.list
echo "/**" >> automatic/$myengine.txt
echo "\page $mytag $myengine" >> automatic/$myengine.txt
../src/lib/plumed --no-mpi patch -e $myengine -i -q >> automatic/$myengine.txt
echo "*/" >> automatic/$myengine.txt
done
# Generate all the documentation pages from comments
{
cat ../*/*/*cpp
# documentation for scripts:
for file in ../scripts/*.sh
do
name=$(basename ${file%.sh})
cat << EOF
//+PLUMEDOC TOOLS $name
/*
EOF
../src/lib/plumed $name --description
cat << EOF
\note This command line tool is implemented as a shell script. Its help message is pasted below:
\verbatim
EOF
../src/lib/plumed --no-mpi $name --help
cat << EOF
\endverbatim
*/
//+ENDPLUMEDOC
EOF
done
} |
awk 'BEGIN{gfile="automatic/GLOSSARY.list"; dfile="automatic/DICTIONARY.list"; }{
if($1=="//+ENDPLUMEDOC" && inside){
inside=0;
module=0
print "*/" >output
}
if(inside>=2 && NF==0){
print "</td> </tr>" >> lfile
if(module==1) print "</td> </tr>" >> mfile
if(inside==2){ printf "</td> </tr>\n" > gfile; }
if(inside==3){ printf "</td> </tr>\n" > dfile; }
inside=1
module=0
}
if(inside==1 && $1!="/*" && $1!="*/") print $0 > output
if(inside>=2 && $1!="/*" && $1!="*/" ){
print $0 > output
printf "%s", $0 >> lfile
if(module==1) printf "%s", $0 >> mfile
if(inside==2){ printf "%s", $0 > gfile; }
if(inside==3){ printf "%s", $0 > dfile; }
}
if($1=="//+PLUMEDOC"){
if( $2=="TOPOLOGY" ||
$2=="COLVAR" ||
$2=="MCOLVAR" ||
$2=="DCOLVAR"||
$2=="MFILTERS" ||
$2=="MTRANSFORMS" ||
$2=="VOLUMES" ||
$2=="MCOLVARF" ||
$2=="MCOLVARB" ||
$2=="MATRIX" ||
$2=="MATRIXF" ||
$2=="CONCOMP" ||
$2=="FUNCTION" ||
$2=="GRIDCALC" ||
$2=="REWEIGHTING"||
$2=="PRINTANALYSIS" ||
$2=="DIMRED" ||
$2=="GRIDANALYSIS" ||
$2=="BIAS" ||
$2=="GENERIC" ||
$2=="VATOM" ||
$2=="TOOLS" ||
$2=="ANALYSIS" ||
$2=="LANDMARKS" ){
if(lfile!="") close(lfile)
lfile="automatic/"$2".list"
printf "<tr> <td width=%s> \\subpage %s </td> <td>","5%", $3 >> lfile
# printf "<tr> <td width=5%> \\ref %s </td><td> %s </td><td>",$3, $2 > gfile
printf "<tr> <td width=%s> \\ref %s </td><td> %s </td><td>","5%",$3, $2 > gfile
if(output!="")close(output);
output="automatic/"$3".tmp";
print "/**" > output
print "\\page "$3" "$3 > output
# print "\\section "$3 >output
inside=2;
module=0
} else if ( $2=="INTERNAL" ){
if(output!="")close(output);
printf "<tr> <td width=%s> \\subpage %s </td><td> %s </td><td>","5%",$3, $2 > dfile
output="automatic/"$3".tmp";
lfile="automatic/"$3".tmp";
print "/**" > output
print "\\page "$3" "$3 > output
# print "\\section "$3 >output
inside=3;
module=0
} else {
# this is the place where other modules are checked for
if(mfile!="") close(mfile)
mfile="automatic/"$2".list"
printf "<tr> <td width=%s> \\subpage %s </td> <td>","5%", $3 >> mfile
printf "<tr> <td width=%s> \\ref %s </td><td> %s </td><td>","5%",$3, $2 > gfile
if(output!="")close(output);
output="automatic/"$3".tmp";
print "/**" > output
print "\\page "$3" "$3 > output
inside=2
module=1
split($2,array,"_");
if(lfile!="") close(lfile)
lfile="automatic/"array[2]"_OTHERMODULES.list"
printf "<tr> <td width=%s> \\ref %s </td><td> (from \\ref %s module) ","5%", $3 ,array[1] >> lfile
if(afile!="") close(afile)
afile="automatic/ADDITIONALMODULES.list"
cmd="grep description: " array[1]".md | sed -e 's/description://'"
cmd | getline describe
close(cmd)
cmd="grep authors: " array[1]".md | sed -e 's/authors://'"
cmd | getline authors
close(cmd)
cmd="grep reference: " array[1]".md | sed -e 's/reference://'"
cmd | getline reference
close(cmd)
printf "<tr><td width=%s> \\subpage %s </td><td> %s </td><td> %s </td><td> %s </td></tr>\n", "10%", array[1], describe, authors, reference >> afile
}
}
}'
# Now put all list files in alphabetical order
for file in automatic/*.list ; do
# -k 5 is required to mix together refs and subpages
sort -k 5 $file | uniq > $file-1
mv $file-1 $file
done
# The following are not proper "list" files so should be generated after sorting
long_version="$(../src/lib/plumed --no-mpi info --long-version)"
git_version="$(../src/lib/plumed --no-mpi info --git-version)"
cat > automatic/VERSION.list << EOF
This manual has been compiled from PLUMED version <b> $long_version </b>
(git version: <b> $git_version </b>).
EOF
if test "$TRAVIS" == true ; then
cat >> automatic/VERSION.list << EOF
Manual built on Travis CI for branch $TRAVIS_BRANCH.
EOF
fi
if test -d regtests ; then
cat >> automatic/VERSION.list << EOF
Regtest results for this version can be found <a href="../regtests/report.html">here</a>.
EOF
fi
for file in ../CHANGES/* ; do
echo "- Changes for \\subpage $(cat $file | grep "@page" | awk '{print $2}')"
done > automatic/CHANGES.list
touch automatic/PDFMANUAL.list
if test "$make_pdfdoc" = yes ; then
cat >> automatic/PDFMANUAL.list << EOF
\htmlonly
An experimental PDF copy of this manual can be found
<a href="../manual.pdf"> here</a>, but the html documentation should
be considered as the official one.
The PDF version has some known issue (e.g. some
links are not working properly and images are not correctly included).
The goal of the PDF manual is to allow people to download a full copy on the documentation for offline
access and to perform easily full-text searches.
Notice that the manual is updated very frequently (sometime more than once per week),
so keep your local version of the PDF manual up to date.
Since the PDF manual is 200+ pages and is continuously updated,
<b>
please do not print it!
</b>
\endhtmlonly
EOF
fi
# Generate links to standard tutorial pages
for file in ./tutorials/*.txt ; do
link=`grep link: $file | sed -e 's/link://' | sed -e 's/\@/\\\/'`
describe=`grep description: $file | sed -e 's/description://'`
echo "<tr> <td> $link </td> <td> $describe </td> </tr>" >> automatic/TUTORIALS.list
done
# Generate links to old tutorial pages
for file in ./tutorials/old_tutorials/*.txt ; do
link=`grep link: $file | sed -e 's/link://' | sed -e 's/\@/\\\/'`
describe=`grep description: $file | sed -e 's/description://'`
echo "<tr> <td> $link </td> <td> $describe </td> </tr>" >> automatic/OLDTUTORIALS.list
done
# Generate links to websites
for file in ./tutorials/*.site; do
link=`grep link: $file | sed -e 's/link://' | sed -e 's/\@/\\\/'`
describe=`grep description: $file | sed -e 's/description://'`
echo "<tr> <td> $link </td> <td> $describe </td> </tr>" >> automatic/WEBSITES.list
done
# Generate links for module specific tutorials
for file in ./tutorials/others/*.txt ; do
arrIN=(${file//.\/tutorials\/others\// });
temp=$(echo $arrIN | tr "-" "\n");
modtut=$(echo $temp | awk '{print toupper($1)}')
link=`grep link: $file | sed -e 's/link://'`
describe=`grep description: $file | sed -e 's/description://'`
echo "<tr> <td> $link </td> <td> $describe </td> </tr>" >> automatic/"$modtut"_TUTORIALS.list
done
# Find what modules the user has installed
# Find the list of modules
# if [ -d ../mymodules ] ; then
# sed -i '' -e 's/type="user" visible="no" url="mymodules.html"/type="user" visible="yes" url="mymodules.html"/' PlumedLayout.xml
echo "<table align=center frame=void width=65%% cellpadding=5%%>" > automatic/MODULES.list
echo "<tr> <td> <b> Module name </b> </td> <td> <b> Default behavior </b> </td> </tr>" >> automatic/MODULES.list
for file in `ls ../src/*/module.type | sed -e 's/..\/src\///' | sed -e 's/\/module.type//'`
do
defoff=0
dstr=`head ../src/$file/module.type`
if [ "$dstr" != "always" ] ; then
echo "<tr> <td> $file </td>" >> automatic/MODULES.list
if [ "$dstr" == "default-on" ] ; then
echo "<td> on </td> </tr>" >> automatic/MODULES.list
else
echo "<td> off </td> </tr>" >> automatic/MODULES.list
defoff=1
fi
# # Generate documentation and accreditation on modules page
# echo "\section $file" >> automatic/mymodules.list
# echo >> automatic/mymodules.list
# echo "<table align=center frame=void width=95%% celpadding=5%%>" >> automatic/mymodules.list
# echo "<tr> <td width=70%%> </td> </tr> <td>" >> automatic/mymodules.list
# author=`grep AUTHOR: ../mymodules/available-modules/"$file" | sed -e 's/AUTHOR://'`
# echo "<b> author: $author </b>" >> automatic/mymodules.list
# echo "</td> </tr>" >> automatic/mymodules.list
# echo "<tr> <td colspan="2">" >> automatic/mymodules.list
# dline=`grep -n DESCRIPTION: ../mymodules/available-modules/"$file" | sed -n 's/^\([0-9]*\)[:].*/\1/p'` >> automatic/mymodules.list
# tail -n +$(($dline+1)) ../mymodules/available-modules/"$file" >> automatic/mymodules.list
# echo "</td> </tr> </table>" >> automatic/mymodules.list
# echo >> automatic/mymodules.list
# echo >> automatic/mymodules.list
# Find src files in module and add a link to the module description
docfiles=$(cat ../src/"$file"/*cpp | grep PLUMEDOC | grep -v END | awk '{print $3;}')
for docfile in $docfiles ; do
cat automatic/"$docfile".tmp |
awk -v o=$defoff '{ print }
/\\page '$docfile'/{
if( o==0 ){
print "<table align=center frame=void width=95%% celpadding=5%%>"
print "<tr> <td width=70%%> </td> <td>"
print "<b> This is part of the '$file' \\link mymodules module \\endlink</b>"
print "</td> </tr> </table>"
} else {
print "<table align=center frame=void width=95%% celpadding=5%%>"
print "<tr> <td width=60%%> </td> <td>"
print "<b> This is part of the '$file' \\link mymodules module \\endlink</b>"
print "</td> </tr>"
print "<tr> <td width=60%%> </td> <td>"
print "<b> It is only available if you configure PLUMED with ./configure --enable-modules='$file' . "
print "Furthermore, this feature is still being developed so take care when using it and report any problems on the mailing list.</b>"
print "</td> </tr>"
print "</table>"
}
}' > automatic/"$docfile"1.tmp
mv automatic/"$docfile"1.tmp automatic/"$docfile".tmp
done
fi
done
echo "</table>" >> automatic/MODULES.list
# fi
# Generate all the documentation from keywords
for file in automatic/*.tmp
do
flag=${file#automatic/}
flag=${flag/.tmp}
if grep -q '//+PLUMEDOC INTERNAL' $file 1>/dev/null 2>/dev/null ; then
cp $file automatic/$flag.txt
else
if ! ../src/lib/plumed --no-mpi manual --action=$flag > automatic/$flag.man 2> /dev/null ; then
echo Full manual for action $flag will not be generated as you are building the manual from a code where this action was not compiled >> errors
elif ! grep -q "\par Examples" $file 1>/dev/null 2>/dev/null
then
echo There are no examples inside documentation for action: $flag >> errors
fi
{
awk '/\\par Examples/{xx=1}{if(xx==0) printf("%s\n",$0)}' automatic/$flag.tmp
cat automatic/$flag.man
awk '/\\par Examples/{xx=1}{if(xx==1) printf("%s\n",$0)}' automatic/$flag.tmp
} > automatic/$flag.txt
fi
done
sed -ie 's/<b> --/<b> \\c \\-\\-/g' automatic/*.txt
rm automatic/*.txte
for file in COLVAR MCOLVAR MFILTERS MTRANSFORMS VOLUMES DCOLVAR MCOLVARF MCOLVARB ANALYSIS LANDMARKS MATRIX MATRIXF CONCOMP REWEIGHTING PRINTANALYSIS BIAS GLOSSARY \
DICTIONARY TUTORIALS OLDTUTORIALS WEBSITES FUNCTION TOPOLOGY VATOM GRIDCALC GRIDANALYSIS DIMRED \
TOOLS
do
mv automatic/$file.list automatic/$file.1.list
{
echo "<table align=center frame=void width=95%% cellpadding=5%%>"
cat automatic/$file.1.list
echo "</table>"
} > automatic/$file.list
rm automatic/$file.1.list
done
for file in automatic/*_*.list
do
mv $file $file.1
{
echo "<table align=center frame=void width=95%% cellpadding=5%%>"
cat $file.1
echo "</table>"
} > $file
rm $file.1
done
for file in automatic/*_OTHERMODULES.list
do
ff=${file%_OTHERMODULES.list}.list
if test -f "$ff" ; then
mv $ff $ff.1
{
cat $ff.1
echo "In addition to the keywords above, by enabling optional modules you can access to the following keywords:"
cat $file
} > $ff
fi
done
# Make all double hyphens appear as double hypens
sed -ie 's/<b> --/<b> \\c \\-\\-/g' automatic/*.txt
rm automatic/*.txte
rm -f *PP.txt *PP.md
keywords=`grep "@[A-Z_]*@" *.md | awk -F"@" '{print $2}' | sort | uniq`
for f in *.txt *.md
do
test -f $f || continue
extension=${f##*.}
file=${f%.$extension}
# first replace with the content of the files
# then grep out the special strings
cp $f ${file}PP.$extension
for kk in $keywords
do
sed -ie "
/^ *@"$kk"@ *$/r automatic/$kk.list
" ${file}PP.$extension
done
rm -f *."$extension"e
grep -Ev '^ *@[A-Z:_]*@ *$' ${file}PP.$extension > tmp;
mv tmp ${file}PP.$extension
done