Skip to content

Commit f844d3e

Browse files
snomiaoclaude
andcommitted
[feat] Use source file links instead of dist .d.ts in API changelog
Update changelog link generation to prefer source file locations over generated declaration file locations. Links now point to the actual source code where APIs are defined (e.g., src/stores/commandStore.ts) instead of the bundled dist/index.d.ts file. This makes the changelog much more useful as developers can click through to see the real implementation and context. Falls back to .d.ts location if source mapping is unavailable. Fixes the issue where links like: https://github.com/.../dist/index.d.ts#L1247 Are now: https://github.com/.../src/stores/commandStore.ts#L10 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 98ed124 commit f844d3e

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

scripts/compare-api-snapshots.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,21 @@ const currentApi = JSON.parse(fs.readFileSync(currentPath, 'utf-8'))
4040

4141
/**
4242
* Generate GitHub permalink to source code
43+
* Prefers source file location over dist .d.ts location
4344
*/
44-
function generateGitHubLink(name, line) {
45-
if (!line) return name
46-
// Format: https://github.com/Comfy-Org/ComfyUI_frontend/blob/main/dist/index.d.ts#L123
47-
return `[\`${name}\`](https://github.com/${repoOwner}/${repoName}/blob/${gitRef}/dist/index.d.ts#L${line})`
45+
function generateGitHubLink(name, item) {
46+
// If we have source file information, use that
47+
if (item?.sourceFile && item?.sourceLine) {
48+
return `[\`${name}\`](https://github.com/${repoOwner}/${repoName}/blob/${gitRef}/${item.sourceFile}#L${item.sourceLine})`
49+
}
50+
51+
// Fallback to .d.ts location if available
52+
if (item?.line) {
53+
return `[\`${name}\`](https://github.com/${repoOwner}/${repoName}/blob/${gitRef}/dist/index.d.ts#L${item.line})`
54+
}
55+
56+
// No location info available
57+
return `\`${name}\``
4858
}
4959

5060
/**
@@ -280,9 +290,7 @@ function formatChangelog(changes, prevVersion, currVersion) {
280290
lines.push(`**${categoryToTitle(category)}**`)
281291
lines.push('')
282292
for (const item of items) {
283-
const displayName = item.item?.line
284-
? generateGitHubLink(item.name, item.item.line)
285-
: `\`${item.name}\``
293+
const displayName = generateGitHubLink(item.name, item.item)
286294
lines.push(`- **Removed**: ${displayName}`)
287295
}
288296
lines.push('')
@@ -334,12 +342,10 @@ function formatChangelog(changes, prevVersion, currVersion) {
334342
lines.push(`**${categoryToTitle(category)}**`)
335343
lines.push('')
336344
for (const item of items) {
337-
// Get the current item to access line number
345+
// Get the current item to access source location
338346
const currItem =
339347
currentApi[item.category] && currentApi[item.category][item.name]
340-
const displayName = currItem?.line
341-
? generateGitHubLink(item.name, currItem.line)
342-
: `\`${item.name}\``
348+
const displayName = generateGitHubLink(item.name, currItem)
343349
lines.push(`- ${displayName}`)
344350
for (const change of item.changes) {
345351
const formatted = formatChange(change)

0 commit comments

Comments
 (0)