Add small llvm/libclang util to exctract doxygen comments
[ardour.git] / tools / doxy2json / ardourdoc.sh
1 #!/bin/bash
2 set -e
3 make
4 cd ../..
5 test -f libs/ardour/ardour/ardour.h
6 LLVMINCLUDE="-I /usr/lib/llvm-3.6/include -I /usr/lib/llvm-3.6/lib/clang/3.6.2/include/"
7
8 TMPFILE=`mktemp`
9 trap 'rm -f $TMPFILE' exit SIGINT SIGTERM
10
11 echo "# analyzing source.. -> $TMPFILE"
12 ./tools/doxy2json/doxy2json \
13         `pkg-config --cflags glib-2.0 glibmm-2.4 cairomm-1.0 gtkmm-2.4 | sed 's/-std=c++11 //;s/-pthread //'` \
14         $LLVMINCLUDE -I /usr/include/linux \
15         -I libs/ardour -I libs/pbd -I libs/lua -I gtk2_ardour -I libs/timecode \
16         -I libs/ltc -I libs/evoral \
17         libs/ardour/ardour/* libs/pbd/pbd/* \
18         gtk2_ardour/*.h \
19         /usr/include/cairomm-1.0/cairomm/context.h \
20 > $TMPFILE
21
22 ls -lh $TMPFILE
23
24 echo "# consolidating JSON"
25 php << EOF
26 <?php
27 \$json = file_get_contents ('$TMPFILE');
28 \$api = array ();
29 foreach (json_decode (\$json, true) as \$a) {
30         if (!isset (\$a['decl'])) { continue; }
31         if (empty (\$a['decl'])) { continue; }
32         if (\$a['decl'] == '::') { continue; }
33         if (substr (\$a['decl'], 0, 1) == '_') { continue; }
34         if (substr (\$a['decl'], 0, 2) == '::') { continue; }
35         if (substr (\$a['decl'], 0, 4) == 'sigc') { continue; }
36         if (substr (\$a['decl'], 0, 5) == 'Atk::') { continue; }
37         if (substr (\$a['decl'], 0, 5) == 'Gdk::') { continue; }
38         if (substr (\$a['decl'], 0, 5) == 'Gtk::') { continue; }
39         if (substr (\$a['decl'], 0, 5) == 'Gio::') { continue; }
40         if (substr (\$a['decl'], 0, 6) == 'Glib::') { continue; }
41         if (substr (\$a['decl'], 0, 7) == 'Pango::') { continue; }
42         if (substr (\$a['decl'], 0, 11) == 'luabridge::') { continue; }
43
44         \$a['decl'] = str_replace ('size_t', 'unsigned long', \$a['decl']);
45         \$canon = str_replace (' *', '*', \$a['decl']);
46         \$api[\$canon] = \$a;
47         }
48 \$jout = array ();
49 foreach (\$api as \$k => \$a) {
50         \$jout[] = \$a;
51 }
52 file_put_contents('doc/ardourapi.json', json_encode (\$jout, JSON_PRETTY_PRINT));
53 EOF
54
55 ls -l doc/ardourapi.json