doctemplate/publish.js
function buildNav(members, opts) {
    var nav = '',
        seen = {},
        list = {
            Modules : 'modules',
            Externals : 'externals',
            Classes : 'classes',
            Events : 'events',
            Namespaces : 'namespaces',
            Mixins : 'mixins'
        },
        hasClassList = false,
        classNav = '',
        globalNav = '';

    nav += '<h2><a href="index.html">' + (opts.indexName || 'Index') + '</a></h2>';

    for (var name in list) {
        if (members[list[name]].length) {
            nav += '<div class="nav-'+list[name]+'">';
            nav += '<h3>'+name+'</h3><ul>';
            members[list[name]].forEach(function(m) {
                if ( !hasOwnProp.call(seen, m.longname) ) {
                    nav += '<li title="'+m.longname+'">'+linkto(m.longname, m.name)+'</li>';
                }
                seen[m.longname] = true;

                var funcs = find({
                    kind : 'function',
                    memberof : m.longname==='Global' ? {isUndefined:true} : m.longname
                });

                if (funcs.length) {
                    nav += '<div class="navinner nav-methods"><h4>Methods</h4><ul>';
                    funcs.forEach(function(f) {
                        if (!hasOwnProp.call(seen, f.longname)) {
                            nav += '<li title="'+f.longname+'">'+linkto(f.longname, f.name)+'</li>';
                        }
                        seen[m.longname] = true;
                    });
                    nav += '</ul></div>';
                }
            });
            nav += '</ul>';
        }
    }

    /*
    if (members.modules.length) {
        nav += '<h3>Modules</h3><ul>';
        members.modules.forEach(function(m) {
            if ( !hasOwnProp.call(seen, m.longname) ) {
                nav += '<li title="'+m.longname+'">'+linkto(m.longname, m.name)+'</li>';
            }
            seen[m.longname] = true;

            methods(m);
        });

        nav += '</ul>';
    }

    if (members.externals.length) {
        nav += '<h3>Externals</h3><ul>';
        members.externals.forEach(function(e) {
            if ( !hasOwnProp.call(seen, e.longname) ) {
                nav += '<li title="'+e.longname+'">'+linkto( e.longname, e.name.replace(/(^"|"$)/g, '') )+'</li>';
            }
            seen[e.longname] = true;
        });

        nav += '</ul>';
    }

    if (members.classes.length) {
        nav += '<h3>Classes</h3><ul>';
        members.classes.forEach(function(c) {
            if ( !hasOwnProp.call(seen, c.longname) ) {
                nav += '<li title="'+c.longname+'">'+linkto(c.longname, c.name)+'</li>';
            }
            seen[c.longname] = true;

            methods(c);
        });
        nav += '</ul>';
    }

    if (members.events.length) {
        nav += '<h3>Events</h3><ul>';
        members.events.forEach(function(e) {
            if ( !hasOwnProp.call(seen, e.longname) ) {
                nav += '<li title="'+e.longname+'">'+linkto(e.longname, e.name)+'</li>';
            }
            seen[e.longname] = true;
        });

        nav += '</ul>';
    }

    if (members.namespaces.length) {
        nav += '<h3>Namespaces</h3><ul>';
        members.namespaces.forEach(function(n) {
            if ( !hasOwnProp.call(seen, n.longname) ) {
                nav += '<li title="'+n.longname+'">'+linkto(n.longname, n.name)+'</li>';
            }
            seen[n.longname] = true;

            methods(n);
        });

        nav += '</ul>';
    }

    if (members.mixins.length) {
        nav += '<h3>Mixins</h3><ul>';
        members.mixins.forEach(function(m) {
            if ( !hasOwnProp.call(seen, m.longname) ) {
                nav += '<li title="'+m.longname+'">'+linkto(m.longname, m.name)+'</li>';
            }
            seen[m.longname] = true;
        });

        nav += '</ul>';
    }
    */

    if (members.tutorials.length) {
        nav += '<h3>Tutorials</h3><ul>';
        members.tutorials.forEach(function(t) {
            nav += '<li>'+tutoriallink(t.name)+'</li>';
        });

        nav += '</ul>';
    }

    if (members.globals.length) {
        members.globals.forEach(function(g) {
            if ( g.kind !== 'typedef' && !hasOwnProp.call(seen, g.longname) ) {
                globalNav += '<li title="'+g.longname+'">' + linkto(g.longname, g.name) + '</li>';
            }
            seen[g.longname] = true;
        });

        if (!globalNav) {
            // turn the heading into a link so you can actually get to the global page
            nav += '<h3>' + linkto('global', 'Global') + '</h3>';
        }
        else {
            nav += '<h3>Global</h3><ul>' + globalNav + '</ul>';
        }
    }

    return nav;
}
function buildNav(members, opts) {
    var nav = '',
        seen = {},
        list = {
            Modules : 'modules',
            Externals : 'externals',
            Classes : 'classes',
            Events : 'events',
            Namespaces : 'namespaces',
            Mixins : 'mixins'
        },
        hasClassList = false,
        classNav = '',
        globalNav = '';

    nav += '<h2><a href="index.html">' + (opts.indexName || 'Index') + '</a></h2>';

    for (var name in list) {
        if (members[list[name]].length) {
            nav += '<div class="nav-'+list[name]+'">';
            nav += '<h3>'+name+'</h3><ul>';
            members[list[name]].forEach(function(m) {
                if ( !hasOwnProp.call(seen, m.longname) ) {
                    nav += '<li title="'+m.longname+'">'+linkto(m.longname, m.name)+'</li>';
                }
                seen[m.longname] = true;

                var funcs = find({
                    kind : 'function',
                    memberof : m.longname==='Global' ? {isUndefined:true} : m.longname
                });

                if (funcs.length) {
                    nav += '<div class="navinner nav-methods"><h4>Methods</h4><ul>';
                    funcs.forEach(function(f) {
                        if (!hasOwnProp.call(seen, f.longname)) {
                            nav += '<li title="'+f.longname+'">'+linkto(f.longname, f.name)+'</li>';
                        }
                        seen[m.longname] = true;
                    });
                    nav += '</ul></div>';
                }
            });
            nav += '</ul>';
        }
    }

    /*
    if (members.modules.length) {
        nav += '<h3>Modules</h3><ul>';
        members.modules.forEach(function(m) {
            if ( !hasOwnProp.call(seen, m.longname) ) {
                nav += '<li title="'+m.longname+'">'+linkto(m.longname, m.name)+'</li>';
            }
            seen[m.longname] = true;

            methods(m);
        });

        nav += '</ul>';
    }

    if (members.externals.length) {
        nav += '<h3>Externals</h3><ul>';
        members.externals.forEach(function(e) {
            if ( !hasOwnProp.call(seen, e.longname) ) {
                nav += '<li title="'+e.longname+'">'+linkto( e.longname, e.name.replace(/(^"|"$)/g, '') )+'</li>';
            }
            seen[e.longname] = true;
        });

        nav += '</ul>';
    }

    if (members.classes.length) {
        nav += '<h3>Classes</h3><ul>';
        members.classes.forEach(function(c) {
            if ( !hasOwnProp.call(seen, c.longname) ) {
                nav += '<li title="'+c.longname+'">'+linkto(c.longname, c.name)+'</li>';
            }
            seen[c.longname] = true;

            methods(c);
        });
        nav += '</ul>';
    }

    if (members.events.length) {
        nav += '<h3>Events</h3><ul>';
        members.events.forEach(function(e) {
            if ( !hasOwnProp.call(seen, e.longname) ) {
                nav += '<li title="'+e.longname+'">'+linkto(e.longname, e.name)+'</li>';
            }
            seen[e.longname] = true;
        });

        nav += '</ul>';
    }

    if (members.namespaces.length) {
        nav += '<h3>Namespaces</h3><ul>';
        members.namespaces.forEach(function(n) {
            if ( !hasOwnProp.call(seen, n.longname) ) {
                nav += '<li title="'+n.longname+'">'+linkto(n.longname, n.name)+'</li>';
            }
            seen[n.longname] = true;

            methods(n);
        });

        nav += '</ul>';
    }

    if (members.mixins.length) {
        nav += '<h3>Mixins</h3><ul>';
        members.mixins.forEach(function(m) {
            if ( !hasOwnProp.call(seen, m.longname) ) {
                nav += '<li title="'+m.longname+'">'+linkto(m.longname, m.name)+'</li>';
            }
            seen[m.longname] = true;
        });

        nav += '</ul>';
    }
    */

    if (members.tutorials.length) {
        nav += '<h3>Tutorials</h3><ul>';
        members.tutorials.forEach(function(t) {
            nav += '<li>'+tutoriallink(t.name)+'</li>';
        });

        nav += '</ul>';
    }

    if (members.globals.length) {
        members.globals.forEach(function(g) {
            if ( g.kind !== 'typedef' && !hasOwnProp.call(seen, g.longname) ) {
                globalNav += '<li title="'+g.longname+'">' + linkto(g.longname, g.name) + '</li>';
            }
            seen[g.longname] = true;
        });

        if (!globalNav) {
            // turn the heading into a link so you can actually get to the global page
            nav += '<h3>' + linkto('global', 'Global') + '</h3>';
        }
        else {
            nav += '<h3>Global</h3><ul>' + globalNav + '</ul>';
        }
    }

    return nav;
}
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.