tokei icon indicating copy to clipboard operation
tokei copied to clipboard

Rust doc comments being miscounted

Open Garmelon opened this issue 4 years ago • 2 comments

This rust code is being counted weirdly:

/* A */

/// B
struct C;

It results in the output

===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 Rust                    1            1            1            0            0
 |- Markdown             1            1            0            1            0
 (Total)                              2            1            1            0
===============================================================================
 Total                   1            1            1            0            0
===============================================================================
  1. The file is 4 lines long (wc -l agrees), yet the total reported by tokei is 1.
  2. The total does not include any comments or blanks.
  3. The total disagrees with the total for the rust section.

If I add more empty lines between /* A */ and /// B, they are simply ignored. If I change /// B to // B, the output is correct.

Similar things happen with this simplified two-liner example:

/// A
struct B;

Tokei output:

===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 Rust                    1            1            1            0            0
 |- Markdown             1            1            0            1            0
 (Total)                              2            1            1            0
===============================================================================
 Total                   1            1            1            0            0
===============================================================================

Tested on commit fd08c8b889f96986d3a05a17c58998ca062e9176 (the current master) with a freshly cloned tokei.

Garmelon avatar Feb 09 '21 20:02 Garmelon

Thank you for your issue! I'll have to investigate further, but you can see what's happening in tokei with tokei -vvv.

XAMPPRocky avatar Feb 10 '21 07:02 XAMPPRocky

Block docstrings are not counted as markdown.

Source file:

/*!
Module docstring
*/

/**
Item docstring
*/
struct CoolStuff;

tokei output:

===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 Rust                    1            8            1            6            1
===============================================================================
 Total                   1            8            1            6            1
===============================================================================

toyboot4e avatar Aug 13 '21 12:08 toyboot4e