]> git.lizzy.rs Git - rust.git/commitdiff
Clearly separate code blocks from other blocks
authormitaa <mitaa.ceb@gmail.com>
Fri, 26 Feb 2016 16:19:35 +0000 (17:19 +0100)
committermitaa <mitaa.ceb@gmail.com>
Sat, 27 Feb 2016 05:42:21 +0000 (06:42 +0100)
For summary descriptions we need the first paragraph (adjacent lines
until a blank line) - but the rendered markdown of a code block did not
leave a blank line in the html and was thus included in the summary line.

src/librustdoc/html/markdown.rs
src/test/rustdoc/issue-31899.rs [new file with mode: 0644]

index 8633d2a1c2e63ac87ca64fb2d5db3d0f11414191..9fd476bfbab552b2f006b5e887c9e046aff3c6cb 100644 (file)
@@ -250,7 +250,9 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
             let text = lines.collect::<Vec<&str>>().join("\n");
             if rendered { return }
             PLAYGROUND_KRATE.with(|krate| {
-                let mut s = String::new();
+                // insert newline to clearly separate it from the
+                // previous block so we can shorten the html output
+                let mut s = String::from("\n");
                 krate.borrow().as_ref().map(|krate| {
                     let test = origtext.lines().map(|l| {
                         stripped_filtered_line(l).unwrap_or(l)
diff --git a/src/test/rustdoc/issue-31899.rs b/src/test/rustdoc/issue-31899.rs
new file mode 100644 (file)
index 0000000..0722dc4
--- /dev/null
@@ -0,0 +1,70 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+
+// @has issue_31899/index.html
+// @has - 'Make this line a bit longer.'
+// @!has - 'rust rust-example-rendered'
+// @!has - 'use ndarray::arr2'
+// @!has - 'prohibited'
+
+/// A tuple or fixed size array that can be used to index an array.
+/// Make this line a bit longer.
+///
+/// ```
+/// use ndarray::arr2;
+///
+/// let mut a = arr2(&[[0, 1], [0, 0]]);
+/// a[[1, 1]] = 1;
+/// assert_eq!(a[[0, 1]], 1);
+/// assert_eq!(a[[1, 1]], 1);
+/// ```
+///
+/// **Note** the blanket implementation that's not visible in rustdoc:
+/// `impl<D> NdIndex for D where D: Dimension { ... }`
+pub fn bar() {}
+
+/// Some line
+///
+/// # prohibited
+pub fn foo() {}
+
+/// Some line
+///
+/// 1. prohibited
+/// 2. bar
+pub fn baz() {}
+
+/// Some line
+///
+/// - prohibited
+/// - bar
+pub fn qux() {}
+
+/// Some line
+///
+/// * prohibited
+/// * bar
+pub fn quz() {}
+
+/// Some line
+///
+/// > prohibited
+/// > bar
+pub fn qur() {}
+
+/// Some line
+///
+/// prohibited
+/// =====
+///
+/// Second
+/// ------
+pub fn qut() {}