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

Allow marking of stubbed API #35

Closed
wants to merge 0 commits into from
Closed

Conversation

alvsan09
Copy link

@alvsan09 alvsan09 commented Aug 13, 2022

Fixes: #34

Allow marking types/members specifically as stubbed, so that they show up as warning (orange), meaning that the types are available but actually not functional.

The markings are provisioned in the existing infos.yml file via a new optional entry called _stubbed which can have two attributes from (mandatory) andto` (optional), these two attributes represent the start and end versions where stubbing applies.

The following applies:

  • The _stubbed yml entry can be entered as a child of any type/member
  • _stubbed can shall have a from attribute and an optional to attribute
  • from and to shall hold string values representing the versions where stubbing applies
  • The versions can be represented using formats present in the generated reports e.g. v1.27.0, master, local
  • Versions can also be represented as three numbers separated by . e.g. 1.26.0
  • The to version is optional, meaning that stubbing applies from a given version until latest (master or local)
  • For practical reasons, the local version is considered equivalent to master i.e. representing latest.
  • The following can be provisioned but is discouraged, as may have undesired results when moving to next versions
    • from having master or local
    • to having master or local, this behaves the same as not having the to version
  • The markings apply to entries that would otherwise appear as implemented in green with the checked icon. i.e. not-implemented markings are not impacted.
  • Both of the generated reports status.html as well as filtered-status.html include stubbed markings
  • The markings apply to specific cells using an orange background with a half filled star icon.
  • When hovering one of these cells the tooltip is appended with the word (stubbed) which clarifies the meaning.

How to Test:
The following gist contains three files, use the infos.yml file to test different stubbed markings,
The other two files are generated status.html and filtered-status.html files generated with the above mentioned infos.yml
https://gist.github.com/alvsan09/e6c6aaf18a3e343109a01c02a56ca5b6

Example:
filtered_stubbed_markings

alvsan09 added a commit that referenced this pull request Aug 13, 2022
Signed-off-by: Alvaro Sanchez-Leon <[email protected]>
@alvsan09 alvsan09 force-pushed the asl/mark_stubbed_api branch from abb889b to 3322572 Compare August 13, 2022 16:34
alvsan09 added a commit that referenced this pull request Aug 14, 2022
Signed-off-by: Alvaro Sanchez-Leon <[email protected]>
@alvsan09 alvsan09 force-pushed the asl/mark_stubbed_api branch from 3322572 to 4010873 Compare August 14, 2022 12:27
alvsan09 added a commit that referenced this pull request Aug 14, 2022
Signed-off-by: Alvaro Sanchez-Leon <[email protected]>
@alvsan09 alvsan09 force-pushed the asl/mark_stubbed_api branch from 4010873 to e04f1d7 Compare August 14, 2022 12:35
@alvsan09 alvsan09 added the enhancement New feature or request label Aug 15, 2022
Copy link
Contributor

@colin-grant-work colin-grant-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on discussion on #32 and #36, I think we'd like to mark stubs in a slightly different way in Theia's theia.d.ts file rather than the infos.yml file. Ping me when you're ready for another look.

Comment on lines 61 to 118
/**
* Each argument represents a semantic version
*/
function isVersionInRange(input: string, from: string, to?: string): boolean {
const inputArr = input.split('.');
const fromArr = from.split('.');
const toArr = to ? to.split('.') : undefined;

if (
inputArr.length !== semverLength ||
fromArr.length !== semverLength ||
!!(toArr && toArr.length !== semverLength)
) {
throw new Error('The expected length of semantic versions is 3');
}

const greaterOrEqual = isGreaterOrEqual(inputArr, fromArr);
if (!greaterOrEqual) {
return false;
}

if (!toArr) {
// Not having a 'to' version means the condition is still present i.e. stubbing applies.
return true;
}

return isLessOrEqual(inputArr, toArr);
}

function isGreaterOrEqual(inputArr: string[], referenceArr: string[]): boolean {
for (let i = 0; i < semverLength; i++) {
if (+inputArr[i] > +referenceArr[i]) {
return true;
}

if (+inputArr[i] < +referenceArr[i]) {
return false;
}
}

// Must be equal
return true;
}

function isLessOrEqual(inputArr: string[], referenceArr: string[]): boolean {
for (let i = 0; i < semverLength; i++) {
if (+inputArr[i] < +referenceArr[i]) {
return true;
}

if (+inputArr[i] > +referenceArr[i]) {
return false;
}
}

// Must be equal
return true;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to use the semver package for these comparisons. Let them handle any corner cases :-).

@alvsan09 alvsan09 closed this Aug 26, 2022
@alvsan09 alvsan09 force-pushed the asl/mark_stubbed_api branch from e04f1d7 to 9a51ed9 Compare August 26, 2022 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow marking of stubbed API via the 'info.yml' file
2 participants