@@ -89,6 +89,7 @@ fn parse_priority(word: &str) -> Option<isize> {
89
89
}
90
90
}
91
91
92
+ /// Remove closing tags, comments, and whitespace
92
93
fn clean_line < ' a > ( line : & ' a str , delimiter_word : & str ) -> & ' a str {
93
94
return line. split_once ( delimiter_word) . unwrap ( ) . 1
94
95
. trim ( )
@@ -154,6 +155,19 @@ pub fn scan_string(str: String, filename: PathBuf, entries: &mut Vec<Entry>) {
154
155
155
156
let text = clean_line ( line, word) ;
156
157
158
+ if word. starts_with ( "todo!(" ) {
159
+ entries. push ( Entry {
160
+ text : line. trim ( ) . to_string ( ) ,
161
+ location : Location {
162
+ file : filename. clone ( ) ,
163
+ line : line_num + 1 ,
164
+ } ,
165
+ data : EntryData :: Generic ,
166
+ } ) ;
167
+
168
+ break ;
169
+ }
170
+
157
171
// Handles: `todo`, `TODO`, `todo:`, `TODO:`
158
172
// Also trims `"` and `'` to handle cases like `foo="bar todo"`
159
173
if word. to_lowercase ( ) . trim_end_matches ( ':' ) . trim_end_matches ( '"' ) . trim_end_matches ( '\'' ) == "todo" {
@@ -773,6 +787,55 @@ mod tests {
773
787
} , entries[ 9 ] ) ;
774
788
}
775
789
790
+ #[ test]
791
+ fn sample_test_rs ( ) {
792
+ let mut entries: Vec < Entry > = vec ! [ ] ;
793
+
794
+ let mut path = std:: env:: current_dir ( ) . unwrap ( ) ;
795
+ path. push ( "samples" ) ;
796
+ path. push ( "2.rs" ) ;
797
+
798
+ scan_file ( path. as_path ( ) , & mut entries) . unwrap ( ) ;
799
+
800
+ assert_eq ! ( 4 , entries. len( ) ) ;
801
+
802
+ assert_eq ! ( Entry {
803
+ data: EntryData :: Generic ,
804
+ text: String :: from( "todo!(\" generic\" );" ) ,
805
+ location: Location {
806
+ file: path. clone( ) ,
807
+ line: 3 ,
808
+ }
809
+ } , entries[ 0 ] ) ;
810
+
811
+ assert_eq ! ( Entry {
812
+ data: EntryData :: Generic ,
813
+ text: String :: from( "todo!();" ) ,
814
+ location: Location {
815
+ file: path. clone( ) ,
816
+ line: 4 ,
817
+ }
818
+ } , entries[ 1 ] ) ;
819
+
820
+ assert_eq ! ( Entry {
821
+ data: EntryData :: Generic ,
822
+ text: String :: from( "todo!(\" @foo not category\" );" ) ,
823
+ location: Location {
824
+ file: path. clone( ) ,
825
+ line: 5 ,
826
+ }
827
+ } , entries[ 2 ] ) ;
828
+
829
+ assert_eq ! ( Entry {
830
+ data: EntryData :: Generic ,
831
+ text: String :: from( "todo!(\" 00 not priority\" );" ) ,
832
+ location: Location {
833
+ file: path. clone( ) ,
834
+ line: 6 ,
835
+ }
836
+ } , entries[ 3 ] ) ;
837
+ }
838
+
776
839
#[ test]
777
840
fn todo_file_test ( ) {
778
841
let mut entries: Vec < Entry > = vec ! [ ] ;
0 commit comments