From e5bbbca33e11d9e22dbbe32c975f908710d4155c Mon Sep 17 00:00:00 2001
From: Alex Crichton
This file may not be copied, modified, or distributed except according to those terms.
+ + diff --git a/src/doc/rust.css b/src/doc/rust.css index d60dd54a67d..3957231a195 100644 --- a/src/doc/rust.css +++ b/src/doc/rust.css @@ -313,6 +313,19 @@ table th { padding: 5px; } +/* Code snippets */ + +.rusttest { display: none; } +pre.rust { position: relative; } +pre.rust a { transform: scaleX(-1); } +.test-arrow { + display: inline-block; + position: absolute; + top: 0; + right: 10px; + font-size: 150%; +} + @media (min-width: 1170px) { pre { font-size: 15px; diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 2004285ecb9..a65c06107ce 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -17,7 +17,8 @@ #![license = "MIT/ASL2"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", - html_root_url = "http://doc.rust-lang.org/")] + html_root_url = "http://doc.rust-lang.org/", + html_playground_url = "http://play.rust-lang.org/")] #![feature(macro_rules, managed_boxes, default_type_params, phase, globs)] #![no_std] diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 6aa07415e9c..2ccf431fc22 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -50,7 +50,8 @@ #![crate_type = "rlib"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", - html_root_url = "http://doc.rust-lang.org/")] + html_root_url = "http://doc.rust-lang.org/", + html_playground_url = "http://play.rust-lang.org/")] #![no_std] #![feature(globs, macro_rules, managed_boxes, phase, simd)] diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index ddfe8380e09..10584223486 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -84,7 +84,8 @@ #![license = "MIT/ASL2"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", - html_root_url = "http://doc.rust-lang.org/")] + html_root_url = "http://doc.rust-lang.org/", + html_playground_url = "http://play.rust-lang.org/")] #![feature(globs, phase)] #![deny(missing_doc)] #![deny(deprecated_owned_vector)] diff --git a/src/libglob/lib.rs b/src/libglob/lib.rs index 86753fbb811..f3e1da77ce5 100644 --- a/src/libglob/lib.rs +++ b/src/libglob/lib.rs @@ -29,8 +29,8 @@ #![license = "MIT/ASL2"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", - html_root_url = "http://doc.rust-lang.org/")] - + html_root_url = "http://doc.rust-lang.org/", + html_playground_url = "http://play.rust-lang.org/")] #![deny(deprecated_owned_vector)] use std::cell::Cell; diff --git a/src/libgreen/lib.rs b/src/libgreen/lib.rs index 31fd8950c80..c75d69480ce 100644 --- a/src/libgreen/lib.rs +++ b/src/libgreen/lib.rs @@ -203,7 +203,8 @@ #![crate_type = "dylib"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", - html_root_url = "http://doc.rust-lang.org/")] + html_root_url = "http://doc.rust-lang.org/", + html_playground_url = "http://play.rust-lang.org/")] // NB this does *not* include globs, please keep it that way. #![feature(macro_rules, phase)] diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index ff580559969..daacf8b3c47 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -111,7 +111,8 @@ if logging is disabled, none of the components of the log will be executed. #![crate_type = "dylib"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", - html_root_url = "http://doc.rust-lang.org/")] + html_root_url = "http://doc.rust-lang.org/", + html_playground_url = "http://play.rust-lang.org/")] #![feature(macro_rules)] #![deny(missing_doc, deprecated_owned_vector)] diff --git a/src/libnum/lib.rs b/src/libnum/lib.rs index 29cf769ffc9..fae21e80f30 100644 --- a/src/libnum/lib.rs +++ b/src/libnum/lib.rs @@ -50,7 +50,8 @@ #![license = "MIT/ASL2"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", - html_root_url = "http://doc.rust-lang.org/")] + html_root_url = "http://doc.rust-lang.org/", + html_playground_url = "http://play.rust-lang.org/")] #![deny(deprecated_owned_vector)] diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 3ed086e9b13..7a12dcf9f7f 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -21,7 +21,8 @@ #![crate_type = "rlib"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", - html_root_url = "http://doc.rust-lang.org/")] + html_root_url = "http://doc.rust-lang.org/", + html_playground_url = "http://play.rust-lang.org/")] #![feature(macro_rules, phase, globs)] #![no_std] diff --git a/src/libregex/lib.rs b/src/libregex/lib.rs index a48760913c1..44c206162ab 100644 --- a/src/libregex/lib.rs +++ b/src/libregex/lib.rs @@ -360,7 +360,8 @@ #![license = "MIT/ASL2"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", - html_root_url = "http://doc.rust-lang.org/")] + html_root_url = "http://doc.rust-lang.org/", + html_playground_url = "http://play.rust-lang.org/")] #![feature(macro_rules, phase)] #![deny(missing_doc, deprecated_owned_vector)] diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index f544e1e0973..3c9358b03a9 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -25,7 +25,7 @@ use html::escape::Escape; use t = syntax::parse::token; /// Highlights some source code, returning the HTML output. -pub fn highlight(src: &str, class: Option<&str>) -> String { +pub fn highlight(src: &str, class: Option<&str>, id: Option<&str>) -> String { debug!("highlighting: ================\n{}\n==============", src); let sess = parse::new_parse_sess(); let fm = parse::string_to_filemap(&sess, @@ -36,6 +36,7 @@ pub fn highlight(src: &str, class: Option<&str>) -> String { doit(&sess, lexer::StringReader::new(&sess.span_diagnostic, fm), class, + id, &mut out).unwrap(); str::from_utf8_lossy(out.unwrap().as_slice()).to_string() } @@ -47,11 +48,17 @@ pub fn highlight(src: &str, class: Option<&str>) -> String { /// it's used. All source code emission is done as slices from the source map, /// not from the tokens themselves, in order to stay true to the original /// source. -fn doit(sess: &parse::ParseSess, mut lexer: lexer::StringReader, class: Option<&str>, +fn doit(sess: &parse::ParseSess, mut lexer: lexer::StringReader, + class: Option<&str>, id: Option<&str>, out: &mut Writer) -> io::IoResult<()> { use syntax::parse::lexer::Reader; - try!(write!(out, "\n", class.unwrap_or(""))); + try!(write!(out, "try!(write!(out, "id='{}' ", id)), + None => {} + } + try!(write!(out, "class='rust {}'>\n", class.unwrap_or(""))); let mut last = BytePos(0); let mut is_attribute = false; let mut is_macro = false; diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index 80653878247..e2fa57148c2 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -16,6 +16,7 @@ pub struct Layout { pub logo: String, pub favicon: String, pub krate: String, + pub playground_url: String, } pub struct Page<'a> { @@ -108,11 +109,13 @@ r##" + {play_js}