/** Called automatically by JsDoc Toolkit. */
load(JSDOC.opt.t + 'src/Symbol.js');
load(JSDOC.opt.t + 'src/Utils.js');
load(JSDOC.opt.t + 'src/Operator.js');
load(JSDOC.opt.t + 'src/Render.js');

function publish(symbolSet) {
	var renderMode = JSDOC.opt.D.renderMode;
	var templatedocs = renderMode == 'templatedocs';
	var extension = templatedocs ? '.jstl' : '.html';
	publish.conf = {  // trailing slash expected for dirs
		outDir: JSDOC.opt.d || SYS.pwd + '../out/jsdoc/',
		templateDir: JSDOC.opt.t || SYS.pwd + '../templates/jsdoc/',
		staticDir: (JSDOC.opt.t || SYS.pwd + '../templates/jsdoc/') + 'static/',
		symbolsDir: renderMode == 'docs' ? 'packages/' : 'paper/',
		// Use no extensions in links for templatedocs
		ext: templatedocs ? '' : extension,
		srcDir: 'symbols/src/',
		renderMode: renderMode,
		globalName: 'Global Scope'
	};
	publish.conf.packagesDir = publish.conf.outDir + publish.conf.symbolsDir;

	if (renderMode == 'docs') {
		// Copy over the static files
		Utils.copyDirectory(
			new java.io.File(publish.conf.staticDir),
			new java.io.File(publish.conf.outDir)
		);
	} else {
		Utils.deleteFiles(new File(publish.conf.outDir));
		new java.io.File(publish.conf.outDir + 'paper/').mkdirs();
	}

	// used to allow Link to check the details of things being linked to
	Link.symbolSet = symbolSet;

	// get an array version of the symbolset, useful for filtering
	var symbols = symbolSet.toArray(),
		files = JSDOC.opt.srcFiles,
		aliasSort = Utils.makeSortby('alias'),
 		classes = symbols.filter(Utils.isaClass).sort(aliasSort);
	
	// create a filemap in which outfiles must be to be named uniquely, ignoring case
	// Since we want lowercase links in templatedocs, we always use this
	if (JSDOC.opt.u || templatedocs) {
		var filemapCounts = {};
		Link.filemap = {};
		for (var i = 0, l = classes.length; i < l; i++) {
			var alias = classes[i].alias,
				lcAlias = alias.toLowerCase();
			
			if (!filemapCounts[lcAlias]) {
				filemapCounts[lcAlias] = 1;
			} else {
				filemapCounts[lcAlias]++;
			}
			// Use lowercase links for templatedocs
			var linkAlias = templatedocs ? lcAlias : alias;
			Link.filemap[alias] = filemapCounts[lcAlias] > 1
					? linkAlias + '_' + filemapCounts[lcAlias] : linkAlias;
		}
	}
	
	Link.base = '../';

	// create each of the class pages
	for (var i = 0, l = classes.length; i < l; i++) {
		var symbol = classes[i];
		
		symbol.events = symbol.getEvents();   // 1 order matters
		symbol.methods = symbol.getMethods(); // 2
		for (var j = 0; j < symbol.methods.length; j++) {
			var method = symbol.methods[j];
			method.isOperator = Operator.isOperator(method);
		}
		
		Link.currentSymbol= symbol;
		var html = Render._class(symbol);
		var name = ((JSDOC.opt.u)? Link.filemap[symbol.alias] : symbol.alias)
				+ extension;
		if (renderMode == 'docs') {
			html = Render.html({
				content: html,
				title: symbol.alias
			});
		}
		IO.saveFile(publish.conf.packagesDir, name, html);
	}
	if (templatedocs) {
		IO.saveFile(publish.conf.outDir, 'packages.js', Render.indexjs());
	} else {
		IO.saveFile(publish.conf.classesDir, 'index.html', Render.index());
	}
}
@@ -367,116 +367,12 @@
 ';%0A%09
-publish.conf = %7B  // trailing slash expected for dirs%0A%09%09outDir: JSDOC.opt.d %7C%7C SYS.pwd + '../out/jsdoc/',%0A%09%09
+var 
 temp
@@ -378,17 +378,18 @@
 plateDir
-:
+ =
  JSDOC.o
@@ -431,24 +431,24 @@
 oc/'
-,%0A%09%09staticDir: (
+;%0A%09var outDir = 
 JSDO
@@ -445,33 +445,33 @@
 Dir = JSDOC.opt.
-t
+d
  %7C%7C SYS.pwd + '.
@@ -476,39 +476,76 @@
 '../
-templates/jsdoc/') + 'static/',
+out/jsdoc/';%0A%0A%09publish.conf = %7B  // trailing slash expected for dirs
 %0A%09%09s
@@ -689,16 +689,135 @@
 ension,%0A
+%09%09outDir: outDir,%0A%09%09templateDir: templateDir,%0A%09%09staticDir: templateDir + 'static/',%0A%09%09classesDir: outDir + 'classes/',%0A
 %09%09srcDir
@@ -896,83 +896,8 @@
 %0A%09%7D;
-%0A%09publish.conf.packagesDir = publish.conf.outDir + publish.conf.symbolsDir;
 %0A%0A%09i
@@ -1167,25 +1167,18 @@
 onf.
-outDir + 'paper/'
+classesDir
 ).mk
@@ -2889,22 +2889,21 @@
 sh.conf.
-packag
+class
 esDir, n

Clean up directory settings.