diff options
| author | bors <bors@rust-lang.org> | 2014-06-30 07:31:29 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-06-30 07:31:29 +0000 |
| commit | 2735c7bb104d0938bccd261c5ea0d083f05ceba5 (patch) | |
| tree | b17bfa5031a983fc6fcb2cd4f6548d728773261e /src/librustdoc/html | |
| parent | e1683f50c00297e9908ae028fa1d41b9a52a6f6f (diff) | |
| parent | 63afc082629044755df0c416ecf4c20ef0375254 (diff) | |
| download | rust-2735c7bb104d0938bccd261c5ea0d083f05ceba5.tar.gz rust-2735c7bb104d0938bccd261c5ea0d083f05ceba5.zip | |
auto merge of #15237 : zzmp/rust/feat/markdown-in-crate-documentation, r=huonw
This makes the `in-header`, `markdown-before-content`, and `markdown-after-content` options available to `rustdoc` when generating documentation for any crate. Before, these options were only available when creating documentation *from* markdown. Now, they are available when generating documentation from source. This also updates the `rustdoc -h` output to reflect these changes. It does not update the `man rustdoc` page, nor does it update the documentation in [the `rustdoc` manual](http://doc.rust-lang.org/rustdoc.html).
Diffstat (limited to 'src/librustdoc/html')
| -rw-r--r-- | src/librustdoc/html/layout.rs | 11 | ||||
| -rw-r--r-- | src/librustdoc/html/render.rs | 8 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index 61a2d3c5d9c..aa298d07780 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -11,10 +11,13 @@ use std::fmt; use std::io; +use externalfiles::ExternalHtml; + #[deriving(Clone)] pub struct Layout { pub logo: String, pub favicon: String, + pub external_html: ExternalHtml, pub krate: String, pub playground_url: String, } @@ -44,6 +47,7 @@ r##"<!DOCTYPE html> <link rel="stylesheet" type="text/css" href="{root_path}main.css"> {favicon} + {in_header} </head> <body> <!--[if lte IE 8]> @@ -53,6 +57,8 @@ r##"<!DOCTYPE html> </div> <![endif]--> + {before_content} + <section class="sidebar"> {logo} {sidebar} @@ -105,6 +111,8 @@ r##"<!DOCTYPE html> </div> </div> + {after_content} + <script> window.rootPath = "{root_path}"; window.currentCrate = "{krate}"; @@ -133,6 +141,9 @@ r##"<!DOCTYPE html> } else { format!(r#"<link rel="shortcut icon" href="{}">"#, layout.favicon) }, + in_header = layout.external_html.in_header, + before_content = layout.external_html.before_content, + after_content = layout.external_html.after_content, sidebar = *sidebar, krate = layout.krate, play_url = layout.playground_url, diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index aacb13156b7..f5d379c4baf 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -41,6 +41,8 @@ use std::str; use std::string::String; use std::sync::Arc; +use externalfiles::ExternalHtml; + use serialize::json::ToJson; use syntax::ast; use syntax::ast_util; @@ -78,7 +80,7 @@ pub struct Context { /// This changes as the context descends into the module hierarchy. pub dst: Path, /// This describes the layout of each page, and is not modified after - /// creation of the context (contains info like the favicon) + /// creation of the context (contains info like the favicon and added html). pub layout: layout::Layout, /// This map is a list of what should be displayed on the sidebar of the /// current page. The key is the section header (traits, modules, @@ -220,7 +222,7 @@ local_data_key!(pub cache_key: Arc<Cache>) local_data_key!(pub current_location_key: Vec<String> ) /// Generates the documentation for `crate` into the directory `dst` -pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> { +pub fn run(mut krate: clean::Crate, external_html: &ExternalHtml, dst: Path) -> io::IoResult<()> { let mut cx = Context { dst: dst, current: Vec::new(), @@ -229,12 +231,14 @@ pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> { layout: layout::Layout { logo: "".to_string(), favicon: "".to_string(), + external_html: external_html.clone(), krate: krate.name.clone(), playground_url: "".to_string(), }, include_sources: true, render_redirect_pages: false, }; + try!(mkdir(&cx.dst)); // Crawl the crate attributes looking for attributes which control how we're |
