docworks-jsdoc2spec
Advanced tools
Comparing version 1.3.11 to 1.4.4
@@ -28,9 +28,10 @@ 'use strict'; | ||
var extra = (0, _docworksPlugins2.default)(plugins, 'extendDocworksProperty', member); | ||
if (member.type) return (0, _docworksModel.Property)(member.name, [], true, false, (0, _jsdocHandlerShared.handleType)(member.type, find, onError, context), [location], (0, _jsdocHandlerShared.handleDoc)(member), (0, _jsdocHandlerShared.handleDoc)(member), extra); | ||
var defaultValue = member.defaultvalue; | ||
if (member.type) return (0, _docworksModel.Property)(member.name, [], true, false, (0, _jsdocHandlerShared.handleType)(member.type, find, onError, context), defaultValue, [location], (0, _jsdocHandlerShared.handleDoc)(member), (0, _jsdocHandlerShared.handleDoc)(member), extra); | ||
// handle write property | ||
if (member.params && member.params.length > 0) return (0, _docworksModel.Property)(member.name, [], false, true, (0, _jsdocHandlerShared.handleType)(member.params[0].type, find, onError, context), [location], (0, _jsdocHandlerShared.handleDoc)(member), (0, _jsdocHandlerShared.handleDoc)(member), extra); | ||
if (member.params && member.params.length > 0) return (0, _docworksModel.Property)(member.name, [], false, true, (0, _jsdocHandlerShared.handleType)(member.params[0].type, find, onError, context), defaultValue, [location], (0, _jsdocHandlerShared.handleDoc)(member), (0, _jsdocHandlerShared.handleDoc)(member), extra); | ||
onError((0, _docworksModel.JsDocError)('Property ' + member.name + ' is missing a type annotation', [location])); | ||
return (0, _docworksModel.Property)(member.name, [], false, false, _docworksModel.Void, [location], (0, _jsdocHandlerShared.handleDoc)(member), (0, _jsdocHandlerShared.handleDoc)(member), extra); | ||
return (0, _docworksModel.Property)(member.name, [], false, false, _docworksModel.Void, defaultValue, [location], (0, _jsdocHandlerShared.handleDoc)(member), (0, _jsdocHandlerShared.handleDoc)(member), extra); | ||
}; | ||
@@ -50,3 +51,3 @@ }; | ||
var prop1 = properties[0]; | ||
if (properties.length == 1) { | ||
if (properties.length === 1) { | ||
if (prop1.set && !prop1.get) onError((0, _docworksModel.JsDocError)('Property ' + prop1.name + ' is a write only property', prop1.locations)); | ||
@@ -56,3 +57,3 @@ | ||
} | ||
if (properties.length == 2) { | ||
if (properties.length === 2) { | ||
@@ -62,15 +63,15 @@ var prop2 = properties[1]; | ||
var _locations = prop1.locations.concat(prop2.locations); | ||
if (prop1.type === prop2.type && prop1.get != prop2.get && prop1.set != prop2.set) { | ||
if (prop1.type === prop2.type && prop1.get !== prop2.get && prop1.set !== prop2.set) { | ||
var docs = prop1.get ? prop1.docs : prop2.docs; | ||
return (0, _docworksModel.Property)(prop1.name, [], true, true, prop1.type, _locations, docs, docs, extra); | ||
return (0, _docworksModel.Property)(prop1.name, [], true, true, prop1.type, prop1.defaultValue, _locations, docs, docs, extra); | ||
} | ||
if (prop1.type !== prop2.type && prop1.get != prop2.get && prop1.set != prop2.set) { | ||
if (prop1.type !== prop2.type && prop1.get !== prop2.get && prop1.set !== prop2.set) { | ||
onError((0, _docworksModel.JsDocError)('Property ' + prop1.name + ' has mismatching types for get (' + prop1.type + ') and set (' + prop2.type + ')', _locations)); | ||
var _docs = prop1.get ? prop1.docs : prop2.docs; | ||
return (0, _docworksModel.Property)(prop1.name, [], true, true, prop1.type, _locations, _docs, extra); | ||
return (0, _docworksModel.Property)(prop1.name, [], true, true, prop1.type, prop1.defaultValue, _locations, _docs, extra); | ||
} | ||
onError((0, _docworksModel.JsDocError)('Property ' + prop1.name + ' is defined two or more times', _locations)); | ||
return (0, _docworksModel.Property)(prop1.name, [], true, true, prop1.type, _locations, prop1.docs, prop1.docs, prop1.extra); | ||
return (0, _docworksModel.Property)(prop1.name, [], true, true, prop1.type, prop1.defaultValue, _locations, prop1.docs, prop1.docs, prop1.extra); | ||
} | ||
@@ -77,0 +78,0 @@ var locations = (_ref = []).concat.apply(_ref, _toConsumableArray(properties.map(function (_) { |
@@ -13,11 +13,12 @@ | ||
let extra = handlePlugins(plugins, 'extendDocworksProperty', member); | ||
let defaultValue = member.defaultvalue; | ||
if (member.type) | ||
return Property(member.name, [], true, false, handleType(member.type, find, onError, context), [location], handleDoc(member), handleDoc(member), extra); | ||
return Property(member.name, [], true, false, handleType(member.type, find, onError, context), defaultValue, [location], handleDoc(member), handleDoc(member), extra); | ||
// handle write property | ||
if (member.params && member.params.length > 0) | ||
return Property(member.name, [], false, true, handleType(member.params[0].type, find, onError, context), [location], handleDoc(member), handleDoc(member), extra); | ||
return Property(member.name, [], false, true, handleType(member.params[0].type, find, onError, context), defaultValue, [location], handleDoc(member), handleDoc(member), extra); | ||
onError(JsDocError(`Property ${member.name} is missing a type annotation`, [location])); | ||
return Property(member.name, [], false, false, Void, [location], handleDoc(member), handleDoc(member), extra); | ||
return Property(member.name, [], false, false, Void, defaultValue, [location], handleDoc(member), handleDoc(member), extra); | ||
@@ -38,3 +39,3 @@ }; | ||
let prop1 = properties[0]; | ||
if (properties.length == 1) { | ||
if (properties.length === 1) { | ||
if (prop1.set && !prop1.get) | ||
@@ -47,3 +48,3 @@ onError(JsDocError( | ||
} | ||
if (properties.length == 2) { | ||
if (properties.length === 2) { | ||
@@ -54,11 +55,11 @@ let prop2 = properties[1]; | ||
if (prop1.type === prop2.type && | ||
prop1.get != prop2.get && | ||
prop1.set != prop2.set) { | ||
prop1.get !== prop2.get && | ||
prop1.set !== prop2.set) { | ||
let docs = prop1.get?prop1.docs:prop2.docs; | ||
return Property(prop1.name, [], true, true, prop1.type, locations, docs, docs, extra); | ||
return Property(prop1.name, [], true, true, prop1.type, prop1.defaultValue, locations, docs, docs, extra); | ||
} | ||
if (prop1.type !== prop2.type && | ||
prop1.get != prop2.get && | ||
prop1.set != prop2.set) { | ||
prop1.get !== prop2.get && | ||
prop1.set !== prop2.set) { | ||
onError(JsDocError( | ||
@@ -68,3 +69,3 @@ `Property ${prop1.name} has mismatching types for get (${prop1.type}) and set (${prop2.type})`, | ||
let docs = prop1.get?prop1.docs:prop2.docs; | ||
return Property(prop1.name, [], true, true, prop1.type, locations, docs, extra) | ||
return Property(prop1.name, [], true, true, prop1.type, prop1.defaultValue, locations, docs, extra) | ||
} | ||
@@ -75,3 +76,3 @@ | ||
locations)); | ||
return Property(prop1.name, [], true, true, prop1.type, locations, prop1.docs, prop1.docs, prop1.extra) | ||
return Property(prop1.name, [], true, true, prop1.type, prop1.defaultValue, locations, prop1.docs, prop1.docs, prop1.extra) | ||
@@ -78,0 +79,0 @@ } |
{ | ||
"name": "docworks-jsdoc2spec", | ||
"version": "1.3.11", | ||
"version": "1.4.4", | ||
"description": "extractor for jsdoc apis to api spec", | ||
@@ -14,3 +14,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"docworks-model": "^1.3.11", | ||
"docworks-model": "^1.4.4", | ||
"intercept-stdout": "^0.1.2", | ||
@@ -17,0 +17,0 @@ "jsdoc": "3.4.0", |
@@ -9,106 +9,124 @@ | ||
class ServiceProperties { | ||
/** | ||
* @member readOnly | ||
* @memberof aNamespace.ServiceProperties | ||
* @type {string} | ||
* @summary Sets or returns the label. | ||
*/ | ||
get readOnly() { | ||
} | ||
/** | ||
* @member readOnly | ||
* @memberof aNamespace.ServiceProperties | ||
* @type {string} | ||
* @summary Sets or returns the label. | ||
*/ | ||
get readOnly() { | ||
} | ||
/** | ||
* @member writeOnly | ||
* @memberof aNamespace.ServiceProperties | ||
* @param {string} value The new label to display. | ||
* @summary Sets or returns the label. | ||
*/ | ||
set writeOnly(value) { | ||
} | ||
/** | ||
* @member writeOnly | ||
* @memberof aNamespace.ServiceProperties | ||
* @param {string} value The new label to display. | ||
* @summary Sets or returns the label. | ||
*/ | ||
set writeOnly(value) { | ||
} | ||
/** | ||
* @member label | ||
* @memberof aNamespace.ServiceProperties | ||
* @type {string} | ||
* @summary Sets or returns the label. | ||
*/ | ||
get label() { | ||
} | ||
/** | ||
* @member label | ||
* @memberof aNamespace.ServiceProperties | ||
* @type {string} | ||
* @summary Sets or returns the label. | ||
*/ | ||
get label() { | ||
} | ||
/** | ||
* @member label | ||
* @memberof aNamespace.ServiceProperties | ||
* @param {string} value The new label to display. | ||
*/ | ||
set label(value) { | ||
} | ||
/** | ||
* @member label | ||
* @memberof aNamespace.ServiceProperties | ||
* @param {string} value The new label to display. | ||
*/ | ||
set label(value) { | ||
} | ||
/** | ||
* @member missingType | ||
* @memberof aNamespace.ServiceProperties | ||
* @summary Sets or returns the label. | ||
*/ | ||
get missingType() { | ||
} | ||
/** | ||
* @member missingType | ||
* @memberof aNamespace.ServiceProperties | ||
* @summary Sets or returns the label. | ||
*/ | ||
get missingType() { | ||
} | ||
/** | ||
* @member missMatchType | ||
* @memberof aNamespace.ServiceProperties | ||
* @type {string} | ||
* @summary Sets or returns the label. | ||
*/ | ||
get missMatchType() { | ||
} | ||
/** | ||
* @member missMatchType | ||
* @memberof aNamespace.ServiceProperties | ||
* @type {string} | ||
* @summary Sets or returns the label. | ||
*/ | ||
get missMatchType() { | ||
} | ||
/** | ||
* @member missMatchType | ||
* @memberof aNamespace.ServiceProperties | ||
* @param {number} value The new label to display. | ||
*/ | ||
set missMatchType(value) { | ||
} | ||
/** | ||
* @member missMatchType | ||
* @memberof aNamespace.ServiceProperties | ||
* @param {number} value The new label to display. | ||
*/ | ||
set missMatchType(value) { | ||
} | ||
/** | ||
* @member dumplicate | ||
* @memberof aNamespace.ServiceProperties | ||
* @type {string} | ||
* @summary Sets or returns the label. | ||
*/ | ||
get dumplicate1() { | ||
} | ||
/** | ||
* @member dumplicate | ||
* @memberof aNamespace.ServiceProperties | ||
* @type {string} | ||
* @summary Sets or returns the label. | ||
*/ | ||
get dumplicate1() { | ||
} | ||
/** | ||
* @member dumplicate | ||
* @memberof aNamespace.ServiceProperties | ||
* @type {string} | ||
* @summary Sets or returns the label. | ||
*/ | ||
get dumplicate2() { | ||
} | ||
/** | ||
* @member dumplicate | ||
* @memberof aNamespace.ServiceProperties | ||
* @type {string} | ||
* @summary Sets or returns the label. | ||
*/ | ||
get dumplicate2() { | ||
} | ||
/** | ||
* @member dumplicate2 | ||
* @memberof aNamespace.ServiceProperties | ||
* @type {string} | ||
* @summary Sets or returns the label. | ||
*/ | ||
get dumplicate_case_B_1() { | ||
} | ||
/** | ||
* @member dumplicate2 | ||
* @memberof aNamespace.ServiceProperties | ||
* @type {string} | ||
* @summary Sets or returns the label. | ||
*/ | ||
get dumplicate_case_B_1() { | ||
} | ||
/** | ||
* @member dumplicate2 | ||
* @memberof aNamespace.ServiceProperties | ||
* @type {string} | ||
* @summary Sets or returns the label. | ||
*/ | ||
get dumplicate_case_B_2() { | ||
} | ||
/** | ||
* @member dumplicate2 | ||
* @memberof aNamespace.ServiceProperties | ||
* @type {string} | ||
* @summary Sets or returns the label. | ||
*/ | ||
get dumplicate_case_B_2() { | ||
} | ||
/** | ||
* @member dumplicate2 | ||
* @memberof aNamespace.ServiceProperties | ||
* @type {string} | ||
* @summary Sets or returns the label. | ||
*/ | ||
get dumplicate_case_B_3() { | ||
} | ||
/** | ||
* @member dumplicate2 | ||
* @memberof aNamespace.ServiceProperties | ||
* @type {string} | ||
* @summary Sets or returns the label. | ||
*/ | ||
get dumplicate_case_B_3() { | ||
} | ||
/** | ||
* @member withDefaultValue | ||
* @memberof aNamespace.ServiceProperties | ||
* @type {string} | ||
* @summary has a default value | ||
* @default a default value | ||
*/ | ||
get hasDefaultValue() { | ||
} | ||
/** | ||
* @member withDefaultValue | ||
* @memberof aNamespace.ServiceProperties | ||
* @param {string} value | ||
*/ | ||
set hasDefaultValue(value) { | ||
} | ||
} | ||
@@ -115,0 +133,0 @@ |
@@ -9,150 +9,165 @@ import runJsDoc from '../lib/jsdoc-runner'; | ||
describe('docs', function() { | ||
describe('service properties', function() { | ||
let jsDocRes; | ||
beforeEach(() => { | ||
jsDocRes = runJsDoc({ | ||
"include": [ | ||
"test/service-properties.js" | ||
] | ||
}); | ||
}); | ||
describe('service properties', function() { | ||
let jsDocRes; | ||
beforeEach(() => { | ||
jsDocRes = runJsDoc({ | ||
"include": [ | ||
"test/service-properties.js" | ||
] | ||
}); | ||
}); | ||
afterEach(function(){ | ||
if (this.currentTest.state == 'failed') { | ||
console.log('the jsDocRes:'); | ||
dump(jsDocRes); | ||
} | ||
}); | ||
afterEach(function(){ | ||
if (this.currentTest.state == 'failed') { | ||
console.log('the jsDocRes:'); | ||
dump(jsDocRes); | ||
} | ||
}); | ||
it('should support readonly property', function() { | ||
it('should support readonly property', function() { | ||
expect(jsDocRes).to.containSubset({ | ||
services: [ | ||
{ | ||
name: 'ServiceProperties', | ||
properties: [ | ||
{name: 'readOnly', get: true, set: false, type: 'string'} | ||
] | ||
} | ||
] | ||
}); | ||
expect(jsDocRes.errors).to.not.containError('Property readOnly'); | ||
}); | ||
expect(jsDocRes).to.containSubset({ | ||
services: [ | ||
{ | ||
name: 'ServiceProperties', | ||
properties: [ | ||
{name: 'readOnly', get: true, set: false, type: 'string'} | ||
] | ||
} | ||
] | ||
}); | ||
expect(jsDocRes.errors).to.not.containError('Property readOnly'); | ||
}); | ||
it('should not allow writeonly properties', function() { | ||
it('should not allow writeonly properties', function() { | ||
expect(jsDocRes).to.containSubset({ | ||
services: [ | ||
{ | ||
name: 'ServiceProperties', | ||
properties: [ | ||
{name: 'writeOnly', get: false, set: true, type: 'string'} | ||
] | ||
} | ||
], | ||
errors: [ | ||
{ | ||
message: 'Property writeOnly is a write only property', | ||
location: 'service-properties.js (18)' | ||
} | ||
] | ||
}); | ||
}); | ||
expect(jsDocRes).to.containSubset({ | ||
services: [ | ||
{ | ||
name: 'ServiceProperties', | ||
properties: [ | ||
{name: 'writeOnly', get: false, set: true, type: 'string'} | ||
] | ||
} | ||
], | ||
errors: [ | ||
{ | ||
message: 'Property writeOnly is a write only property', | ||
location: 'service-properties.js (18)' | ||
} | ||
] | ||
}); | ||
}); | ||
it('should merge get and set members declaration into a single property', function() { | ||
it('should merge get and set members declaration into a single property', function() { | ||
expect(jsDocRes).to.containSubset({ | ||
services: [ | ||
{ | ||
name: 'ServiceProperties', | ||
properties: [ | ||
{name: 'label', get: true, set: true, type: 'string'} | ||
] | ||
} | ||
] | ||
}); | ||
expect(jsDocRes.errors).to.not.containError('Property label'); | ||
}); | ||
expect(jsDocRes).to.containSubset({ | ||
services: [ | ||
{ | ||
name: 'ServiceProperties', | ||
properties: [ | ||
{name: 'label', get: true, set: true, type: 'string'} | ||
] | ||
} | ||
] | ||
}); | ||
expect(jsDocRes.errors).to.not.containError('Property label'); | ||
}); | ||
it('should error on missing type', function() { | ||
it('should error on missing type', function() { | ||
expect(jsDocRes).to.containSubset({ | ||
services: [ | ||
{ | ||
name: 'ServiceProperties', | ||
properties: [ | ||
{ name: 'missingType', get: false, set: false, type: 'void' } | ||
] | ||
} | ||
], | ||
errors: [ | ||
{ | ||
message: 'Property missingType is missing a type annotation', | ||
location: 'service-properties.js (44)' | ||
} | ||
] | ||
}); | ||
}); | ||
expect(jsDocRes).to.containSubset({ | ||
services: [ | ||
{ | ||
name: 'ServiceProperties', | ||
properties: [ | ||
{ name: 'missingType', get: false, set: false, type: 'void' } | ||
] | ||
} | ||
], | ||
errors: [ | ||
{ | ||
message: 'Property missingType is missing a type annotation', | ||
location: 'service-properties.js (44)' | ||
} | ||
] | ||
}); | ||
}); | ||
it('should error on mismatched type between get and set', function() { | ||
it('should error on mismatched type between get and set', function() { | ||
expect(jsDocRes).to.containSubset({ | ||
services: [ | ||
{ | ||
name: 'ServiceProperties', | ||
properties: [ | ||
{ name: 'missMatchType', get: true, set: true, type: 'string' } | ||
] | ||
} | ||
], | ||
errors: [ | ||
{ | ||
message: 'Property missMatchType has mismatching types for get (string) and set (number)', | ||
location: 'service-properties.js (52, 61)' | ||
} | ||
] | ||
}); | ||
}); | ||
expect(jsDocRes).to.containSubset({ | ||
services: [ | ||
{ | ||
name: 'ServiceProperties', | ||
properties: [ | ||
{ name: 'missMatchType', get: true, set: true, type: 'string' } | ||
] | ||
} | ||
], | ||
errors: [ | ||
{ | ||
message: 'Property missMatchType has mismatching types for get (string) and set (number)', | ||
location: 'service-properties.js (52, 61)' | ||
} | ||
] | ||
}); | ||
}); | ||
it('should error on duplicate property definition', function() { | ||
it('should error on duplicate property definition', function() { | ||
expect(jsDocRes).to.containSubset({ | ||
services: [ | ||
{ | ||
name: 'ServiceProperties', | ||
properties: [ | ||
{ name: 'dumplicate', get: true, set: true, type: 'string' } | ||
] | ||
} | ||
], | ||
errors: [ | ||
{ | ||
message: 'Property dumplicate is defined two or more times', | ||
location: 'service-properties.js (69, 78)' | ||
} | ||
] | ||
}); | ||
}); | ||
expect(jsDocRes).to.containSubset({ | ||
services: [ | ||
{ | ||
name: 'ServiceProperties', | ||
properties: [ | ||
{ name: 'dumplicate', get: true, set: true, type: 'string' } | ||
] | ||
} | ||
], | ||
errors: [ | ||
{ | ||
message: 'Property dumplicate is defined two or more times', | ||
location: 'service-properties.js (69, 78)' | ||
} | ||
] | ||
}); | ||
}); | ||
it('should error on duplicate 3 times property definition', function() { | ||
it('should error on duplicate 3 times property definition', function() { | ||
expect(jsDocRes).to.containSubset({ | ||
services: [ | ||
{ | ||
name: 'ServiceProperties', | ||
properties: [ | ||
{ name: 'dumplicate2', get: true, set: false, type: 'string' } | ||
] | ||
} | ||
], | ||
errors: [ | ||
{ | ||
message: 'Property dumplicate2 is defined two or more times', | ||
location: 'service-properties.js (87, 96, 105)' | ||
} | ||
] | ||
}); | ||
}); | ||
expect(jsDocRes).to.containSubset({ | ||
services: [ | ||
{ | ||
name: 'ServiceProperties', | ||
properties: [ | ||
{ name: 'dumplicate2', get: true, set: false, type: 'string' } | ||
] | ||
} | ||
], | ||
errors: [ | ||
{ | ||
message: 'Property dumplicate2 is defined two or more times', | ||
location: 'service-properties.js (87, 96, 105)' | ||
} | ||
] | ||
}); | ||
}); | ||
it('should support property with a default value', function() { | ||
expect(jsDocRes).to.containSubset({ | ||
services: [ | ||
{ | ||
name: 'ServiceProperties', | ||
properties: [ | ||
{name: 'withDefaultValue', get: true, set: true, type: 'string', defaultValue: 'a default value'} | ||
] | ||
} | ||
] | ||
}); | ||
expect(jsDocRes.errors).to.not.containError('Property withDefaultValue'); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3505
125255
Updateddocworks-model@^1.4.4