@condenast/ember-docs
Advanced tools
Comparing version 0.1.3 to 0.1.4
{ | ||
"name": "@condenast/ember-docs", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Creates documentation from Ember apps / addons", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,2 +8,3 @@ const commonmark = require('commonmark'); | ||
let positionalParams = staticProperties.find(property => property.key.name === 'positionalParams'); | ||
if (positionalParams) { | ||
@@ -21,5 +22,25 @@ if (positionalParams.value.type === 'ArrayExpression') { | ||
let positionalParams = getPositionalParameters(ast, component); | ||
let parameters = utils.getProperties(ast); | ||
let positional = parameters.filter(param => { | ||
return positionalParams.indexOf(param.key.name) !== -1; | ||
}).map(param => { | ||
let comment = (param.leadingComments || []).find((comment) => { | ||
return comment.type === 'CommentBlock'; | ||
}); | ||
let doc = doctrine.parse(comment.value, { unwrap: false, recoverable: true }); | ||
let property = doc.tags.find(tag => tag.title === 'property') || {}; | ||
let type = property.type; | ||
if (type) { | ||
type = type.name; | ||
} | ||
return { | ||
name: param.key.name, | ||
description: utils.markdown(doc.description || ''), | ||
type | ||
} | ||
}); | ||
return { | ||
positional: [], | ||
positional, | ||
named: [] | ||
@@ -26,0 +47,0 @@ }; |
@@ -72,3 +72,3 @@ /** | ||
// Pod components | ||
if (name.match(/component$/)) { | ||
if (name.match(/\/component$/)) { | ||
name = name.match(/(.*)\/component$/)[1]; | ||
@@ -75,0 +75,0 @@ } |
@@ -169,5 +169,10 @@ const _ = require('lodash'); | ||
let properties = []; | ||
let callExpression = main; | ||
if (main.type === 'CallExpression') { | ||
main.arguments.filter(arg => arg.type === 'ObjectExpression').forEach(body => { | ||
if (main.type === 'VariableDeclarator') { | ||
callExpression = main.init; | ||
} | ||
if (callExpression.type === 'CallExpression') { | ||
callExpression.arguments.filter(arg => arg.type === 'ObjectExpression').forEach(body => { | ||
body.properties.filter(property => property.type === 'ObjectProperty').forEach(property => { | ||
@@ -233,3 +238,3 @@ properties.push(property); | ||
*/ | ||
if (dfn.callee.property && dfn.callee.property.name === 'reopenClass') { | ||
if (dfn.callee && dfn.callee.property && dfn.callee.property.name === 'reopenClass') { | ||
staticProperties = staticProperties.concat( | ||
@@ -236,0 +241,0 @@ dfn.arguments[0].properties.filter((property) => property.type === 'ObjectProperty') |
@@ -18,2 +18,20 @@ const parse = require('../../index'); | ||
test('variable-export-component', () => { | ||
let component = parse(path.resolve(__dirname, '../fixtures/classic/app/components/variable-export-component.js'), {}); | ||
expect(component.name).toBe('variable-export-component'); | ||
expect(component.access).toBe('public'); | ||
expect(component.description).toEqual([ | ||
'<p>This is my component that got reexported as a variable</p>\n' | ||
]); | ||
expect(component.parameters).toEqual({ | ||
named: [], | ||
positional: [{ | ||
name: 'first', | ||
description: ['<p>This is the first param</p>\n'], | ||
type: 'string' | ||
}] | ||
}); | ||
}); | ||
describe('pods', () => { | ||
@@ -20,0 +38,0 @@ test('text-field', () => { |
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
51298
30
1409