Skip to content

Commit bb73c7a

Browse files
committed
Rollup merge of rust-lang#26932 - tsurai:master, r=steveklabnik
Simple adjustment to auto select the nightly channel for examples using unstable feature.
2 parents f7f28c8 + 682a007 commit bb73c7a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/librustdoc/html/static/playpen.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ document.addEventListener('DOMContentLoaded', function() {
1616
return;
1717
}
1818

19+
var featureRegexp = new RegExp('^\s*#!\\[feature\\(\.*?\\)\\]');
1920
var elements = document.querySelectorAll('pre.rust');
2021

2122
Array.prototype.forEach.call(elements, function(el) {
@@ -29,8 +30,14 @@ document.addEventListener('DOMContentLoaded', function() {
2930
a.setAttribute('class', 'test-arrow');
3031

3132
var code = el.previousElementSibling.textContent;
33+
34+
var channel = '';
35+
if (featureRegexp.test(code)) {
36+
channel = '&version=nightly';
37+
}
38+
3239
a.setAttribute('href', window.playgroundUrl + '?code=' +
33-
encodeURIComponent(code));
40+
encodeURIComponent(code) + channel);
3441
a.setAttribute('target', '_blank');
3542

3643
el.appendChild(a);

0 commit comments

Comments
 (0)