doc.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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>"
  11. echo " <div id=container>"
  12. echo " <div class=article_outer>"
  13. echo " <div class=article_inner>"
  14. echo " <a href=.><img src=libigl-logo.jpg alt='igl logo' class=center></a>"
  15. echo " <h1>libigl</h1>"
  16. echo " Automatically generated documentation for <a href=.>libigl</a>."
  17. echo " <h2>Headers:</h2>"
  18. echo " <table class=full>"
  19. echo " <colgroup>"
  20. echo " <col span="1" style="width:300px">"
  21. echo " </colgroup>"
  22. echo " <tr class=header><th>.h file</th><th>Functions</th></tr>"
  23. # loop over all headers
  24. odd="0"
  25. HEADERS=`ls include/igl/*.h | \
  26. ruby -ne 'puts $_.split("").map{|e| (e>="a"?e.upcase():e.downcase())}.join' | \
  27. sort | \
  28. ruby -ne 'puts $_.split("").map{|e| (e>="a"?e.upcase():e.downcase())}.join'`
  29. for h in $HEADERS
  30. do
  31. b=`basename $h`
  32. # only consider files that exist as proper .h/.cpp files (Those that don't
  33. # are mostly utilitarian or poorly written)
  34. if [ -e "${h%.h}.cpp" ]
  35. then
  36. printf " <tr id='$b' class=d$odd><td>$b</td>"
  37. # portion of file inside namespace
  38. html_nsp=`cat $h | \
  39. perl -ne 'BEGIN{$p = 0} $o=$p;$p ^= $_=~"[{}]";print if $o && $p;' | \
  40. sed -e "s/</\&lt;/g" | sed -e "s/>/\&gt;/g" | sed -e "s/%/%%/g" | \
  41. sed -e "s/^\( *[^ \/].*\)$/<pre><code>\1<\/code><\/pre>/g" | \
  42. sed -e ':a' -e 'N' -e '$!ba' -e 's/<\/code><\/pre>\n<pre><code>/\\\n/g' | \
  43. sed -e "s/^\(.*[^ ].*\)$/\1<br>/g"`;
  44. printf "<td>$html_nsp</td>"
  45. # Try to find functions and corresponding comments
  46. echo "</tr>"
  47. odd=`echo "($odd+1)%2" | bc`
  48. fi
  49. done
  50. echo " </table>"
  51. echo " <p>See also: <a href=tutorial.html>tutorial</a>, <a href=style_guidelines.html>style guidelines</a>, <a href=file-formats/index.html>file formats</a></p>"
  52. echo " <p>Automatically generated on `date` by scripts/doc.sh.</p>"
  53. echo " </div>"
  54. echo " </div>"
  55. echo " </div>"
  56. echo " </body>"
  57. echo "</html>"