Mercurial > hg > soundsoftware-site
view extra/soundsoftware/extract-javadoc.sh @ 888:96376d0a80bd feature_80
Close obsolete branch feature_80
author | Chris Cannam |
---|---|
date | Sat, 05 Mar 2011 16:02:23 +0000 |
parents | c3544e9fd588 |
children | 73401a15037b |
line wrap: on
line source
#!/bin/bash docdir="/var/doc" project="$1" projectdir="$2" targetdir="$3" if [ -z "$project" ] || [ -z "$targetdir" ] || [ -z "$projectdir" ]; then echo "Usage: $0 <project> <projectdir> <targetdir>" exit 2 fi if [ ! -d "$projectdir" ]; then echo "Project directory $projectdir not found" exit 1 fi if [ ! -d "$targetdir" ]; then echo "Target dir $targetdir not found" exit 1 fi if [ -f "$targetdir/index.html" ]; then echo "Target dir $targetdir already contains index.html" exit 1 fi # Identify Java files whose packages match the trailing parts of their # paths, and list the resulting packages and the path prefixes with # the packages removed (so as to find code in subdirs, # e.g. src/com/example/...) # Regexp match is very rough; check what is actually permitted for # package declarations find "$projectdir" -type f -name \*.java \ -exec grep '^ *package [a-zA-Z][a-zA-Z0-9\._-]*; *$' \{\} /dev/null \; | sed -e 's/\/[^\/]*: *package */:/' -e 's/; *$//' | sort | uniq | ( current_prefix= current_packages= while IFS=: read filepath package; do echo "Looking at $package in $filepath" packagepath=${package//./\/} prefix=${filepath%$packagepath} prefix=${prefix:=$projectdir} if [ "$prefix" = "$filepath" ]; then echo "Package $package does not match suffix of path $filepath, skipping" continue fi if [ "$prefix" != "$current_prefix" ]; then if [ -n "$current_packages" ]; then echo "Running Javadoc for packages $current_packages from prefix $current_prefix" javadoc -sourcepath "$current_prefix" -d "$targetdir" -subpackages $current_packages fi current_prefix="$prefix" current_packages= else current_packages="$current_packages $package" fi done prefix=${prefix:=$projectdir} if [ -n "$current_packages" ]; then echo "Running Javadoc for packages $current_packages in prefix $current_prefix" javadoc -sourcepath "$current_prefix" -d "$targetdir" -subpackages $current_packages fi ) # for exit code: [ -f "$targetdir/index.html" ]