XAMPPRocky / tokei

Count your code, quickly.
Other
10.56k stars 507 forks source link

Rust doc comments being miscounted #713

Open Garmelon opened 3 years ago

Garmelon commented 3 years ago

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.

XAMPPRocky commented 3 years ago

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

toyboot4e commented 2 years ago

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
===============================================================================