Skip to content

Commit

Permalink
fix autodoc for spurrious toggles (apache#16452)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasDelteil authored and aaronmarkham committed Oct 16, 2019
1 parent 00c1628 commit 7d0753b
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions docs/python_docs/_static/autodoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,32 @@
/* Customizations to the Sphinx auto module plugin output */
function auto_index() {
var targets = $("dl.class>dt,dl.function>dt");

var li_node = $("li.current>span>a.current.reference.internal").parent().parent();
var html = "<ul id='autodoc'>";
if (li_node.length > 0) {
for (var i = 0; i < targets.length; ++i) {
var id = $(targets[i]).attr('id');
if (id) {
var paths = id.split('.')
if (paths.length >= 2) {
var id_simple = paths.pop();
id_simple = paths.pop() + "." + id_simple;
} else {
var id_simple = id;
if (targets.length > 0) {
for (var i = 0; i < targets.length; ++i) {
var id = $(targets[i]).attr('id');
if (id) {
var paths = id.split('.')
if (paths.length >= 2) {
var id_simple = paths.pop();
id_simple = paths.pop() + "." + id_simple;
} else {
var id_simple = id;
}
html += "<li><span class='link-wrapper'><a class='reference internal' href='#";
html += id;
html += "'>" + id_simple + "</a></span</li>";
}
html += "<li><span class='link-wrapper'><a class='reference internal' href='#";
html += id;
html += "'>" + id_simple + "</a></span</li>";
}
html += "</ul>";
li_node.append(html);
li_node.prepend("<a><span id='autodoc_toggle' onclick='$(\"#autodoc\").toggle()'>[toggle]</span></a>")
}
html += "</ul>";
li_node.append(html);
li_node.prepend("<a><span id='autodoc_toggle' onclick='$(\"#autodoc\").toggle()'>[toggle]</span></a>")
} else {
setTimeout(auto_index, 500);
}

}
$(document).ready(auto_index);

0 comments on commit 7d0753b

Please sign in to comment.