MCPcopy Create free account
hub / github.com/Effect-TS/effect / renderMarkdownReport

Function renderMarkdownReport

packages/tools/api-diff/src/Report.ts:96–172  ·  view source on GitHub ↗
(diff: ApiDiff)

Source from the content-addressed store, hash-verified

94] as const
95
96export const renderMarkdownReport = (diff: ApiDiff): string => {
97 const counts = new Map<string, number>()
98 for (const change of diff.changes) {
99 counts.set(change.classification, (counts.get(change.classification) ?? 0) + 1)
100 }
101 const authoritative = diff.changes.filter((change) => change.authoritative)
102 const suggested = diff.changes.filter((change) => !change.authoritative)
103 const moduleCounts = new Map<string, number>()
104 for (const change of diff.changes) {
105 const module = changeModule(change)
106 moduleCounts.set(module, (moduleCounts.get(module) ?? 0) + 1)
107 }
108 const lines: Array<string> = [
109 "# TypeScript API Diff",
110 "",
111 `Base: \`${diff.base.ref}\` (\`${diff.base.sha}\`)`,
112 "",
113 `Head: \`${diff.head.ref}\` (\`${diff.head.sha}\`)`,
114 "",
115 "This report describes structural API changes and review confidence; it is not a semantic-version compatibility claim.",
116 "",
117 "## Summary",
118 "",
119 "| Classification | Count |",
120 "| --- | ---: |",
121 ...[...counts].sort(([left], [right]) => left.localeCompare(right))
122 .map(([classification, count]) => `| ${escapeCell(classification)} | ${count} |`),
123 "",
124 "## Changes by module",
125 "",
126 "| Domain | Module | Count |",
127 "| --- | --- | ---: |",
128 ...[...moduleCounts].sort(([left], [right]) => left.localeCompare(right)).map(([module, count]) => {
129 const unstable = unstableDomain(module)
130 const domain = unstable === undefined
131 ? module.startsWith("@effect/")
132 ? module.split("/").slice(0, 2).join("/")
133 : "stable"
134 : `unstable/${unstable}`
135 return `| ${escapeCell(domain)} | ${escapeCell(module)} | ${count} |`
136 }),
137 ""
138 ]
139 const sections = [
140 [
141 "Stable API changes",
142 authoritative.filter((change) => !isUnstableChange(change))
143 ],
144 [
145 "Unstable API changes",
146 authoritative.filter(isUnstableChange)
147 ]
148 ] as const
149 for (const [section, sectionChanges] of sections) {
150 if (sectionChanges.length === 0) {
151 continue
152 }
153 lines.push(`## ${section}`, "")

Callers 3

Diff.test.tsFile · 0.90
Report.test.tsFile · 0.90
ApiDiffClass · 0.90

Calls 15

changeModuleFunction · 0.85
escapeCellFunction · 0.85
unstableDomainFunction · 0.85
isUnstableChangeFunction · 0.85
renderChangeFunction · 0.85
sliceMethod · 0.80
trimMethod · 0.80
setMethod · 0.65
getMethod · 0.65
pushMethod · 0.65
hasMethod · 0.65
filterMethod · 0.45

Tested by

no test coverage detected