annotate extra/soundsoftware/extract-javadoc.sh @ 178:2cec5c53cd68 feature_20

* Another minor stylesheet update, start hacking around with Doxyfiles
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 02 Feb 2011 17:04:56 +0000
parents c1e9f2dab1d5
children 3a353bd04976
rev   line source
chris@168 1 #!/bin/sh
chris@168 2
chris@168 3 # Run this script from /var/doc/<project-name>
chris@168 4
chris@168 5 # Find Hg repo and update it
chris@168 6
chris@168 7 docdir=$(pwd)
chris@168 8 name=$(basename $(pwd))
chris@168 9 hgdir="/var/hg/$name"
chris@168 10 echo "Extracting doc for $name"
chris@168 11 if [ ! -d "$hgdir" ]; then
chris@168 12 echo "Error: No $hgdir found for project $name"
chris@168 13 exit 1
chris@168 14 fi
chris@168 15 ( cd "$hgdir" ; hg update ) || exit 1
chris@168 16
chris@168 17 # Identify either a Doxyfile or some Java packages
chris@168 18
chris@168 19 # TODO: Doxyfile
chris@168 20
chris@178 21 doxyfile=`find "$hgdir" -type f -name Doxyfile -print | head -1`
chris@178 22
chris@178 23 echo "This project contains a Doxyfile:"
chris@178 24 echo "$doxyfile"
chris@178 25
chris@178 26 if [ -z "$doxyfile" ]; then
chris@178 27 echo "No Doxyfile: skipping"
chris@178 28 else
chris@178 29
chris@178 30 # hmm. should be a whitelist
chris@178 31
chris@178 32 ( cd "$hgdir" && grep -vi OUTPUT_DIRECTORY "$doxyfile" | grep -vi HTML_OUTPUT | sed -e '$a OUTPUT_DIRECTORY='"$docdir" -e '$a HTML_OUTPUT = .' | doxygen - )
chris@178 33
chris@178 34 fi
chris@168 35
chris@168 36 # This is very rough; check what is actually permitted for package
chris@168 37 # declarations
chris@168 38
chris@168 39 java_packages=`find "$hgdir" -type f -name \*.java -print | \
chris@178 40 xargs grep -h '^ *package [a-zA-Z][a-zA-Z0-9\._-]* *; *' | \
chris@178 41 sort | uniq | \
chris@178 42 sed -e 's/^ *package //' -e 's/ *; *$//'`
chris@168 43
chris@178 44 echo "This project contains Java packages:"
chris@168 45 echo "$java_packages"
chris@168 46
chris@178 47 if [ -z "$java_packages" ]; then
chris@178 48 echo "No Java packages: skipping"
chris@178 49 exit 0
chris@178 50 fi
chris@178 51
chris@178 52 # This won't work if code is in a subdir,
chris@178 53 # e.g. src/com/example/project/Hello.java
chris@178 54
chris@178 55 # We need to convert the package name back to a path, and check
chris@178 56 # whether that matches the tail of the path to a java file that
chris@178 57 # declares itself to be in that package... but we don't have that list
chris@178 58 # of java files to hand here... hm
chris@168 59
chris@168 60 javadoc -sourcepath "$hgdir" -d . -subpackages $java_packages -verbose
chris@168 61
chris@168 62 # If we have just written something to a doc directory that was
chris@168 63 # previously empty, we should switch on Embedded for this project