···11+#! /bin/bash
22+33+# ./corpus.sh scans all .cmti and .cmt, and optionally .cmi files, in the
44+# current opam switch. For each one, it runs odoc compile, which triggers the
55+# odoc parser on every comment found. If any errors or warnings are reported by
66+# the parser, they will be written to stderr.
77+#
88+# A corpus of .cmt[i] files is typically installed with something like
99+#
1010+# opam install lwt --criteria='+count(solution)'
1111+#
1212+#
1313+# Typical usage is somehing like:
1414+#
1515+# ./corpus.sh > results.txt 2>&1
1616+1717+SWITCH=$(opam config var prefix)
1818+1919+CMTI=$(find $SWITCH/lib -name '*.cmti')
2020+CMT=$(find $SWITCH/lib -name '*.cmt')
2121+# CMI=$(find $SWITCH/lib -name '*.cmi')
2222+2323+mkdir -p _build/
2424+2525+function apply_odoc
2626+{
2727+ FILES=$1
2828+2929+ for FILE in $FILES
3030+ do
3131+ echo $FILE
3232+ odoc compile --package corpus -o _build/file.odoc $FILE 2>&1
3333+ done
3434+}
3535+3636+apply_odoc "$CMTI"
3737+apply_odoc "$CMT"
3838+# apply_odoc "$CMI"