about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2017-05-08 14:25:01 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2017-05-08 14:25:01 +0200
commit95a94e3d3d43e0df87e2d80e6f2a2e0e5c355dca (patch)
treec1bf4afc7337ff728970341f5bcf7e625393eaea /src
parent70198a0a44633c7c9d14fce2159c1f750491287b (diff)
downloadrust-95a94e3d3d43e0df87e2d80e6f2a2e0e5c355dca.tar.gz
rust-95a94e3d3d43e0df87e2d80e6f2a2e0e5c355dca.zip
Add markdown-[before|after]-content options
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/externalfiles.rs12
-rw-r--r--src/librustdoc/lib.rs13
2 files changed, 23 insertions, 2 deletions
diff --git a/src/librustdoc/externalfiles.rs b/src/librustdoc/externalfiles.rs
index d78f00497ca..111ae4ede27 100644
--- a/src/librustdoc/externalfiles.rs
+++ b/src/librustdoc/externalfiles.rs
@@ -13,6 +13,7 @@ use std::io::prelude::*;
 use std::io;
 use std::path::Path;
 use std::str;
+use html::markdown::{Markdown, RenderType};
 
 #[derive(Clone)]
 pub struct ExternalHtml{
@@ -28,7 +29,8 @@ pub struct ExternalHtml{
 }
 
 impl ExternalHtml {
-    pub fn load(in_header: &[String], before_content: &[String], after_content: &[String])
+    pub fn load(in_header: &[String], before_content: &[String], after_content: &[String],
+                md_before_content: &[String], md_after_content: &[String], render: RenderType)
             -> Option<ExternalHtml> {
         load_external_files(in_header)
             .and_then(|ih|
@@ -36,9 +38,17 @@ impl ExternalHtml {
                     .map(|bc| (ih, bc))
             )
             .and_then(|(ih, bc)|
+                load_external_files(md_before_content)
+                    .map(|m_bc| (ih, format!("{}{}", bc, Markdown(&m_bc, render))))
+            )
+            .and_then(|(ih, bc)|
                 load_external_files(after_content)
                     .map(|ac| (ih, bc, ac))
             )
+            .and_then(|(ih, bc, ac)|
+                load_external_files(md_after_content)
+                    .map(|m_ac| (ih, bc, format!("{}{}", ac, Markdown(&m_ac, render))))
+            )
             .map(|(ih, bc, ac)|
                 ExternalHtml {
                     in_header: ih,
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 1156fadf8c0..45c9c712730 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -159,6 +159,14 @@ pub fn opts() -> Vec<RustcOptGroup> {
                         "files to include inline between the content and </body> of a rendered \
                          Markdown file or generated documentation",
                         "FILES")),
+        unstable(optmulti("", "markdown-before-content",
+                          "files to include inline between <body> and the content of a rendered \
+                           Markdown file or generated documentation",
+                          "FILES")),
+        unstable(optmulti("", "markdown-after-content",
+                          "files to include inline between the content and </body> of a rendered \
+                           Markdown file or generated documentation",
+                          "FILES")),
         stable(optopt("", "markdown-playground-url",
                       "URL to send code snippets to", "URL")),
         stable(optflag("", "markdown-no-toc", "don't include table of contents")),
@@ -274,7 +282,10 @@ pub fn main_args(args: &[String]) -> isize {
     let external_html = match ExternalHtml::load(
             &matches.opt_strs("html-in-header"),
             &matches.opt_strs("html-before-content"),
-            &matches.opt_strs("html-after-content")) {
+            &matches.opt_strs("html-after-content"),
+            &matches.opt_strs("markdown-before-content"),
+            &matches.opt_strs("markdown-after-content"),
+            render_type) {
         Some(eh) => eh,
         None => return 3,
     };