feat(jsii-diff): add tool to check API compatibility#415
Conversation
Add parsing semantics for various common capabilities to doc comments (summary, remarks, stability and others). Add a tool uses stability annotations in the doc comments to check whether two JSII assemblies are API-compatible.
- Rename `@see` field back to 'see'. - Treat unannotated APIs as `@stable` by default. - Add feature to leave out NPM package name by default for very concise comparison against latest release: `jsii-diff npm:`. - Split out struct vs ref interface comparisons to simplify. - Split out tests for same reason. - Take inherited constructors/methods into account. - Some more explanations in readme. - Fixed an oopsie, can't add required arguments to methods.
|
On the discussion of I will lift it to a first-class annotation in the JSII spec. The idea being that JSII client generators will have the ability to look at this annotation and add On whether the annotation burden should be on
For both of these reasons, I think the default should be sealed and |
| /// <summary>getXxx() is not allowed (see negatives), but getXxx(a, ...) is okay.</summary> | ||
| /// <remarks> | ||
| /// remarks: ..) is okay. | ||
| /// summary: getXxx() is not allowed (see negatives), but getXxx(a, . |
…s object instead of taking a mutable one
| } | ||
| const module = await fs.readJSON(JSII_ASSEMBLY_FILE, { encoding: 'utf-8' }) as spec.Assembly; | ||
| const module = spec.validateAssembly(await fs.readJSON(JSII_ASSEMBLY_FILE, { encoding: 'utf-8' })); | ||
| if (!module.name) { throw new Error(`Could not find package in ${JSII_ASSEMBLY_FILE}`); } |
There was a problem hiding this comment.
I don't reckon this is possible anymore, not that you've run through validateAssembly :)
RomainMuller
left a comment
There was a problem hiding this comment.
👌🏻 Dope. Would be nice to have follow-up issues created for the couple of low-impact items you're leaving out (colored output, this kind of things).
|
Done. Don't like what the C# generator is doing to the doc comments on final glance, so I'm going to have to dive in there to finish this off. |
| } | ||
| } | ||
|
|
||
| if (original.docs.isSubclassable && !updated.docs.isSubclassable) { |
| } | ||
|
|
||
| export function compareStruct(original: reflect.InterfaceType, updated: reflect.InterfaceType, context: ComparisonContext) { | ||
| // We don't compare structs here; they will be evaluated for compatibility |
There was a problem hiding this comment.
looks weird. wouldn't it make sense to just have an argument that says if this is an input/output struct? [and again I am going back to the intuition that this is an inherent property of a struct]
| * If present, this block indicates that an API item is no longer supported and may be | ||
| * removed in a future release. The `@deprecated` tag must be followed by a sentence | ||
| * describing the recommended alternative. Deprecation recursively applies to members | ||
| * of a container. For example, if a class is deprecated, then so are all of its members. |
There was a problem hiding this comment.
Are we propagating this in the jsii manifest? (we should)
There was a problem hiding this comment.
I've been going back and forth on this, and ultimately decided that the assembly would map most closely to the source of truth (the source code). The propagation analysis is done by jsii-reflect.
| * | ||
| * @default false | ||
| */ | ||
| subclassable?: boolean; |
There was a problem hiding this comment.
I am wondering if we should separate all these flags from "docs" into some some other struct associated with each type, but I guess pragmatically we can leave them here.
There was a problem hiding this comment.
Was thinking the same, ended up with this for now.
There was a problem hiding this comment.
Maybe also we can expose them as properties in jsii-reflect to improve discoverability...
There was a problem hiding this comment.
I was originally doing that, but because of the type inheritance tree in jsii-reflect it turned into copy/pasting a bunch of similar properties around and then I decided to just put everything on Docs. But yeah.
Add parsing semantics for various common capabilities to doc comments
(summary, remarks, stability and others).
Add a tool uses stability annotations in the doc comments to check
whether two JSII assemblies are API-compatible.
Fixes #358
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.