Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docstrings in python is counted as code #253

Closed
Hultner opened this issue Aug 31, 2018 · 3 comments
Closed

Docstrings in python is counted as code #253

Hultner opened this issue Aug 31, 2018 · 3 comments
Labels

Comments

@Hultner
Copy link

Hultner commented Aug 31, 2018

In python doc-comments are defined using the multi-line string literal syntax """ xxx """" at the beginning of a module, function, class or method. Tried out tokei on a few of my projects and it grossly miscalculates SLOC because of this, for reference pygount is very accurate.

@XAMPPRocky
Copy link
Owner

@Hultner Thank you for your issue! I'm closing this as a duplicate of #185. Here is what I've said on this issue previously.

Python docstrings are considered code as syntactically they are strings and it requires parsing the code into a Abstract Syntax Tree in order to correctly to determine whether the given """hello world""" is actually code or comments. This might hopefully be resolved when there is a good solution to #67 and there can then be an option for you as the user to decide whether to treat them as code or comments, until then I'm marking this as wontfix.

@Hultner
Copy link
Author

Hultner commented Aug 31, 2018

Ah I understand. Too bad this makes this tool useless for any significant python project. 😢

@olivren
Copy link

olivren commented Feb 22, 2019

@Hultner There is now a workaround for this issue: the tokei configuration file (.tokeirc or tokei.toml in the current directory) has an option treat_doc_strings_as_comments = true that enables this behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants