Git Product home page Git Product logo

Comments (3)

XAMPPRocky avatar XAMPPRocky commented on July 23, 2024

Thank you for your issue! However tokei is correct here. All doc comments in Rust are markdown and this code is invalid Rust because it needs to be attached to an item.

from tokei.

LeoQ7 avatar LeoQ7 commented on July 23, 2024

Thank you for the clarification!

For the following code snippet, is the result from tokei also correct?

const demo: &str = "Hello, World!";

/// markdown? docstring?
const demo1: &str = "Hello, World!";

Output:

[2024-03-07T04:45:50Z TRACE tokei::language::language_type] const demo: &str = "Hello, World!";
[2024-03-07T04:45:50Z TRACE tokei::language::syntax] Start "\""
[2024-03-07T04:45:50Z TRACE tokei::language::syntax] End "\""
[2024-03-07T04:45:50Z TRACE tokei::language::syntax]

[2024-03-07T04:45:50Z TRACE tokei::language::syntax]

[2024-03-07T04:45:50Z TRACE tokei::language::syntax] /// markdown? docstring?

[2024-03-07T04:45:50Z TRACE tokei::language::syntax] Markdown found: " markdown? docstring?\n"
[2024-03-07T04:45:50Z TRACE tokei::language::language_type] markdown? docstring?
[2024-03-07T04:45:50Z TRACE tokei::language::syntax] ^ Skippable
[2024-03-07T04:45:50Z TRACE tokei::language::syntax] Comment No.1
[2024-03-07T04:45:50Z TRACE tokei::language::language_type] const demo1: &str = "Hello, World!";
[2024-03-07T04:45:50Z TRACE tokei::language::syntax] Start "\""
[2024-03-07T04:45:50Z TRACE tokei::language::syntax] End "\""
[2024-03-07T04:45:50Z TRACE tokei::language::language_type] const demo1: &str = "Hello, World!";
[2024-03-07T04:45:50Z TRACE tokei::language::language_type] Code No.1
===============================================================================
 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
===============================================================================

IMHO, LoC should be 2 here?

A correct example is:

const demo: u8 = 42;

/// markdown? docstring?
const demo1: &str = "Hello, World!";

Output:

[2024-03-07T06:18:40Z TRACE tokei::language::language_type] Using Simple Parse on "const demo: u8 = 42;\n\n"
[2024-03-07T06:18:40Z TRACE tokei::language::language_type] /// markdown? docstring?
[2024-03-07T06:18:40Z TRACE tokei::language::syntax] /// markdown? docstring?

[2024-03-07T06:18:40Z TRACE tokei::language::syntax] Markdown found: " markdown? docstring?\n"
[2024-03-07T06:18:40Z TRACE tokei::language::language_type] markdown? docstring?
[2024-03-07T06:18:40Z TRACE tokei::language::syntax] ^ Skippable
[2024-03-07T06:18:40Z TRACE tokei::language::syntax] Comment No.1
[2024-03-07T06:18:40Z TRACE tokei::language::language_type] const demo1: &str = "Hello, World!";
[2024-03-07T06:18:40Z TRACE tokei::language::syntax] Start "\""
[2024-03-07T06:18:40Z TRACE tokei::language::syntax] End "\""
[2024-03-07T06:18:40Z TRACE tokei::language::language_type] const demo1: &str = "Hello, World!";
[2024-03-07T06:18:40Z TRACE tokei::language::language_type] Code No.1
===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 Rust                    1            3            2            0            1
 |- Markdown             1            1            0            1            0
 (Total)                              4            2            1            1
===============================================================================
 Total                   1            3            2            0            1
===============================================================================

from tokei.

LeoQ7 avatar LeoQ7 commented on July 23, 2024

A similar issue is #713 , my guess is that the early return at https://github.com/XAMPPRocky/tokei/blob/master/src/language/syntax.rs#L250-L252 somehow affected the counting of previous lines when there is a quote.

from tokei.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.