···1+#! /bin/bash
2+3+# ./corpus.sh scans all .cmti and .cmt, and optionally .cmi files, in the
4+# current opam switch. For each one, it runs odoc compile, which triggers the
5+# odoc parser on every comment found. If any errors or warnings are reported by
6+# the parser, they will be written to stderr.
7+#
8+# A corpus of .cmt[i] files is typically installed with something like
9+#
10+# opam install lwt --criteria='+count(solution)'
11+#
12+#
13+# Typical usage is somehing like:
14+#
15+# ./corpus.sh > results.txt 2>&1
16+17+SWITCH=$(opam config var prefix)
18+19+CMTI=$(find $SWITCH/lib -name '*.cmti')
20+CMT=$(find $SWITCH/lib -name '*.cmt')
21+# CMI=$(find $SWITCH/lib -name '*.cmi')
22+23+mkdir -p _build/
24+25+function apply_odoc
26+{
27+ FILES=$1
28+29+ for FILE in $FILES
30+ do
31+ echo $FILE
32+ odoc compile --package corpus -o _build/file.odoc $FILE 2>&1
33+ done
34+}
35+36+apply_odoc "$CMTI"
37+apply_odoc "$CMT"
38+# apply_odoc "$CMI"