Skip to content

Commit 682a007

Browse files
committed
doc: set playground to nightly for unstable code
1 parent 67256df commit 682a007

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)