sveltedoc-parser
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -6,5 +6,12 @@ # Change Log | ||
## [2.2.0] 15.08.2019 | ||
- [Added] Svelte V3: Add a new properties for data items: `originalName` and `importPath` | ||
- [Changed] Svelte V3: Add support for multiple bindings to one data item, now `bind` property of the item are array | ||
- [Changed] Property `value` for component items marked as depricated and new proprty `importPath` are used now | ||
- [Fixed] Issues with parsing | ||
## [2.1.0] 09.08.2019 | ||
- [Added] Svelte V3: Implement support for property binding parsing (`bind:proprty={...}`) | ||
- [Added] Svelte V3: Implement support for property binding parsing (`bind:property={...}`) | ||
- [Added] Svelte V3: Implement support for event parsing which dispatched from code (`dispatch(...)`) | ||
@@ -11,0 +18,0 @@ - [Added] Svelte V3: Implement support for event parsing which dispatched from markup expressions (`<button on:click="{() => dispatch(....)}">`) |
@@ -90,2 +90,10 @@ const { loadFileStructureFromOptions } = require('./lib/helpers'); | ||
if (newItem.bind && newItem.bind.length > 0) { | ||
if (currentItem.bind) { | ||
currentItem.bind.push(...newItem.bind); | ||
} else { | ||
currentItem.bind = [...newItem.bind]; | ||
} | ||
} | ||
if (!currentItem.bind && newItem.bind) { | ||
@@ -92,0 +100,0 @@ currentItem.bind = newItem.bind; |
@@ -207,3 +207,5 @@ const EventEmitter = require('events'); | ||
if (this.imports.hasOwnProperty(p.value.name)) { | ||
entry.value = this.imports[p.value.name].sourceFilename; | ||
// TODO: 3.*, Backward compatibility: Remove this property | ||
entry.importPath = this.imports[p.value.name].sourceFilename; | ||
entry.value = entry.importPath; | ||
} | ||
@@ -210,0 +212,0 @@ } |
const EventEmitter = require('events'); | ||
const util = require('util'); | ||
const path = require('path'); | ||
@@ -115,3 +116,5 @@ const espree = require('espree'); | ||
readonly: variable.kind === 'const', | ||
type: jsdoc.DEFAULT_TYPE | ||
type: jsdoc.DEFAULT_TYPE, | ||
importPath: variable.importPath, | ||
originalName: variable.originalName | ||
}); | ||
@@ -167,2 +170,4 @@ | ||
name: name, | ||
importPath: path, | ||
// TODO: 3.*, Backward compatibility: Remove this property | ||
value: path | ||
@@ -289,10 +294,10 @@ }); | ||
const specifier = node.specifiers[0]; | ||
const source = node.source; | ||
if (source && source.type === 'Literal') { | ||
const sourceFileName = source.value; | ||
if (specifier && specifier.type === 'ImportDefaultSpecifier') { | ||
const source = node.source; | ||
if (source && source.type === 'Literal') { | ||
if (specifier && specifier.type === 'ImportDefaultSpecifier') { | ||
const importEntry = { | ||
identifier: specifier.local.name, | ||
sourceFilename: source.value | ||
sourceFilename: sourceFileName | ||
}; | ||
@@ -308,5 +313,11 @@ | ||
} else { | ||
const imported = specifier.imported | ||
? specifier.imported.name | ||
: undefined; | ||
this.emitDataItem({ | ||
node, | ||
name: importEntry.identifier, | ||
originalName: imported || importEntry.identifier, | ||
importPath: importEntry.sourceFilename, | ||
kind: 'const' | ||
@@ -317,16 +328,19 @@ }, scopeType, 'private'); | ||
} | ||
} else if (node.specifiers.length > 0) { | ||
node.specifiers.forEach((specifier) => { | ||
if (specifier.type === 'ImportSpecifier') { | ||
this.emitDataItem({ | ||
node: specifier, | ||
name: specifier.local.name, | ||
originalName: specifier.imported | ||
? specifier.imported.name | ||
: specifier.local.name, | ||
importPath: sourceFileName, | ||
kind: 'const' | ||
}, scopeType, 'private'); | ||
} | ||
}); | ||
} | ||
} else if (node.specifiers.length > 0) { | ||
node.specifiers.forEach((specifier) => { | ||
if (specifier.type === 'ImportSpecifier') { | ||
this.emitDataItem({ | ||
node: specifier, | ||
name: specifier.local.name, | ||
kind: 'const' | ||
}, scopeType, 'private'); | ||
} | ||
}); | ||
// Import svelte API functions | ||
if (node.source.type === 'Literal' && node.source.value === 'svelte') { | ||
if (sourceFileName === 'svelte') { | ||
// Dispatcher constructors | ||
@@ -339,2 +353,7 @@ node.specifiers | ||
} | ||
} | ||
// Import svelte API functions | ||
if (node.source.type === 'Literal' && node.source.value === 'svelte') { | ||
} | ||
@@ -603,7 +622,7 @@ } | ||
name: bindProperty.targetPropertyName, | ||
kind: 'let', | ||
bind: { | ||
kind: undefined, | ||
bind: [{ | ||
source: bindProperty.parent, | ||
property: bindProperty.sourcePropertyName | ||
}, | ||
}], | ||
loc: bindProperty.loc, | ||
@@ -629,3 +648,3 @@ visibility: 'private', | ||
loc: this.includeSourceLocations && lastAttributeLocations.hasOwnProperty('bind:this') | ||
? lastAttributeLocations[name] | ||
? lastAttributeLocations['bind:this'] | ||
: null | ||
@@ -632,0 +651,0 @@ }); |
{ | ||
"name": "sveltedoc-parser", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Generate a JSON documentation for a Svelte file", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -107,3 +107,3 @@ /** | ||
*/ | ||
bind?: SvelteDataBindMapping; | ||
bind?: SvelteDataBindMapping[]; | ||
/** | ||
@@ -125,3 +125,18 @@ * Indicates that this data item of component located in static context. | ||
*/ | ||
value?: any | ||
value?: any; | ||
/** | ||
* The original name of the imported item. | ||
* Used when aliace are used in import statement. | ||
* @since Svelte V3 | ||
* @since {2.2.0} | ||
*/ | ||
originalName?: string; | ||
/** | ||
* The relative path of importing of this object. | ||
* When not defined, so variable is not provided. | ||
* @since Svelte V3 | ||
* @since {2.2.0} | ||
*/ | ||
importPath?: string; | ||
} | ||
@@ -180,4 +195,13 @@ | ||
* The relative path to improted component. | ||
* @deprecated Use `importPath` instead of this property. | ||
*/ | ||
value: string; | ||
/** | ||
* The relative path of importing of this object. | ||
* When not defined, so variable is not provided. | ||
* @since Svelte V3 | ||
* @since {2.2.0} | ||
*/ | ||
importPath?: string; | ||
} | ||
@@ -184,0 +208,0 @@ |
Sorry, the diff of this file is not supported yet
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
2122
99756