template/publish.js
function buildNav( members ) {

	var seen = {};
	var nav = navigationMaster;



	if ( members.modules.length ) {

		members.modules.sort(sort_by('longname', true, function(a){return a.toUpperCase()}));
		members.modules.forEach( function ( m ) {
			if ( !hasOwnProp.call( seen, m.longname ) ) {

				nav.module.members.push( linkto( m.longname, m.name ) );
			}
			seen[m.longname] = true;
		} );
	}

	if ( members.externals.length ) {

		members.externals.sort(sort_by('longname', true, function(a){return a.toUpperCase()}));
		members.externals.forEach( function ( e ) {
			if ( !hasOwnProp.call( seen, e.longname ) ) {

				nav.external.members.push( linkto( e.longname, e.name.replace( /(^"|"$)/g, '' ) ) );
			}
			seen[e.longname] = true;
		} );
	}

	if ( members.classes.length ) {

		members.classes.sort(sort_by('longname', true, function(a){return a.toUpperCase()}));
		members.classes.forEach( function ( c ) {
			if ( !hasOwnProp.call( seen, c.longname ) ) {

				nav.class.members.push( { link: linkto( c.longname, c.longname ), namespace:c} );
			}
			seen[c.longname] = true;
		} );

	}
	/*
	 if ( members.events.length ) {

	 members.events.forEach( function ( e ) {
	 if ( !hasOwnProp.call( seen, e.longname ) ) {

	 nav.event.members.push( linkto( e.longname, e.name ) );

	 }
	 seen[e.longname] = true;
	 } );

	 }*/


	if ( members.typedef.length ) {

		members.typedef.forEach( function ( td ) {
			if ( !hasOwnProp.call( seen, td.longname ) ) {

				nav.typedef.members.push( {link:linkto( td.name, td.name ), namespace:{ longname:td.longname } });

			}
			seen[td.longname] = true;
		} );

	}
	if ( members.callbacks.length ) {

		members.callbacks.forEach( function ( cb ) {
			if ( !hasOwnProp.call( seen, cb.longname ) ) {

				nav.callbacks.members.push( {link:linkto( cb.longname, cb.longname.split('#')[0] ), namespace:{ longname:cb.longname } });

			}
			seen[cb.longname] = true;
		} );

	}
	if ( members.namespaces.length ) {


		members.namespaces.sort(sort_by('longname', true, function(a){return a.toUpperCase()}));
		members.namespaces.forEach( function ( n ) {

			if ( !hasOwnProp.call( seen, n.longname ))
			{
				nav.namespace.members.push( { link: linkto( n.longname, n.longname ), namespace:n} );
			}
			seen[n.longname] = true;
		} );

	}

	if ( members.mixins.length ) {

		members.mixins.sort(sort_by('longname', true, function(a){return a.toUpperCase()}));
		members.mixins.forEach( function ( m ) {
			if ( !hasOwnProp.call( seen, m.longname ) ) {

				nav.mixin.members.push( linkto( m.longname, m.longname ) );
			}
			seen[m.longname] = true;
		} );

	}

	if ( members.tutorials.length ) {

		members.tutorials.sort(sort_by('name', true, function(a){return a.toUpperCase()}));
		members.tutorials.forEach( function ( t ) {

			nav.tutorial.members.push( tutoriallink( t.name ) );
		} );

	}

	if ( members.globals.length ) {
		members.globals.sort(sort_by('longname', true, function(a){return a.toUpperCase()}));
		members.globals.forEach( function ( g ) {
			if ( g.kind !== 'typedef' && !hasOwnProp.call( seen, g.longname ) ) {

				nav.global.members.push( linkto( g.longname, g.longname ) );
			}
			seen[g.longname] = true;
		} );
	}


	var topLevelNav = [];
	_.each( nav, function ( entry, name ) {
		if ( entry.members.length > 0 && name !== "index" ) {
			topLevelNav.push( {
				title   : entry.title,
				link    : entry.link,
				members : entry.members
			} );
		}
	} );



	nav.topLevelNav = topLevelNav;

}
function buildNav( members ) {

	var seen = {};
	var nav = navigationMaster;



	if ( members.modules.length ) {

		members.modules.sort(sort_by('longname', true, function(a){return a.toUpperCase()}));
		members.modules.forEach( function ( m ) {
			if ( !hasOwnProp.call( seen, m.longname ) ) {

				nav.module.members.push( linkto( m.longname, m.name ) );
			}
			seen[m.longname] = true;
		} );
	}

	if ( members.externals.length ) {

		members.externals.sort(sort_by('longname', true, function(a){return a.toUpperCase()}));
		members.externals.forEach( function ( e ) {
			if ( !hasOwnProp.call( seen, e.longname ) ) {

				nav.external.members.push( linkto( e.longname, e.name.replace( /(^"|"$)/g, '' ) ) );
			}
			seen[e.longname] = true;
		} );
	}

	if ( members.classes.length ) {

		members.classes.sort(sort_by('longname', true, function(a){return a.toUpperCase()}));
		members.classes.forEach( function ( c ) {
			if ( !hasOwnProp.call( seen, c.longname ) ) {

				nav.class.members.push( { link: linkto( c.longname, c.longname ), namespace:c} );
			}
			seen[c.longname] = true;
		} );

	}
	/*
	 if ( members.events.length ) {

	 members.events.forEach( function ( e ) {
	 if ( !hasOwnProp.call( seen, e.longname ) ) {

	 nav.event.members.push( linkto( e.longname, e.name ) );

	 }
	 seen[e.longname] = true;
	 } );

	 }*/


	if ( members.typedef.length ) {

		members.typedef.forEach( function ( td ) {
			if ( !hasOwnProp.call( seen, td.longname ) ) {

				nav.typedef.members.push( {link:linkto( td.name, td.name ), namespace:{ longname:td.longname } });

			}
			seen[td.longname] = true;
		} );

	}
	if ( members.callbacks.length ) {

		members.callbacks.forEach( function ( cb ) {
			if ( !hasOwnProp.call( seen, cb.longname ) ) {

				nav.callbacks.members.push( {link:linkto( cb.longname, cb.longname.split('#')[0] ), namespace:{ longname:cb.longname } });

			}
			seen[cb.longname] = true;
		} );

	}
	if ( members.namespaces.length ) {


		members.namespaces.sort(sort_by('longname', true, function(a){return a.toUpperCase()}));
		members.namespaces.forEach( function ( n ) {

			if ( !hasOwnProp.call( seen, n.longname ))
			{
				nav.namespace.members.push( { link: linkto( n.longname, n.longname ), namespace:n} );
			}
			seen[n.longname] = true;
		} );

	}

	if ( members.mixins.length ) {

		members.mixins.sort(sort_by('longname', true, function(a){return a.toUpperCase()}));
		members.mixins.forEach( function ( m ) {
			if ( !hasOwnProp.call( seen, m.longname ) ) {

				nav.mixin.members.push( linkto( m.longname, m.longname ) );
			}
			seen[m.longname] = true;
		} );

	}

	if ( members.tutorials.length ) {

		members.tutorials.sort(sort_by('name', true, function(a){return a.toUpperCase()}));
		members.tutorials.forEach( function ( t ) {

			nav.tutorial.members.push( tutoriallink( t.name ) );
		} );

	}

	if ( members.globals.length ) {
		members.globals.sort(sort_by('longname', true, function(a){return a.toUpperCase()}));
		members.globals.forEach( function ( g ) {
			if ( g.kind !== 'typedef' && !hasOwnProp.call( seen, g.longname ) ) {

				nav.global.members.push( linkto( g.longname, g.longname ) );
			}
			seen[g.longname] = true;
		} );
	}


	var topLevelNav = [];
	_.each( nav, function ( entry, name ) {
		if ( entry.members.length > 0 && name !== "index" ) {
			topLevelNav.push( {
				title   : entry.title,
				link    : entry.link,
				members : entry.members
			} );
		}
	} );



	nav.topLevelNav = topLevelNav;

}
Create the navigation sidebar.
@param {object} members The members that will be used to create the sidebar.
@param {array<object>} members.classes
@param {array<object>} members.externals
@param {array<object>} members.globals
@param {array<object>} members.mixins
@param {array<object>} members.modules
@param {array<object>} members.namespaces
@param {array<object>} members.tutorials
@param {array<object>} members.events
@return {string} The HTML for the navigation sidebar.