fix(platform-api-docs): prefer source over build output when deduplicating - #10085
Conversation
8236f2a to
0b32e92
Compare
|
@mcmire In case you have missed to look at this ? |
|
@cryptodev-2s Ah sorry I did miss this, I haven't reviewed this yet. I will review this shortly. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0b32e92. Configure here.
mcmire
left a comment
There was a problem hiding this comment.
Two more suggestions. Everything else looks good.
| // Scanning `.` makes the project root a scan directory, so its | ||
| // `node_modules` exclusion covers the published declaration files too. | ||
| // Each location has to be collected in its own call for them to survive, | ||
| // since exclusions apply to every pattern in the call they belong to. |
There was a problem hiding this comment.
Is this comment in the right place? Maybe it needs to be moved to above the generate call? On the other hand, to me, not knowing this fact doesn't seem to impact readability of this test, so I would also be fine with removing this:
| // Scanning `.` makes the project root a scan directory, so its | |
| // `node_modules` exclusion covers the published declaration files too. | |
| // Each location has to be collected in its own call for them to survive, | |
| // since exclusions apply to every pattern in the call they belong to. |
| // One call per location, not one call carrying every pattern. Exclusions | ||
| // apply to a whole call, so combining them lets the source-tree | ||
| // `node_modules` and `dist` exclusions match the published declaration files | ||
| // and drop them. |
There was a problem hiding this comment.
I think this could be written in a clearer way:
| // One call per location, not one call carrying every pattern. Exclusions | |
| // apply to a whole call, so combining them lets the source-tree | |
| // `node_modules` and `dist` exclusions match the published declaration files | |
| // and drop them. | |
| // NOTE: We are calling `addSourceFiles` for each kind of source instead of | |
| // calling it at the very end so that at each step we can make sure to exclude | |
| // `node_modules` and `dist`. | |

Explanation
A capability declared in a package's source is also visible in the
distbuilt from it, and a cross-package import resolves to thatdistrather than to the sibling's source. Whichever was reached first won, so 83 of 1164 source links pointed at.d.ctsbuild output instead of code you can read and edit.Deduplication now scores source above build output, so the outcome no longer depends on traversal order. All 1164 links point at source, and namespace, action and event counts are unchanged.
Both clients generate byte-identical docs, since they only ever see published packages and score every candidate the same way.
References
Checklist
Note
Low Risk
Documentation generation and link selection only; no runtime API or security behavior changes.
Overview
Generated platform API docs were linking many capabilities to
distdeclaration files (.d.cts) instead of editable.tssource, because monorepo scans see the same action/event twice and cross-package imports often resolve throughnode_modulesto build output first—whichever duplicate was processed first won.Deduplication scoring now adds a
sourceScorethat favors paths outside/dist/, so when both source and build declarations exist, docs keep the source file for links and metadata. Published-package-only consumers are unchanged (every candidate still looks likedist).Tests cover scanning with
node_modulesunder a broad scan dir and a monorepo-stylea-controller/b-controllerlayout assertingactions.mdpoints atpackages/b-controller/src/...and not/dist/. The changelog records the fix under Fixed.Reviewed by Cursor Bugbot for commit 38afbc9. Bugbot is set up for automated code reviews on this repo. Configure here.