@@ -202,32 +202,30 @@ impl InfoField for LanguagesInfo {
202202 }
203203}
204204
205- /// Counts the lines-of-code of a tokei `Language`. Takes into
206- /// account that a prose language's comments *are* its code.
207205pub fn loc ( language_type : & tokei:: LanguageType , language : & tokei:: Language ) -> usize {
208- __loc ( language_type, language)
206+ __loc ( language_type, language. code , language . comments )
209207 + language
210208 . children
211209 . iter ( )
212210 . fold ( 0 , |sum, ( lang_type, reports) | {
213- sum + reports
214- . iter ( )
215- . fold ( 0 , |sum, report| sum + stats_loc ( lang_type, & report. stats ) )
211+ sum + reports. iter ( ) . fold ( 0 , |sum, report| {
212+ let stats = report. stats . summarise ( ) ;
213+ sum + __loc ( lang_type, stats. code , stats. comments )
214+ } )
216215 } )
217216}
218217
219- /// Counts the lines-of- code of a tokei `Report`. This is the child of a
220- /// `tokei::CodeStats`.
221- pub fn stats_loc ( language_type : & tokei:: LanguageType , stats : & tokei :: CodeStats ) -> usize {
222- let stats = stats . summarise ( ) ;
223- __stats_loc ( language_type , & stats )
218+ fn __loc ( language_type : & tokei :: LanguageType , code : usize , comments : usize ) -> usize {
219+ match language_type {
220+ tokei:: LanguageType :: Markdown => code + comments ,
221+ _ => code ,
222+ }
224223}
225224
226225#[ cfg( test) ]
227226mod test {
228- use rstest:: rstest;
229-
230227 use super :: * ;
228+ use rstest:: rstest;
231229
232230 #[ test]
233231 fn test_display_languages_info ( ) {
0 commit comments