changeset 221:984e4ee774f1 feature_20

Merge from branch "feature_75"
author Chris Cannam
date Thu, 10 Feb 2011 13:43:48 +0000
parents 1e55195bca45 (diff) 3fecad619aa3 (current diff)
children 45c691a2b709
files
diffstat 4 files changed, 245 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/soundsoftware/extract-docs.sh	Thu Feb 10 13:43:48 2011 +0000
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+# Run this script from anywhere
+
+# Enumerate Hg repos; make sure they're up to date; extract docs for
+# each
+
+hgdir="/var/hg"
+docdir="/var/doc"
+
+progdir=$(dirname $0)
+case "$progdir" in
+    /*) ;;
+    *) progdir="$(pwd)/$progdir" ;;
+esac
+
+types="javadoc doxygen"
+
+for x in $types; do
+    if [ ! -x "$progdir/extract-$x.sh" ]; then
+	echo "Helper script not available: $progdir/extract-$x.sh"
+	exit 1
+    fi
+done
+
+for projectdir in "$hgdir"/* ; do
+
+    if [ -d "$projectdir" ] && [ -d "$projectdir/.hg" ]; then
+
+	project=$(basename "$projectdir")
+	echo "Found Hg repo: $projectdir for project $project"
+
+ ##!!! do as www-data:
+	( cd "$projectdir" ; sudo -u www-data hg -q update ) || exit 1
+
+	tmpdir=$(mktemp -d "$docdir/tmp_XXXXXX")
+	
+	case "$tmpdir" in
+	    /*) ;;
+	    *) echo "Temporary directory creation failed"; exit 1;;
+	esac
+
+	targetdir="$docdir/$project"
+
+	echo "Temporary dir is $tmpdir, eventual target is $targetdir"
+
+ ##!!! do as docs user:
+	for x in $types; do
+	    if "$progdir/extract-$x.sh" "$project" "$tmpdir"; then
+		break
+	    else
+		echo "Failed to extract via type $x"
+	    fi
+	done
+
+        if [ -f "$tmpdir/index.html" ]; then
+	    echo "Processing resulted in an index.html being created, looks good!"
+	    if [ ! -d "$targetdir" ] || [ ! -f "$targetdir/index.html" ]; then
+# # If we have just written something to a doc directory that was
+# # previously empty, we should switch on Embedded for this project
+		echo "This project hasn't had doc extracted before -- I should switch on Embedded for it at this point"
+	    fi
+
+	    if [ -d "$targetdir" ]; then
+		mv "$targetdir" "$targetdir"_"$$" && \
+		    mv "$tmpdir" "$targetdir" && \
+		    rm -rf "$targetdir"_"$$"
+	    else 
+		echo "Processing resulted in no index.html, skipping"
+		mv "$tmpdir" "$targetdir"
+	    fi
+
+	else
+	    # generated nothing (useful)
+	    rm -rf "$tmpdir"
+	fi
+    fi
+done
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/extra/soundsoftware/extract-doxygen.sh	Thu Feb 10 13:43:48 2011 +0000
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+hgdir="/var/hg"
+docdir="/var/doc"
+
+project="$1"
+targetdir="$2"
+
+projectdir="$hgdir/$project"
+
+if [ -z "$project" ] || [ -z "$targetdir" ]; then
+    echo "Usage: $0 <project> <targetdir>"
+    exit 2
+fi
+
+if [ ! -d "$projectdir" ] || [ ! -d "$projectdir/.hg" ]; then
+    echo "No hg repo found at $projectdir"
+    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
+
+doxyfile=$(find "$projectdir" -type f -name Doxyfile -print | head -1)
+
+if [ -z "$doxyfile" ]; then
+    echo "No Doxyfile found for project $project"
+    exit 1
+fi
+
+echo "Project $project contains a Doxyfile at $doxyfile"
+
+cd "$projectdir" || exit 1
+
+# hmm. should be a whitelist
+
+cat "$doxyfile" | \
+    grep -vi OUTPUT_DIRECTORY | \
+    grep -vi HTML_OUTPUT | \
+    grep -vi SEARCHENGINE | \
+    grep -vi HAVE_DOT | \
+    grep -vi DOT_FONTNAME | \
+    grep -vi DOT_FONTPATH | \
+    grep -vi DOT_TRANSPARENT | \
+    sed -e '$a OUTPUT_DIRECTORY='"$targetdir" \
+    -e '$a HTML_OUTPUT = .' \
+    -e '$a SEARCHENGINE = NO' \
+    -e '$a HAVE_DOT = YES' \
+    -e '$a DOT_FONTNAME = FreeMono' \
+    -e '$a DOT_FONTPATH = /usr/share/fonts/truetype/freefont' \
+    -e '$a DOT_TRANSPARENT = YES' | \
+    doxygen -
+
--- a/extra/soundsoftware/extract-javadoc.sh	Thu Feb 10 13:43:27 2011 +0000
+++ b/extra/soundsoftware/extract-javadoc.sh	Thu Feb 10 13:43:48 2011 +0000
@@ -1,37 +1,74 @@
-#!/bin/sh
+#!/bin/bash
 
-# Run this script from /var/doc/<project-name>
+hgdir="/var/hg"
+docdir="/var/doc"
 
-# Find Hg repo and update it
+project="$1"
+targetdir="$2"
 
-docdir=$(pwd)
-name=$(basename $(pwd))
-hgdir="/var/hg/$name"
-echo "Extracting doc for $name"
-if [ ! -d "$hgdir" ]; then
-   echo "Error: No $hgdir found for project $name"
-   exit 1
+projectdir="$hgdir/$project"
+
+if [ -z "$project" ] || [ -z "$targetdir" ]; then
+    echo "Usage: $0 <project> <targetdir>"
+    exit 2
 fi
-( cd "$hgdir" ; hg update ) || exit 1
 
-# Identify either a Doxyfile or some Java packages
+if [ ! -d "$projectdir" ] || [ ! -d "$projectdir/.hg" ]; then
+    echo "No hg repo found at $projectdir"
+    exit 1
+fi
 
-# TODO: Doxyfile
+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
 
-# This is very rough; check what is actually permitted for package
-# declarations
+# 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/...)
 
-java_packages=`find "$hgdir" -type f -name \*.java -print | \
-     xargs grep -h '^ *package [a-zA-Z][a-zA-Z0-9\._-]* *; *' | sort | uniq | \
-     sed -e 's/^ *package //' -e 's/ *; *$//'`
+# Regexp match is very rough; check what is actually permitted for
+# package declarations
 
-echo "This project contains java packages:"
-echo "$java_packages"
+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
+    )
 
-# This won't work if code is in a subdir, e.g. src/com/example/project/Hello.java
+# for exit code:
+[ -f "$targetdir/index.html" ]
 
-javadoc -sourcepath "$hgdir" -d . -subpackages $java_packages -verbose
-
-# If we have just written something to a doc directory that was
-# previously empty, we should switch on Embedded for this project
--- a/public/themes/soundsoftware/stylesheets/application.css	Thu Feb 10 13:43:27 2011 +0000
+++ b/public/themes/soundsoftware/stylesheets/application.css	Thu Feb 10 13:43:48 2011 +0000
@@ -151,12 +151,55 @@
 .TableRowColor { background-color: #fdfbf5; color: #000000; border: 0; }
 .TableRowColor td { background-color: #fdfbf5; color: #000000; border: 0; }
 .NavBarCell1 { background-color: #ffe69b; color:#000000 }
+
 .embedded table { border: 0px solid #fff; }
+.embedded h1 { font-family: DroidSans, 'Liberation Sans', tahoma, verdana, sans-serif; }
 .embedded h3 { margin-top: 0.5em; }
 .embedded hr { color: #a9b680; background-color: #a9b680 }
 .embedded center { text-align: left; } /* haha */
 
 /* Special hack to hide the FRAMES | NO FRAMES links -- they don't
-   work in this context -- and right-align the All Classes link */
+   work in this context -- and right-align the All Classes and Detail links */
 .embedded .NavBarCell2 a[target=_top] { width: 0px; visibility: hidden; }
 .embedded .NavBarCell2 + .NavBarCell2 { text-align: right; }
+.embedded .NavBarCell3 + .NavBarCell3 { text-align: right; }
+
+/* For Doxygen in Embedded context (though note some of the Javadoc
+   rules will also apply to Doxygen): */
+
+.memItemLeft,
+.memItemRight,
+.memTemplParams,
+.memTemplItemLeft,
+.memTemplItemRight,
+.indexkey,
+.indexvalue,
+.memproto,
+.memproto td,
+.memdoc a,
+.embedded li .el,
+.embedded a.el { font-family: monospace; }
+
+.embedded .memTemplParams { font-style: italic; }
+
+.embedded .memItemRight a:first-child,
+.embedded .memTemplItemRight a:first-child,
+.embedded .indexkey a:first-child,
+.embedded a.el,
+.embedded .memdoc a { font-weight: bold; } /* function names, etc */
+
+.embedded .memitem { border-bottom: 1px solid #a9b680; padding-top: 0.5em; } 
+.embedded .memitem:last-child { border-bottom: 0px; } 
+
+.embedded .contents { margin-top: 0.5em; }
+.embedded .contents td { padding: 0px; }
+
+.embedded .contents h1,
+.embedded .contents h2,
+.embedded .navigation h1,
+.embedded .navigation h2 { padding-top: 0.5em; padding-bottom: 0.25em; }
+
+.embedded .contents .center { text-align: center; } /* undo javadoc hack above */
+
+
+