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

[FEATURE] jsdoc: Improve support for ES6+ syntax #785

Merged
merged 27 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1df5ae5
ArrowFunctions + ArrowFunctionExpression.expression
d3xter666 Aug 15, 2022
7f42f00
Type validation + Arrow fuction expression
d3xter666 Aug 15, 2022
6fb8ec0
ArrowFunctionExpression cover all cases
d3xter666 Aug 16, 2022
eea010b
Refactor ArrowFunctionExpression
d3xter666 Aug 16, 2022
9193b4e
Avoid "computed" Identifier to be used at it might lead to hidden bugs
d3xter666 Aug 17, 2022
17c9686
Optional Chaining for MemberExpression & CallExpression
d3xter666 Aug 18, 2022
1499f33
Literals for Syntax.OptionalMemberExpression/OptionalCallExpression
d3xter666 Aug 18, 2022
5bb7a2e
Enhance LogicalExpression to support "||" and "??" oprators
d3xter666 Aug 19, 2022
de73361
Cover ChainExpression
d3xter666 Aug 19, 2022
3256d92
Wrapper Expressions generic approach
d3xter666 Aug 19, 2022
a9bb985
Cover possible retruning statements in JS
d3xter666 Aug 22, 2022
26448a1
Support alternate definitions of modules
d3xter666 Aug 22, 2022
3f2ad7a
ES6 Class definition export
d3xter666 Aug 22, 2022
a2ab576
Fix eslint checks
d3xter666 Aug 22, 2022
a6f23b5
Add tests
d3xter666 Aug 23, 2022
ca7fdd8
Enable all tests
d3xter666 Aug 23, 2022
9a419d0
Extend Syntax types "manually"
d3xter666 Aug 23, 2022
167e822
Fix types
d3xter666 Aug 23, 2022
8adad20
Bugfix chaining: There might be multilevel chains
d3xter666 Aug 23, 2022
8c47c34
Simplify tests
d3xter666 Aug 23, 2022
baa7205
Support of TemplateLiterals
d3xter666 Aug 24, 2022
1577586
Handle TemplateLiterals
d3xter666 Aug 25, 2022
7ce0b03
Bugfixes: Parse TemplateLiterals as strings
d3xter666 Aug 25, 2022
1efa268
Add JSDoc to the samples
d3xter666 Aug 25, 2022
9fa8ccf
Annotate properly ArrowFunctionExpression w/ expression: true
d3xter666 Aug 29, 2022
9172576
Updated api.json expectation
d3xter666 Aug 29, 2022
27bfd49
remove metamodel tag
d3xter666 Sep 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
392 changes: 277 additions & 115 deletions lib/processors/jsdoc/lib/ui5/plugin.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*!
* ${copyright}
*/

/**
* Covers:
* - ArrowFunction
* - ChainExpression
* - ClassDeclaration
*/
(sap?.ui).define([`Bar`], (Bar) => {
/**
* @class
* My super documentation of this class
*
* @extends library.j.Bar
*
* @author SAP SE
* @version ${version}
*
* @public
* @alias library.j.Foo
*/
class Foo extends Bar {
make() {
sap.ui.require("conditional/module1");
}
}

return Foo;
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*!
* ${copyright}
*/

/**
* Covers:
* - ArrowFunctionExpression
*/
window.someRandomModule ||
sap.ui.define(
["./a"],
/**
* Constructor for a new library.j.aaa.
*
* @param {string} [sId] ID for the new control, generated automatically if no ID is given
* @param {object} [mSettings] Initial settings for the new control
*
* @class
*
* @author SAP SE
* @version ${version}
*
* @constructor
* @extends library.j.a
* @public
* @since 1.22
* @alias library.j.aaa
* @ui5-metamodel This control will also be described in the UI5 (legacy) design time meta model.
*/
(a) =>
a.extend(`library.j.aaa`, {
metadata: {
properties: {
/**
* MyProp property
* @since 1.46
*/
MyProp: {
type: "boolean",
group: `Misc`,
defaultValue: false,
},
},
},
})
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*!
* ${copyright}
*/

/**
* Covers:
* - Generators
* - YeldExpression
*/
sap.ui.define([], function* someGenerator(genVar) {
yield genVar++;
});
26 changes: 15 additions & 11 deletions test/expected/build/library.j/dest/resources/library/j/some.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
* ${copyright}
*/

sap.ui.define([],
function() {
"use strict";
sap.ui.define(
["./dependency-es6-1"],
["./dependency-es6-2"],
["./dependency-es6-3"],
function (dep1, dep2, dep3) {
"use strict";

/**
* @alias library.j
* @namespace
* @public
*/
var SomeFunction = function() {};

}, /* bExport= */ true);
/**
* @alias library.j
* @namespace
* @public
*/
var SomeFunction = function () {};
},
/* bExport= */ true
);
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"$schema-ref":"http://schemas.sap.com/sapui5/designtime/api.json/1.0","version":"1.0.0","library":"library.j","symbols":[{"kind":"namespace","name":"library.j","basename":"j","resource":"library/j/some.js","module":"library/j/some","static":true,"visibility":"public"}]}
{"$schema-ref":"http://schemas.sap.com/sapui5/designtime/api.json/1.0","version":"1.0.0","library":"library.j","symbols":[{"kind":"namespace","name":"library.j","basename":"j","resource":"library/j/some.js","module":"library/j/some","static":true,"visibility":"public"},{"kind":"class","name":"library.j.aaa","basename":"aaa","resource":"library/j/dependency-es6-2.js","module":"library/j/dependency-es6-2","export":"","static":true,"visibility":"public","since":"1.22","extends":"library.j.a","ui5-metamodel":true,"ui5-metadata":{"properties":[{"name":"MyProp","type":"boolean","defaultValue":false,"group":"undefined","visibility":"public","since":"1.46","description":"MyProp property","methods":["getMyProp","setMyProp"]}]},"constructor":{"visibility":"public","parameters":[{"name":"sId","type":"string","optional":true,"description":"ID for the new control, generated automatically if no ID is given"},{"name":"mSettings","type":"object","optional":true,"description":"Initial settings for the new control"}],"description":"Constructor for a new library.j.aaa."},"methods":[{"name":"extend","visibility":"public","static":true,"returnValue":{"type":"function","description":"Created class / constructor function"},"parameters":[{"name":"sClassName","type":"string","optional":false,"description":"Name of the class being created"},{"name":"oClassInfo","type":"object","optional":true,"description":"Object literal with information about the class"},{"name":"FNMetaImpl","type":"function","optional":true,"description":"Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class"}],"description":"Creates a new subclass of class library.j.aaa with name <code>sClassName</code> and enriches it with the information contained in <code>oClassInfo</code>.\n\n<code>oClassInfo</code> might contain the same kind of information as described in {@link library.j.a.extend}."},{"name":"getMetadata","visibility":"public","static":true,"returnValue":{"type":"sap.ui.base.Metadata","description":"Metadata object describing this class"},"description":"Returns a metadata object for class library.j.aaa."},{"name":"getMyProp","visibility":"public","since":"1.46","returnValue":{"type":"boolean","description":"Value of property <code>MyProp</code>"},"description":"Gets current value of property {@link #getMyProp MyProp}.\n\nMyProp property\n\nDefault value is <code>false</code>."},{"name":"setMyProp","visibility":"public","since":"1.46","returnValue":{"type":"this","description":"Reference to <code>this</code> in order to allow method chaining"},"parameters":[{"name":"bMyProp","type":"boolean","optional":true,"defaultValue":false,"description":"New value for property <code>MyProp</code>"}],"description":"Sets a new value for property {@link #getMyProp MyProp}.\n\nMyProp property\n\nWhen called with a value of <code>null</code> or <code>undefined</code>, the default value of the property will be restored.\n\nDefault value is <code>false</code>."}]},{"kind":"class","name":"library.j.Foo","basename":"Foo","resource":"library/j/dependency-es6-1.js","module":"library/j/dependency-es6-1","static":true,"visibility":"public","extends":"library.j.Bar","description":"My super documentation of this class","constructor":{"visibility":"public"}}]}
31 changes: 31 additions & 0 deletions test/fixtures/library.j/main/src/library/j/dependency-es6-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*!
* ${copyright}
*/

/**
* Covers:
* - ArrowFunction
* - ChainExpression
* - ClassDeclaration
*/
(sap?.ui).define([`Bar`], (Bar) => {
/**
* @class
* My super documentation of this class
*
* @extends library.j.Bar
*
* @author SAP SE
* @version ${version}
*
* @public
* @alias library.j.Foo
*/
class Foo extends Bar {
make() {
sap.ui.require("conditional/module1");
}
}

return Foo;
});
46 changes: 46 additions & 0 deletions test/fixtures/library.j/main/src/library/j/dependency-es6-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*!
* ${copyright}
*/

/**
* Covers:
* - ArrowFunctionExpression
*/
window.someRandomModule ||
sap.ui.define(
["./a"],
/**
* Constructor for a new library.j.aaa.
*
* @param {string} [sId] ID for the new control, generated automatically if no ID is given
* @param {object} [mSettings] Initial settings for the new control
*
* @class
*
* @author SAP SE
* @version ${version}
*
* @constructor
* @extends library.j.a
* @public
* @since 1.22
* @alias library.j.aaa
* @ui5-metamodel This control will also be described in the UI5 (legacy) design time meta model.
*/
(a) =>
a.extend(`library.j.aaa`, {
metadata: {
properties: {
/**
* MyProp property
* @since 1.46
*/
MyProp: {
type: "boolean",
group: `Misc`,
defaultValue: false,
},
},
},
})
);
12 changes: 12 additions & 0 deletions test/fixtures/library.j/main/src/library/j/dependency-es6-3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*!
* ${copyright}
*/

/**
* Covers:
* - Generators
* - YeldExpression
*/
sap.ui.define([], function* someGenerator(genVar) {
yield genVar++;
});
26 changes: 15 additions & 11 deletions test/fixtures/library.j/main/src/library/j/some.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
* ${copyright}
*/

sap.ui.define([],
function() {
"use strict";
sap.ui.define(
["./dependency-es6-1"],
["./dependency-es6-2"],
["./dependency-es6-3"],
function (dep1, dep2, dep3) {
"use strict";

/**
* @alias library.j
* @namespace
* @public
*/
var SomeFunction = function() {};

}, /* bExport= */ true);
/**
* @alias library.j
* @namespace
* @public
*/
var SomeFunction = function () {};
},
/* bExport= */ true
);