MCPcopy Create free account
hub / github.com/FastLED/FastLED / strip_comments

Function strip_comments

ci/lint_cpp/logging_in_iram_checker.py:31–50  ·  view source on GitHub ↗

Strip C/C++ comments from content while preserving line structure. Args: content: The content to strip comments from Returns: Content with comments removed, preserving line numbers

(content: str)

Source from the content-addressed store, hash-verified

29
30
31def strip_comments(content: str) -> str:
32 """
33 Strip C/C++ comments from content while preserving line structure.
34
35 Args:
36 content: The content to strip comments from
37
38 Returns:
39 Content with comments removed, preserving line numbers
40 """
41 # Remove multi-line comments (/* ... */) while retaining line numbers.
42 content = re.sub(
43 r"/\*.*?\*/",
44 lambda match: "\n" * match.group(0).count("\n"),
45 content,
46 flags=re.DOTALL,
47 )
48 # Remove single-line comments (// ...)
49 content = re.sub(r"//.*$", "", content, flags=re.MULTILINE)
50 return content
51
52
53class LoggingInIramChecker(FileContentChecker):

Callers 1

check_file_contentMethod · 0.70

Calls 1

countMethod · 0.45

Tested by

no test coverage detected