doc.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. # THIS would be much easier with a ruby script that parsed each .h/.cpp pair
  3. # and created a <tr> row.
  4. #
  5. echo "<html>"
  6. echo " <head>"
  7. echo " <title>libigl auto-documentation</title>"
  8. echo ' <link href="./style.css" rel="stylesheet" type="text/css">'
  9. echo " </head>"
  10. echo " <body class=article_body>"
  11. echo " <div class=article>"
  12. echo " <a href=.><img src=libigl-logo.jpg alt='igl logo' class=center></a>"
  13. echo " <h1>libigl</h1>"
  14. echo " Automatically generated documentation for <a href=.>libigl</a>."
  15. echo " <h2>Headers:</h2>"
  16. echo " <table>"
  17. echo " <tr><th>.h file</th><th>Functions</th></tr>"
  18. # loop over all headers
  19. odd="0"
  20. for h in include/igl/*.h;
  21. do
  22. b=`basename $h`
  23. # only consider files that exist as proper .h/.cpp files (Those that don't
  24. # are mostly utilitarian or poorly written)
  25. if [ -e "${h%.h}.cpp" ]
  26. then
  27. printf " <tr id='$b' class=d$odd><td>$b</td>"
  28. # portion of file inside namespace
  29. html_nsp=`cat $h | \
  30. perl -ne 'BEGIN{$p = 0} $o=$p;$p ^= $_=~"[{}]";print if $o && $p;' | \
  31. sed -e "s/</\&lt;/g" | sed -e "s/>/\&gt;/g" | sed -e "s/%/%%/g" | \
  32. sed -e "s/^\( *[^ \/].*\)$/<pre><code>\1<\/code><\/pre>/g" | \
  33. sed -e ':a' -e 'N' -e '$!ba' -e 's/<\/code><\/pre>\n<pre><code>/\\\n/g' | \
  34. sed -e "s/^\(.*[^ ].*\)$/\1<br>/g"`;
  35. printf "<td>$html_nsp</td>"
  36. # Try to find functions and corresponding comments
  37. echo "</tr>"
  38. odd=`echo "($odd+1)%2" | bc`
  39. fi
  40. done
  41. echo " </table>"
  42. echo " <p>See also: <a href=tutorial.html>tutorial</a>, <a href=style_guidelines.html>style guidelines</a></p>"
  43. echo " <p>Automatically generated on `date` by scripts/doc.sh.</p>"
  44. echo " </div>"
  45. echo " </body>"
  46. echo "</html>"