templates/default/fulldoc/html/js/app.js in yard-0.9.20 vs templates/default/fulldoc/html/js/app.js in yard-0.9.21
- old
+ new
@@ -169,10 +169,11 @@
var show = false;
var toc = _toc;
var counter = 0;
var tags = ['h2', 'h3', 'h4', 'h5', 'h6'];
var i;
+ var curli;
if ($('#filecontents h1').length > 1) tags.unshift('h1');
for (i = 0; i < tags.length; i++) { tags[i] = '#filecontents ' + tags[i]; }
var lastTag = parseInt(tags[0][1], 10);
$(tags.join(', ')).each(function() {
if ($(this).parents('.method_details .docstring').length != 0) return;
@@ -188,18 +189,28 @@
this.id = proposedId;
}
}
if (thisTag > lastTag) {
for (i = 0; i < thisTag - lastTag; i++) {
- var tmp = $('<ol/>'); toc.append(tmp); toc = tmp;
+ if ( typeof(curli) == "undefined" ) {
+ curli = $('<li/>');
+ toc.append(curli);
+ }
+ toc = $('<ol/>');
+ curli.append(toc);
+ curli = undefined;
}
}
if (thisTag < lastTag) {
- for (i = 0; i < lastTag - thisTag; i++) toc = toc.parent();
+ for (i = 0; i < lastTag - thisTag; i++) {
+ toc = toc.parent();
+ toc = toc.parent();
+ }
}
var title = $(this).attr('toc-title');
if (typeof(title) == "undefined") title = $(this).text();
- toc.append('<li><a href="#' + this.id + '">' + title + '</a></li>');
+ curli =$('<li><a href="#' + this.id + '">' + title + '</a></li>');
+ toc.append(curli);
lastTag = thisTag;
});
if (!show) return;
html = '<div id="toc"><p class="title hide_toc"><a href="#"><strong>Table of Contents</strong></a></p></div>';
$('#content').prepend(html);