Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package Based Matching for Inter-Package References when performing a Merge of JSON output #2833

Open
taylorb-syd opened this issue Jan 22, 2025 · 1 comment
Assignees
Milestone

Comments

@taylorb-syd
Copy link

taylorb-syd commented Jan 22, 2025

Search Terms

Merge, JSON, Separated, Declaration, Common Documentation, Inter-Package References

Problem

When merging generated JSON output for multiple repositories to create a common documentation using --merge inter-repo reflections do not resolve. This is despite the required information being in the symbolIdMap in the form of qualifiedName. I suspect this is because the sourceFileName does not match, that or merge functionality has not implemented this despite cross-package references working within packages according to the reference implementation. Either way there appears to be enough information to match the reflections.

Example:

To show what I mean I have taken (and redacted slightly) an example from one of the documentation merges I am seeing this problem in:

Within one package we can see the following reference for a parameter:

"type": {
   "type": "reference",
   "target": {
        "sourceFileName": "node_modules/@initech/core/lib/context.ts"
        "qualifiedName": "RequestContext"
   },
   "name": "RequestContext",
   "package": "@initech/core"
}

In the output for @initech/core we have the following in the symbolIdMap:

"316": {
  "sourceFileName": "lib/context.ts",
  "qualifiedName": "RequestContext"
},

And at the root of the object we can see that packageName is correctly set to @initech/core.

Suggested Solution

If the problem is in fact the mismatched sourceFileName. We can't rely on this, however we can instead match on the packageName, which means when merging we need to make sure we preserve the packageName inside the symbol mappings.

@taylorb-syd taylorb-syd added the enhancement Improved functionality label Jan 22, 2025
@taylorb-syd taylorb-syd changed the title Looser Matching for Inter-Package References when performing a Merge of JSON output Package Based Matching for Inter-Package References when performing a Merge of JSON output Jan 23, 2025
@taylorb-syd
Copy link
Author

taylorb-syd commented Jan 23, 2025

I think I have started to get a good idea of how things work. Please correct any misunderstandings:

It appears that when merging projects all reflections are put into a common StableKeyMap based upon the ReflectionSymbolId class. In order to make this work, we would need to modify the way ReflectionSymbolId works to encode the packageName into it when merging and/or serializing, then we need to modify the way targets are resolved. I'm stilling get my head around how this works under the hood, so I'm still a long way away from creating a PR.

@Gerrit0 Gerrit0 removed the enhancement Improved functionality label Feb 2, 2025
@Gerrit0 Gerrit0 added this to the v0.28.0 milestone Feb 21, 2025
@Gerrit0 Gerrit0 self-assigned this Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants