about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMarcus Klaas de Vries <mail@marcusklaas.nl>2015-10-20 20:14:27 +0200
committerMarcus Klaas de Vries <mail@marcusklaas.nl>2015-10-20 20:14:27 +0200
commit8e2547b6bcdbac2cadfafe0d8f2795bf9fa1c4da (patch)
tree955a3cf16a43092a39a5cb0147a942c4fe97d645 /src
parent526ccff690bee0adf7f93ece0d2bba16db42413d (diff)
parent6b4ef7457a54103817e8afb3dba3828b60b1e286 (diff)
Merge pull request #505 from tikue/master
Fix doc comment regression and add tests.
Diffstat (limited to 'src')
-rw-r--r--src/comment.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/comment.rs b/src/comment.rs
index e4ce5a7ed35..045d1cb5047 100644
--- a/src/comment.rs
+++ b/src/comment.rs
@@ -27,6 +27,10 @@ pub fn rewrite_comment(orig: &str,
     // Edge case: block comments. Let's not trim their lines (for now).
     let (opener, closer, line_start) = if block_style {
         ("/* ", " */", " * ")
+    } else if orig.starts_with("///") {
+        ("/// ", "", "/// ")
+    } else if orig.starts_with("//!") {
+        ("//! ", "", "//! ")
     } else {
         ("// ", "", "// ")
     };
@@ -81,7 +85,7 @@ pub fn rewrite_comment(orig: &str,
             let rewrite = try_opt!(rewrite_string(line, &fmt));
             result.push_str(&rewrite);
         } else {
-            if line.len() == 0 || line.starts_with('!') {
+            if line.len() == 0 {
                 // Remove space if this is an empty comment or a doc comment.
                 result.pop();
             }
@@ -97,7 +101,10 @@ pub fn rewrite_comment(orig: &str,
 }
 
 fn left_trim_comment_line(line: &str) -> &str {
-    if line.starts_with("/* ") || line.starts_with("// ") {
+    if line.starts_with("//! ") || line.starts_with("/// ") {
+        &line[4..]
+    } else if line.starts_with("/* ") || line.starts_with("// ") || line.starts_with("//!") ||
+       line.starts_with("///") {
         &line[3..]
     } else if line.starts_with("/*") || line.starts_with("* ") || line.starts_with("//") {
         &line[2..]