Skip to content

Commit 7d0753b

Browse files
ThomasDelteilaaronmarkham
authored andcommitted
fix autodoc for spurrious toggles (apache#16452)
1 parent 00c1628 commit 7d0753b

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

docs/python_docs/_static/autodoc.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,32 @@
2020
/* Customizations to the Sphinx auto module plugin output */
2121
function auto_index() {
2222
var targets = $("dl.class>dt,dl.function>dt");
23-
2423
var li_node = $("li.current>span>a.current.reference.internal").parent().parent();
2524
var html = "<ul id='autodoc'>";
2625
if (li_node.length > 0) {
27-
for (var i = 0; i < targets.length; ++i) {
28-
var id = $(targets[i]).attr('id');
29-
if (id) {
30-
var paths = id.split('.')
31-
if (paths.length >= 2) {
32-
var id_simple = paths.pop();
33-
id_simple = paths.pop() + "." + id_simple;
34-
} else {
35-
var id_simple = id;
26+
if (targets.length > 0) {
27+
for (var i = 0; i < targets.length; ++i) {
28+
var id = $(targets[i]).attr('id');
29+
if (id) {
30+
var paths = id.split('.')
31+
if (paths.length >= 2) {
32+
var id_simple = paths.pop();
33+
id_simple = paths.pop() + "." + id_simple;
34+
} else {
35+
var id_simple = id;
36+
}
37+
html += "<li><span class='link-wrapper'><a class='reference internal' href='#";
38+
html += id;
39+
html += "'>" + id_simple + "</a></span</li>";
3640
}
37-
html += "<li><span class='link-wrapper'><a class='reference internal' href='#";
38-
html += id;
39-
html += "'>" + id_simple + "</a></span</li>";
4041
}
42+
html += "</ul>";
43+
li_node.append(html);
44+
li_node.prepend("<a><span id='autodoc_toggle' onclick='$(\"#autodoc\").toggle()'>[toggle]</span></a>")
4145
}
42-
html += "</ul>";
43-
li_node.append(html);
44-
li_node.prepend("<a><span id='autodoc_toggle' onclick='$(\"#autodoc\").toggle()'>[toggle]</span></a>")
4546
} else {
4647
setTimeout(auto_index, 500);
4748
}
49+
4850
}
4951
$(document).ready(auto_index);

0 commit comments

Comments
 (0)