@condenast/ember-docs
Advanced tools
Comparing version 0.1.4 to 0.1.5
{ | ||
"name": "@condenast/ember-docs", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Creates documentation from Ember apps / addons", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -23,4 +23,11 @@ const commonmark = require('commonmark'); | ||
let positional = parameters.filter(param => { | ||
return positionalParams.indexOf(param.key.name) !== -1; | ||
let named = parameters.filter(param => { | ||
let comment = (param.leadingComments || []).find((comment) => { | ||
return comment.type === 'CommentBlock'; | ||
}); | ||
if (comment == null) return false; | ||
let doc = doctrine.parse(comment.value, { unwrap: false, recoverable: true }); | ||
let property = doc.tags.find(tag => tag.title === 'property'); | ||
return property; | ||
}).map(param => { | ||
@@ -31,3 +38,3 @@ let comment = (param.leadingComments || []).find((comment) => { | ||
let doc = doctrine.parse(comment.value, { unwrap: false, recoverable: true }); | ||
let property = doc.tags.find(tag => tag.title === 'property') || {}; | ||
let property = doc.tags.find(tag => tag.title === 'property'); | ||
let type = property.type; | ||
@@ -45,4 +52,4 @@ if (type) { | ||
return { | ||
positional, | ||
named: [] | ||
positional: positionalParams.map(name => named.find(param => param.name === name)), | ||
named | ||
}; | ||
@@ -49,0 +56,0 @@ } |
@@ -72,3 +72,3 @@ const _ = require('lodash'); | ||
let node = event.node; | ||
if (event.entering && node.type === 'code_block') { | ||
if (event.entering && node.type === 'code_block' && node.info == null) { | ||
examples.push(node.literal); | ||
@@ -75,0 +75,0 @@ node.literal = '\uFFFC'; |
@@ -5,2 +5,6 @@ import Component from '@ember/component'; | ||
This is my component that got reexported as a variable | ||
```hbs | ||
This component isn't turned into an example. | ||
``` | ||
*/ | ||
@@ -7,0 +11,0 @@ const MyComponent = Component.extend({ |
@@ -16,2 +16,23 @@ const parse = require('../../index'); | ||
'\n<p>Test</p>\n']); | ||
expect(component.parameters).toEqual({ | ||
named: [{ | ||
description: ["<p>The <code>type</code> of the <code>input</code> element.</p>\n"], | ||
name: 'type', | ||
type: 'string' | ||
}, { | ||
description: ["<p>The <code>placeholder</code> of the <code>input</code> element.</p>\n"], | ||
name: 'placeholder', | ||
type: 'string' | ||
}, { | ||
description: ["<p>Whether or not the field is read only</p>\n"], | ||
name: 'readonly', | ||
type: 'boolean' | ||
}, { | ||
description: ["<p>Whether or not the field is disabled.</p>\n"], | ||
name: 'disabled', | ||
type: 'boolean' | ||
}], | ||
positional: [] | ||
}); | ||
}); | ||
@@ -24,7 +45,11 @@ | ||
expect(component.description).toEqual([ | ||
'<p>This is my component that got reexported as a variable</p>\n' | ||
'<p>This is my component that got reexported as a variable</p>\n<pre><code class=\"language-hbs\">This component isn\'t turned into an example.\n</code></pre>\n' | ||
]); | ||
expect(component.parameters).toEqual({ | ||
named: [], | ||
named: [{ | ||
name: 'first', | ||
description: ['<p>This is the first param</p>\n'], | ||
type: 'string' | ||
}], | ||
positional: [{ | ||
@@ -31,0 +56,0 @@ name: 'first', |
52592
1442