From 93ee82b1fda6d395d1f70d7fb767b5dceaf4ca29 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Sat, 5 Jan 2013 16:37:11 +0100 Subject: Big changes in Eigen documentation: - Organize the documentation into "chapters". - Each chapter include many documentation pages, reference pages organized as modules, and a quick reference page. - The "Chapters" tree is created using the defgroup/ingroup mechanism, even for the documentation pages (i.e., .dox files for which I added an \eigenManualPage macro that we can switch between \page or \defgroup ). - Add a "General topics" entry for all pages that do not fit well in the previous "chapters". - The highlevel struture is managed by a new eigendoxy_layout.xml file. - remove the "index" and quite useless pages (namespace list, class hierarchy, member list, file list, etc.) - add the javascript search-engine. - add the "treeview" panel. - remove \tableofcontents (replace them by a custom \eigenAutoToc macro to be able to easily re-enable if needed). - add javascript to automatically generate a TOC from the h1/h2 tags of the current page, and put the TOC in the left side panel. - overload various javascript function generated by doxygen to: - remove the root of the treeview - remove links to section/subsection from the treeview - automatically expand the "Chapters" section - automatically expand the current section - adjust the height of the treeview to take into account the TOC - always use the default .css file, eigendoxy.css now only includes our modifications - use Doxyfile to specify our logo - remove cross references to unsupported modules (temporarily) --- doc/eigen_navtree_hacks.js | 239 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100644 doc/eigen_navtree_hacks.js (limited to 'doc/eigen_navtree_hacks.js') diff --git a/doc/eigen_navtree_hacks.js b/doc/eigen_navtree_hacks.js new file mode 100644 index 000000000..1a09e74fc --- /dev/null +++ b/doc/eigen_navtree_hacks.js @@ -0,0 +1,239 @@ + +// generate a table of contents in the side-nav based on the h1/h2 tags of the current page. +function generate_autotoc() { + var headers = $("h1, h2"); + if(headers.length > 1) { + var toc = $("#side-nav").append(''); + toc = $("#nav-toc"); + var footerHeight = footer.height(); + toc = toc.append(''); + toc = toc.find('ul'); + var indices = new Array(); + indices[0] = 0; + indices[1] = 0; + + var h1counts = $("h1").length; + headers.each(function(i) { + var current = $(this); + var levelTag = current[0].tagName.charAt(1); + if(h1counts==0) + levelTag--; + var cur_id = current.attr("id"); + + indices[levelTag-1]+=1; + var prefix = indices[0]; + if (levelTag >1) { + prefix+="."+indices[1]; + } + + current.html(prefix + " " + current.html()); + for(var l = levelTag; l < 2; ++l){ + indices[l] = 0; + } + + if(cur_id == undefined) { + current.attr('id', 'title' + i); + current.addClass('anchor'); + toc.append("
  • " + current.text() + "
  • "); + } else { + toc.append("
  • " + current.text() + "
  • "); + } + }); + resizeHeight(); + } +} + + +var global_navtree_object; + +// Overloaded to remove links to sections/subsections +function getNode(o, po) +{ + po.childrenVisited = true; + var l = po.childrenData.length-1; + for (var i in po.childrenData) { + var nodeData = po.childrenData[i]; + if((!nodeData[1]) || (nodeData[1].indexOf('#')==-1)) // <- we added this line + po.children[i] = newNode(o, po, nodeData[0], nodeData[1], nodeData[2], i==l); + } +} + +// Overloaded to adjust the size of the navtree wrt the toc +function resizeHeight() +{ + var toc = $("#nav-toc"); + var tocHeight = toc.height(); // <- we added this line + var headerHeight = header.height(); + var footerHeight = footer.height(); + var windowHeight = $(window).height() - headerHeight - footerHeight; + content.css({height:windowHeight + "px"}); + navtree.css({height:(windowHeight-tocHeight) + "px"}); // <- we modified this line + sidenav.css({height:(windowHeight) + "px",top: headerHeight+"px"}); +} + +// Overloaded to save the root node into global_navtree_object +function initNavTree(toroot,relpath) +{ + var o = new Object(); + global_navtree_object = o; // <- we added this line + o.toroot = toroot; + o.node = new Object(); + o.node.li = document.getElementById("nav-tree-contents"); + o.node.childrenData = NAVTREE; + o.node.children = new Array(); + o.node.childrenUL = document.createElement("ul"); + o.node.getChildrenUL = function() { return o.node.childrenUL; }; + o.node.li.appendChild(o.node.childrenUL); + o.node.depth = 0; + o.node.relpath = relpath; + o.node.expanded = false; + o.node.isLast = true; + o.node.plus_img = document.createElement("img"); + o.node.plus_img.src = relpath+"ftv2pnode.png"; + o.node.plus_img.width = 16; + o.node.plus_img.height = 22; + + navTo(o,toroot,window.location.hash,relpath); + + $(window).bind('hashchange', function(){ + if (window.location.hash && window.location.hash.length>1){ + var a; + if ($(location).attr('hash')){ + var clslink=stripPath($(location).attr('pathname'))+':'+ + $(location).attr('hash').substring(1); + a=$('.item a[class$="'+clslink+'"]'); + } + if (a==null || !$(a).parent().parent().hasClass('selected')){ + $('.item').removeClass('selected'); + $('.item').removeAttr('id'); + } + var link=stripPath2($(location).attr('pathname')); + navTo(o,link,$(location).attr('hash'),relpath); + } + }) + + $(window).load(showRoot); +} + +// return false if the the node has no children at all, or has only section/subsection children +function checkChildrenData(node) { + if (!(typeof(node.childrenData)==='string')) { + for (var i in node.childrenData) { + var url = node.childrenData[i][1]; + if(url.indexOf("#")==-1) + return true; + } + return false; + } + return (node.childrenData); +} + +// Modified to: +// 1 - remove the root node (added && node.parentNode.parentNode.parentNode) +// 2 - remove the section/subsection children +function createIndent(o,domNode,node,level) +{ + if (node.parentNode && node.parentNode.parentNode + && node.parentNode.parentNode.parentNode // <- we added this line + ) { + createIndent(o,domNode,node.parentNode,level+1); + } + var imgNode = document.createElement("img"); + imgNode.width = 16; + imgNode.height = 22; + + if (level==0 && checkChildrenData(node)) { // <- we modified this line to use checkChildrenData(node) instead of node.childrenData + node.plus_img = imgNode; + node.expandToggle = document.createElement("a"); + node.expandToggle.href = "javascript:void(0)"; + node.expandToggle.onclick = function() { + if (node.expanded) { + $(node.getChildrenUL()).slideUp("fast"); + if (node.isLast) { + node.plus_img.src = node.relpath+"ftv2plastnode.png"; + } else { + node.plus_img.src = node.relpath+"ftv2pnode.png"; + } + node.expanded = false; + } else { + expandNode(o, node, false, false); + } + } + node.expandToggle.appendChild(imgNode); + domNode.appendChild(node.expandToggle); + } else { + domNode.appendChild(imgNode); + } + if (level==0) { + if (node.isLast) { + if (checkChildrenData(node)) { // <- we modified this line to use checkChildrenData(node) instead of node.childrenData + imgNode.src = node.relpath+"ftv2plastnode.png"; + } else { + imgNode.src = node.relpath+"ftv2lastnode.png"; + domNode.appendChild(imgNode); + } + } else { + if (checkChildrenData(node)) { // <- we modified this line to use checkChildrenData(node) instead of node.childrenData + imgNode.src = node.relpath+"ftv2pnode.png"; + } else { + imgNode.src = node.relpath+"ftv2node.png"; + domNode.appendChild(imgNode); + } + } + } else { + if (node.isLast) { + imgNode.src = node.relpath+"ftv2blank.png"; + } else { + imgNode.src = node.relpath+"ftv2vertline.png"; + } + } + imgNode.border = "0"; +} + +// Overloaded to automatically expand the selected node +function selectAndHighlight(n) +{ + var a; + if ($(location).attr('hash')) { + var link=stripPath($(location).attr('pathname'))+':'+ + $(location).attr('hash').substring(1); + a=$('.item a[class$="'+link+'"]'); + } + if (a && a.length) { + a.parent().parent().addClass('selected'); + a.parent().parent().attr('id','selected'); + highlightAnchor(); + } else if (n) { + $(n.itemDiv).addClass('selected'); + $(n.itemDiv).attr('id','selected'); + } + expandNode(global_navtree_object, n, true, true); // <- we added this line + showRoot(); +} + + +$(document).ready(function() { + + generate_autotoc(); + + (function (){ // wait until the first "selected" element has been created + try { + + // this line will triger an exception if there is no #selected element, i.e., before the tree structure is complete. + document.getElementById("selected").className = "item selected"; + + // ok, the default tree has been created, we can keep going... + + // expand the "Chapters" node + expandNode(global_navtree_object, global_navtree_object.node.children[0].children[2], true, true); + + // Hide the root node "Eigen" + $(document.getElementsByClassName('index.html')[0]).parent().parent().css({display:"none"}); + + } catch (err) { + setTimeout(arguments.callee, 10); + } + })(); +}); -- cgit v1.2.3