Skip to content

Commit 1e42a68

Browse files
committed
DOC link example gallery scripts rather than inline
1 parent 4ec8630 commit 1e42a68

File tree

4 files changed

+121
-125
lines changed

4 files changed

+121
-125
lines changed

doc/conf.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@
225225

226226
trim_doctests_flags = True
227227

228-
# Add the 'copybutton' javascript, to hide/show the prompt in code
229-
# examples
228+
230229
def setup(app):
230+
# to hide/show the prompt in code examples:
231231
app.add_javascript('js/copybutton.js')
232+
# to format example galleries:
233+
app.add_javascript('js/examples.js')
234+
app.add_stylesheet('css/examples.css')

doc/sphinxext/gen_rst.py

Lines changed: 5 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -489,130 +489,12 @@ def generate_example_rst(app):
489489
490490
491491
<style type="text/css">
492-
493492
div#sidebarbutton {
494493
display: none;
495494
}
496-
497-
.figure {
498-
float: left;
499-
margin: 10px;
500-
-webkit-border-radius: 10px; /* Saf3-4, iOS 1-3.2, Android <1.6 */
501-
-moz-border-radius: 10px; /* FF1-3.6 */
502-
border-radius: 10px; /* Opera 10.5, IE9, Saf5, Chrome, FF4, iOS 4, Android 2.1+ */
503-
border: 2px solid #fff;
504-
background-color: white;
505-
/* --> Thumbnail image size */
506-
width: 150px;
507-
height: 100px;
508-
-webkit-background-size: 150px 100px; /* Saf3-4 */
509-
-moz-background-size: 150px 100px; /* FF3.6 */
510-
}
511-
512-
.figure img {
513-
display: inline;
514-
}
515-
516-
div.docstringWrapper p.caption {
517-
display: block;
518-
-webkit-box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.0);
519-
-moz-box-shadow: 0px 0px 20px rgba(0, 0, 0, .0); /* FF3.5 - 3.6 */
520-
box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.0); /* Opera 10.5, IE9, FF4+, Chrome 10+ */
521-
padding: 0px;
522-
border: white;
523-
}
524-
525-
div.docstringWrapper p {
526-
display: none;
527-
background-color: white;
528-
-webkit-box-shadow: 0px 0px 20px rgba(0, 0, 0, 1.00);
529-
-moz-box-shadow: 0px 0px 20px rgba(0, 0, 0, 1.00); /* FF3.5 - 3.6 */
530-
box-shadow: 0px 0px 20px rgba(0, 0, 0, 1.00); /* Opera 10.5, IE9, FF4+, Chrome 10+ */
531-
padding: 13px;
532-
margin-top: 0px;
533-
border-style: solid;
534-
border-width: 1px;
535-
}
536-
537-
538495
</style>
539496
540497
541-
.. raw:: html
542-
543-
544-
<script type="text/javascript">
545-
546-
function animateClone(e){
547-
var position;
548-
position = $(this).position();
549-
var clone = $(this).closest('.thumbnailContainer').find('.clonedItem');
550-
var clone_fig = clone.find('.figure');
551-
clone.css("left", position.left - 70).css("top", position.top - 70).css("position", "absolute").css("z-index", 1000).css("background-color", "white");
552-
553-
var cloneImg = clone_fig.find('img');
554-
555-
clone.show();
556-
clone.animate({
557-
height: "270px",
558-
width: "320px"
559-
}, 0
560-
);
561-
cloneImg.css({
562-
'max-height': "200px",
563-
'max-width': "280px"
564-
});
565-
cloneImg.animate({
566-
height: "200px",
567-
width: "280px"
568-
}, 0
569-
);
570-
clone_fig.css({
571-
'margin-top': '20px',
572-
});
573-
clone_fig.show();
574-
clone.find('p').css("display", "block");
575-
clone_fig.css({
576-
height: "240",
577-
width: "305px"
578-
});
579-
cloneP_height = clone.find('p.caption').height();
580-
clone_fig.animate({
581-
height: (200 + cloneP_height)
582-
}, 0
583-
);
584-
585-
clone.bind("mouseleave", function(e){
586-
clone.animate({
587-
height: "100px",
588-
width: "150px"
589-
}, 10, function(){$(this).hide();});
590-
clone_fig.animate({
591-
height: "100px",
592-
width: "150px"
593-
}, 10, function(){$(this).hide();});
594-
});
595-
} //end animateClone()
596-
597-
598-
$(window).load(function () {
599-
$(".figure").css("z-index", 1);
600-
601-
$(".docstringWrapper").each(function(i, obj){
602-
var clone;
603-
var $obj = $(obj);
604-
clone = $obj.clone();
605-
clone.addClass("clonedItem");
606-
clone.appendTo($obj.closest(".thumbnailContainer"));
607-
clone.hide();
608-
$obj.bind("mouseenter", animateClone);
609-
}); // end each
610-
}); // end
611-
612-
</script>
613-
614-
615-
616498
Examples
617499
========
618500
@@ -969,13 +851,13 @@ def generate_file_rst(fname, target_dir, src_dir, root_dir, plot_gallery):
969851
# incrementally: 1, 2, 3 and not 1, 2, 5)
970852
# * iterate over [fig_mngr.num for fig_mngr in
971853
# matplotlib._pylab_helpers.Gcf.get_all_fig_managers()]
972-
for fig_num in (fig_mngr.num for fig_mngr in
973-
matplotlib._pylab_helpers.Gcf.get_all_fig_managers()):
854+
fig_managers = matplotlib._pylab_helpers.Gcf.get_all_fig_managers()
855+
for fig_mngr in fig_mngr:
974856
# Set the fig_num figure as the current figure as we can't
975857
# save a figure that's not the current figure.
976-
plt.figure(fig_num)
977-
plt.savefig(image_path % fig_num)
978-
figure_list.append(image_fname % fig_num)
858+
plt.figure(fig_mngr.num)
859+
plt.savefig(image_path % fig_mngr.num)
860+
figure_list.append(image_fname % fig_mngr.num)
979861
except:
980862
print(80 * '_')
981863
print('%s is not compiling:' % fname)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* Styling for example galleries */
2+
3+
.thumbnailContainer .figure {
4+
float: left;
5+
margin: 10px;
6+
-webkit-border-radius: 10px; /* Saf3-4, iOS 1-3.2, Android <1.6 */
7+
-moz-border-radius: 10px; /* FF1-3.6 */
8+
border-radius: 10px; /* Opera 10.5, IE9, Saf5, Chrome, FF4, iOS 4, Android 2.1+ */
9+
border: 2px solid #fff;
10+
background-color: white;
11+
/* --> Thumbnail image size */
12+
width: 150px;
13+
height: 100px;
14+
-webkit-background-size: 150px 100px; /* Saf3-4 */
15+
-moz-background-size: 150px 100px; /* FF3.6 */
16+
}
17+
18+
.thumbnailContainer .figure img {
19+
display: inline;
20+
}
21+
22+
div.docstringWrapper p.caption {
23+
display: block;
24+
-webkit-box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.0);
25+
-moz-box-shadow: 0px 0px 20px rgba(0, 0, 0, .0); /* FF3.5 - 3.6 */
26+
box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.0); /* Opera 10.5, IE9, FF4+, Chrome 10+ */
27+
padding: 0px;
28+
border: white;
29+
}
30+
31+
div.docstringWrapper p {
32+
display: none;
33+
background-color: white;
34+
-webkit-box-shadow: 0px 0px 20px rgba(0, 0, 0, 1.00);
35+
-moz-box-shadow: 0px 0px 20px rgba(0, 0, 0, 1.00); /* FF3.5 - 3.6 */
36+
box-shadow: 0px 0px 20px rgba(0, 0, 0, 1.00); /* Opera 10.5, IE9, FF4+, Chrome 10+ */
37+
padding: 13px;
38+
margin-top: 0px;
39+
border-style: solid;
40+
border-width: 1px;
41+
}
42+
43+
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/* Interactive component of example galleries */
2+
3+
function animateClone(e){
4+
var position;
5+
position = $(this).position();
6+
var clone = $(this).closest('.thumbnailContainer').find('.clonedItem');
7+
var clone_fig = clone.find('.figure');
8+
clone.css("left", position.left - 70).css("top", position.top - 70).css("position", "absolute").css("z-index", 1000).css("background-color", "white");
9+
10+
var cloneImg = clone_fig.find('img');
11+
12+
clone.show();
13+
clone.animate({
14+
height: "270px",
15+
width: "320px"
16+
}, 0
17+
);
18+
cloneImg.css({
19+
'max-height': "200px",
20+
'max-width': "280px"
21+
});
22+
cloneImg.animate({
23+
height: "200px",
24+
width: "280px"
25+
}, 0
26+
);
27+
clone_fig.css({
28+
'margin-top': '20px',
29+
});
30+
clone_fig.show();
31+
clone.find('p').css("display", "block");
32+
clone_fig.css({
33+
height: "240",
34+
width: "305px"
35+
});
36+
cloneP_height = clone.find('p.caption').height();
37+
clone_fig.animate({
38+
height: (200 + cloneP_height)
39+
}, 0
40+
);
41+
42+
clone.bind("mouseleave", function(e){
43+
clone.animate({
44+
height: "100px",
45+
width: "150px"
46+
}, 10, function(){$(this).hide();});
47+
clone_fig.animate({
48+
height: "100px",
49+
width: "150px"
50+
}, 10, function(){$(this).hide();});
51+
});
52+
} //end animateClone()
53+
54+
55+
$(window).load(function () {
56+
$(".thumbnailContainer .figure").css("z-index", 1);
57+
58+
$(".docstringWrapper").each(function(i, obj){
59+
var clone;
60+
var $obj = $(obj);
61+
clone = $obj.clone();
62+
clone.addClass("clonedItem");
63+
clone.appendTo($obj.closest(".thumbnailContainer"));
64+
clone.hide();
65+
$obj.bind("mouseenter", animateClone);
66+
}); // end each
67+
}); // end
68+

0 commit comments

Comments
 (0)