GuillaumeGomez / rustdoc-stripper

rustdoc-stripper is a tool used to edit/remove rustdoc comments from your code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incomplete ignore_if_doc_commented implementation

gkoz opened this issue · comments

Looks like #39 was not enough. This patch makes the test fail:

diff --git a/tests/tests.rs b/tests/tests.rs
index 2aecca5..94b4de8 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -378,12 +378,22 @@ another
 const BASIC6 : &'static str = r#"/// not stripped comment
 struct Foo;

+impl Foo {
+    /// another existing comment
+    fn new() -> Foo { }
+}
+
 struct Bar;
 "#;

 const BASIC6_REGEN : &'static str = r#"/// not stripped comment
 struct Foo;

+impl Foo {
+    /// another existing comment
+    fn new() -> Foo { }
+}
+
 /// struct Bar comment
 struct Bar;
 "#;
@@ -392,6 +402,8 @@ fn get_basic6_md(file: &str) -> String {
     format!(r#"<!-- file {} -->
 <!-- struct Foo -->
 struct Foo comment
+<!-- impl Foo::fn new -->
+fn new comment
 <!-- struct Bar -->
 struct Bar comment
 "#, file)

It should fail as far as I can see. Your comment is "another existing comment", however you say it's "fn new comment" in the comment file. Did I miss something?

I might've gotten the test case wrong but the idea is the same as with the "not stripped comment", which prevents "struct Foo comment" from being inserted, I expect fn new to retain its "another existing comment".

Can you write a small code sample case with this issue please?

This isn't small enough? If I paste the inputs to the test into files and run rustdoc-stripper -g -x it inserts

    /// fn new comment

after

    /// another existing comment