Skip to content

Commit eb0c652

Browse files
aturonalexcrichton
authored andcommitted
---
yaml --- r: 153737 b: refs/heads/try2 c: 31ac8a9 h: refs/heads/master i: 153735: 7c70170 v: v3
1 parent a841288 commit eb0c652

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 62bddfa0a5bf7753f835aa9c299232eb75c7bdaa
8+
refs/heads/try2: 31ac8a90f1fbe66c3ad34ef0e5f48bc5f7026059
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustdoc/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ pub fn opts() -> Vec<getopts::OptGroup> {
131131
Markdown file or generated documentation",
132132
"FILES"),
133133
optopt("", "markdown-playground-url",
134-
"URL to send code snippets to", "URL")
134+
"URL to send code snippets to", "URL"),
135+
optflag("", "markdown-no-toc", "don't include table of contents")
135136
)
136137
}
137138

@@ -220,7 +221,8 @@ pub fn main_args(args: &[String]) -> int {
220221
return test::run(input, cfgs, libs, externs, test_args)
221222
}
222223
(false, true) => return markdown::render(input, output.unwrap_or(Path::new("doc")),
223-
&matches, &external_html),
224+
&matches, &external_html,
225+
!matches.opt_present("markdown-no-toc")),
224226
(false, false) => {}
225227
}
226228

branches/try2/src/librustdoc/markdown.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use externalfiles::ExternalHtml;
2020

2121
use html::escape::Escape;
2222
use html::markdown;
23-
use html::markdown::{MarkdownWithToc, find_testable_code, reset_headers};
23+
use html::markdown::{Markdown, MarkdownWithToc, find_testable_code, reset_headers};
2424
use test::Collector;
2525

2626
/// Separate any lines at the start of the file that begin with `%`.
@@ -42,7 +42,7 @@ fn extract_leading_metadata<'a>(s: &'a str) -> (Vec<&'a str>, &'a str) {
4242
/// Render `input` (e.g. "foo.md") into an HTML file in `output`
4343
/// (e.g. output = "bar" => "bar/foo.html").
4444
pub fn render(input: &str, mut output: Path, matches: &getopts::Matches,
45-
external_html: &ExternalHtml) -> int {
45+
external_html: &ExternalHtml, include_toc: bool) -> int {
4646
let input_p = Path::new(input);
4747
output.push(input_p.filestem().unwrap());
4848
output.set_extension("html");
@@ -80,6 +80,12 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches,
8080

8181
reset_headers();
8282

83+
let rendered = if include_toc {
84+
format!("{}", MarkdownWithToc(text))
85+
} else {
86+
format!("{}", Markdown(text))
87+
};
88+
8389
let err = write!(
8490
&mut out,
8591
r#"<!DOCTYPE html>
@@ -113,7 +119,7 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches,
113119
css = css,
114120
in_header = external_html.in_header,
115121
before_content = external_html.before_content,
116-
text = MarkdownWithToc(text),
122+
text = rendered,
117123
after_content = external_html.after_content,
118124
playground = playground,
119125
);

0 commit comments

Comments
 (0)