MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / summarize_asciidoc

Function summarize_asciidoc

scripts/developer-guide/summarize_reports.py:89–127  ·  view source on GitHub ↗
(report: Path, status: str, summary_key: str, output: Path | None)

Source from the content-addressed store, hash-verified

87
88
89def summarize_asciidoc(report: Path, status: str, summary_key: str, output: Path | None) -> None:
90 text = ""
91 if report.is_file():
92 text = report.read_text(encoding="utf-8", errors="ignore")
93
94 pattern = re.compile(
95 r"^\s*(?:[^:\n]+:\d+:\d+:\s+|asciidoctor:\s+)(ERROR|WARN(?:ING)?|INFO)\b",
96 re.MULTILINE,
97 )
98 matches = pattern.findall(text)
99
100 counts = {"error": 0, "warning": 0, "info": 0}
101 for severity in matches:
102 normalized = severity.upper()
103 if normalized == "ERROR":
104 counts["error"] += 1
105 elif normalized in {"WARN", "WARNING"}:
106 counts["warning"] += 1
107 elif normalized == "INFO":
108 counts["info"] += 1
109
110 total = sum(counts.values())
111
112 if total:
113 parts = [f"{counts['error']} errors"] if counts["error"] else []
114 if counts["warning"]:
115 parts.append(f"{counts['warning']} warnings")
116 if counts["info"]:
117 parts.append(f"{counts['info']} info")
118 detail = f" ({', '.join(parts)})" if parts else ""
119 summary = f"{total} issue(s) flagged{detail}"
120 if _has_nonzero_status(status):
121 summary += f" (exit code {_normalize_status(status)})"
122 elif _has_nonzero_status(status):
123 summary = f"Linter failed (exit code {_normalize_status(status)})"
124 else:
125 summary = "No issues found"
126
127 write_outputs([(summary_key, summary)], output)
128
129
130def summarize_vale(

Callers 1

mainFunction · 0.85

Calls 7

_has_nonzero_statusFunction · 0.85
_normalize_statusFunction · 0.85
write_outputsFunction · 0.85
compileMethod · 0.65
valuesMethod · 0.65
appendMethod · 0.65
joinMethod · 0.65

Tested by

no test coverage detected