From 682a007d24ada56f2455b69a6977f780fca15d80 Mon Sep 17 00:00:00 2001 From: Cristian Kubis Date: Fri, 10 Jul 2015 09:40:44 +0200 Subject: [PATCH] doc: set playground to nightly for unstable code --- src/librustdoc/html/static/playpen.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/playpen.js b/src/librustdoc/html/static/playpen.js index ff947d93fca16..b7a5f202629fe 100644 --- a/src/librustdoc/html/static/playpen.js +++ b/src/librustdoc/html/static/playpen.js @@ -16,6 +16,7 @@ document.addEventListener('DOMContentLoaded', function() { return; } + var featureRegexp = new RegExp('^\s*#!\\[feature\\(\.*?\\)\\]'); var elements = document.querySelectorAll('pre.rust'); Array.prototype.forEach.call(elements, function(el) { @@ -29,8 +30,14 @@ document.addEventListener('DOMContentLoaded', function() { a.setAttribute('class', 'test-arrow'); var code = el.previousElementSibling.textContent; + + var channel = ''; + if (featureRegexp.test(code)) { + channel = '&version=nightly'; + } + a.setAttribute('href', window.playgroundUrl + '?code=' + - encodeURIComponent(code)); + encodeURIComponent(code) + channel); a.setAttribute('target', '_blank'); el.appendChild(a);