← every case · 2000 · string forms

2090-docstring_holding_a_comment_symbol

the # inside the docstring is text and not a comment symbol, and the docstring around it is a triple quoted string like any other, opening a line on its own. Case 2100 is the same shape where the block is data the program prints, and the two together separate a counter that decides by where the block sits from one that decides by what it is

read ascloc.defaultcloc.docstring-as-codemezura.contentmezura.regionscc.defaulttokei.default
input.py
1codedef f():
2comments """
3comments # this is not a comment, it is inside the docstring
4comments """
5code return 1

stringcommentthe tag around another language

What each tool answered

cloc.default ✓ agrees
the rules ask5 lines · 0 blanks · 2 code · 3 comments
it answers5 lines · 0 blanks · 2 code · 3 comments

cloc --json cases/2000-string_forms/2090-docstring_holding_a_comment_symbol/input.py

cloc.default ✓ agrees

--strip-str-comments

the rules ask5 lines · 0 blanks · 2 code · 3 comments
it answers5 lines · 0 blanks · 2 code · 3 comments

cloc --json cases/2000-string_forms/2090-docstring_holding_a_comment_symbol/input.py --strip-str-comments

cloc.docstring-as-code ✗ fails

the flag makes cloc skip the stage that turns a docstring into a comment, so nothing tells the filters below that those lines are inside anything, and the one whose first mark is a # is dropped as a comment line

the rules ask5 lines · 0 blanks · 5 code · 0 comments
it answers5 lines · 0 blanks · 4 code · 1 comments

cloc --json cases/2000-string_forms/2090-docstring_holding_a_comment_symbol/input.py --docstring-as-code

mezura.content ✓ agrees
the rules ask5 lines · 5 code · 0 comments · 0 extra
it answers5 lines · 5 code · 0 comments · 0 extra

mezura cases/2000-string_forms/2090-docstring_holding_a_comment_symbol/input.py --output json --hide timing --no-default-config --no-local --counting content

mezura.region ✓ agrees
the rules ask5 lines · 0 blanks · 5 code · 0 comments
it answers5 lines · 0 blanks · 5 code · 0 comments

mezura cases/2000-string_forms/2090-docstring_holding_a_comment_symbol/input.py --output json --hide timing --no-default-config --no-local --counting region

scc.default ✓ agrees

any triple quoted block that opens a line is read as documentation, so the three lines of this one are comments by the definition it declares and not by a mistake

the rules ask5 lines · 0 blanks · 2 code · 3 comments
it answers5 lines · 0 blanks · 2 code · 3 comments

scc --format json cases/2000-string_forms/2090-docstring_holding_a_comment_symbol/input.py

tokei.default ✓ agrees
the rules ask5 lines · 0 blanks · 5 code · 0 comments
it answers5 lines · 0 blanks · 5 code · 0 comments

tokei --output json cases/2000-string_forms/2090-docstring_holding_a_comment_symbol/input.py