terra-props-table
Advanced tools
Comparing version 2.13.0 to 2.14.0
const generatePropType = require('./generatePropType'); | ||
const generatePropRow = (propName, prop) => ( | ||
`| ${propName || ''}` + | ||
`| ${propName || ''}` + | ||
`| ${prop.type ? generatePropType(prop.type) : ''}` + | ||
@@ -10,4 +10,4 @@ `| ${prop.required ? '`required`' : 'optional'}` + | ||
'|' | ||
); | ||
); | ||
module.exports = generatePropRow; |
@@ -9,3 +9,3 @@ const generatePropRow = require('./generatePropRow'); | ||
`${tableHeader}${tableHeaderBottom}${ | ||
Object.keys(props).sort().map(propName => generatePropRow(propName, props[propName])).join('\n')}` | ||
Object.keys(props).sort().map(propName => generatePropRow(propName, props[propName])).join('\n')}` | ||
); | ||
@@ -12,0 +12,0 @@ }; |
@@ -9,3 +9,3 @@ function formatShape(shape) { | ||
if (type.name === 'enum') { | ||
if (isNaN(type.value[0].value)) { | ||
if (Number.isNaN(Number(type.value[0].value))) { | ||
typeName = typeof type.value[0].value; | ||
@@ -12,0 +12,0 @@ } else { |
@@ -10,5 +10,4 @@ #!/usr/bin/env node | ||
const generateMarkdown = require('./generateMarkdown/generateMarkdown'); | ||
const parse = require('react-docgen').parse; | ||
const { parse } = require('react-docgen'); | ||
commander | ||
@@ -15,0 +14,0 @@ .version(pkg.version) |
@@ -7,2 +7,11 @@ Changelog | ||
2.13.0 - (July 17, 2018) | ||
------------------ | ||
### Changed | ||
* Minor dependency version bump | ||
* Formatting changes per eslint v4 update | ||
### Removed | ||
* Implicit inferring of an `enum`'s type based on its first child. | ||
2.12.0 - (July 10, 2018) | ||
@@ -9,0 +18,0 @@ ------------------ |
@@ -9,5 +9,2 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /* eslint-disable import/no-extraneous-dependencies */ | ||
var _react = require('react'); | ||
@@ -37,4 +34,5 @@ | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } /* eslint-disable import/no-extraneous-dependencies */ | ||
var cx = _bind2.default.bind(_PropsTable2.default); | ||
@@ -60,10 +58,4 @@ | ||
// Pull the first value off and use that as type. | ||
// This assumes all enumerable values are the same type. | ||
if (typeName === 'enum') { | ||
if (isNaN(type.value[0].value)) { | ||
typeName = _typeof(type.value[0].value); | ||
} else { | ||
typeName = 'number'; | ||
} | ||
typeName = 'enum'; | ||
} else if (typeName === 'arrayOf') { | ||
@@ -70,0 +62,0 @@ if (type.value.name === 'shape') { |
@@ -17,2 +17,4 @@ 'use strict'; | ||
// These props are used to test react-doc-gen, but they only need to be mocked | ||
/* eslint-disable react/no-unused-prop-types */ | ||
var propTypes = { | ||
@@ -44,2 +46,3 @@ /** | ||
*/ | ||
// eslint-disable-next-line react/forbid-prop-types | ||
array: _propTypes2.default.array, | ||
@@ -70,2 +73,3 @@ /** | ||
}; | ||
/* eslint-enable react/no-unused-prop-types */ | ||
@@ -72,0 +76,0 @@ var MockComponent = function MockComponent(props) { |
{ | ||
"name": "terra-props-table", | ||
"main": "lib/PropsTable.js", | ||
"version": "2.13.0", | ||
"version": "2.14.0", | ||
"description": "terra-props-table", | ||
@@ -37,3 +37,3 @@ "repository": { | ||
"react-docgen": "^2.15.0", | ||
"terra-markdown": "^2.10.0" | ||
"terra-markdown": "^2.11.0" | ||
}, | ||
@@ -40,0 +40,0 @@ "scripts": { |
@@ -29,10 +29,4 @@ /* eslint-disable import/no-extraneous-dependencies */ | ||
// Pull the first value off and use that as type. | ||
// This assumes all enumerable values are the same type. | ||
if (typeName === 'enum') { | ||
if (isNaN(type.value[0].value)) { | ||
typeName = typeof type.value[0].value; | ||
} else { | ||
typeName = 'number'; | ||
} | ||
typeName = 'enum'; | ||
} else if (typeName === 'arrayOf') { | ||
@@ -46,4 +40,7 @@ if (type.value.name === 'shape') { | ||
const options = type.value.map((option) => { | ||
const name = option.name === 'shape' ? (<span key={option.value}> an object structured like: | ||
<pre className={cx('props-table-pre')}> {formatShape(option.value)} </pre></span>) : (<span key={option.name}> {option.name}</span>); | ||
const name = option.name === 'shape' ? (( | ||
<span key={option.value}> an object structured like: | ||
<pre className={cx('props-table-pre')}> {formatShape(option.value)} </pre> | ||
</span> | ||
)) : (<span key={option.name}> {option.name}</span>); | ||
return name; | ||
@@ -50,0 +47,0 @@ }); |
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
// These props are used to test react-doc-gen, but they only need to be mocked | ||
/* eslint-disable react/no-unused-prop-types */ | ||
const propTypes = { | ||
@@ -30,2 +31,3 @@ /** | ||
*/ | ||
// eslint-disable-next-line react/forbid-prop-types | ||
array: PropTypes.array, | ||
@@ -60,2 +62,3 @@ /** | ||
}; | ||
/* eslint-enable react/no-unused-prop-types */ | ||
@@ -62,0 +65,0 @@ const MockComponent = props => ( |
@@ -16,17 +16,26 @@ const generateMarkdown = require('../../bin/generateMarkdown/generateMarkdown'); | ||
it('should generate a markdown table', () => { | ||
const validInput = { description: '', | ||
const validInput = { | ||
description: '', | ||
methods: [], | ||
props: | ||
{ children: | ||
{ type: { name: 'string', value: 'asdf' }, | ||
{ | ||
children: | ||
{ | ||
type: { name: 'string', value: 'asdf' }, | ||
required: true, | ||
description: 'The component that will be wrapped by i18n provider.' }, | ||
description: 'The component that will be wrapped by i18n provider.', | ||
}, | ||
locale: | ||
{ type: { name: 'string', value: 'asdf' }, | ||
{ | ||
type: { name: 'string', value: 'asdf' }, | ||
required: true, | ||
description: 'The locale name.' }, | ||
description: 'The locale name.', | ||
}, | ||
messages: | ||
{ type: { name: 'string', value: 'asdf' }, | ||
{ | ||
type: { name: 'string', value: 'asdf' }, | ||
required: true, | ||
description: 'Translations messages object.' } }, | ||
description: 'Translations messages object.', | ||
}, | ||
}, | ||
}; | ||
@@ -33,0 +42,0 @@ |
@@ -6,3 +6,5 @@ const generatePropRow = require('../../bin/generateMarkdown/generatePropRow'); | ||
const propName = 'children'; | ||
const prop = { type: { name: 'node' }, required: true, defaultValue: { value: 'center' }, description: 'The component(s) that will be wrapped by `<Base />`.' }; | ||
const prop = { | ||
type: { name: 'node' }, required: true, defaultValue: { value: 'center' }, description: 'The component(s) that will be wrapped by `<Base />`.', | ||
}; | ||
@@ -51,3 +53,5 @@ expect(generatePropRow(propName, prop)).toMatchSnapshot(); | ||
const propName = ''; | ||
const prop = { type: { name: 'node' }, required: true, defaultValue: { value: 'center' }, description: 'The component(s) that will be wrapped by `<Base />`.' }; | ||
const prop = { | ||
type: { name: 'node' }, required: true, defaultValue: { value: 'center' }, description: 'The component(s) that will be wrapped by `<Base />`.', | ||
}; | ||
@@ -62,3 +66,5 @@ expect(generatePropRow(propName, prop)).toMatchSnapshot(); | ||
const propName = null; | ||
const prop = { type: { name: 'node' }, required: true, defaultValue: { value: 'center' }, description: 'The component(s) that will be wrapped by `<Base />`.' }; | ||
const prop = { | ||
type: { name: 'node' }, required: true, defaultValue: { value: 'center' }, description: 'The component(s) that will be wrapped by `<Base />`.', | ||
}; | ||
@@ -72,3 +78,5 @@ expect(generatePropRow(propName, prop)).toMatchSnapshot(); | ||
let propName; | ||
const prop = { type: { name: 'node' }, required: true, defaultValue: { value: 'center' }, description: 'The component(s) that will be wrapped by `<Base />`.' }; | ||
const prop = { | ||
type: { name: 'node' }, required: true, defaultValue: { value: 'center' }, description: 'The component(s) that will be wrapped by `<Base />`.', | ||
}; | ||
@@ -75,0 +83,0 @@ expect(generatePropRow(propName, prop)).toMatchSnapshot(); |
@@ -5,14 +5,22 @@ const generateProps = require('../../bin/generateMarkdown/generateProps'); | ||
it('should return a props markdown table', () => { | ||
const props = { children: | ||
{ type: { name: 'node' }, | ||
const props = { | ||
children: | ||
{ | ||
type: { name: 'node' }, | ||
required: true, | ||
description: 'The component that will be wrapped by i18n provider.' }, | ||
description: 'The component that will be wrapped by i18n provider.', | ||
}, | ||
locale: | ||
{ type: { name: 'string' }, | ||
{ | ||
type: { name: 'string' }, | ||
required: true, | ||
description: 'The locale name.' }, | ||
description: 'The locale name.', | ||
}, | ||
messages: | ||
{ type: { name: 'object' }, | ||
{ | ||
type: { name: 'object' }, | ||
required: true, | ||
description: 'Translations messages object.' } }; | ||
description: 'Translations messages object.', | ||
}, | ||
}; | ||
@@ -19,0 +27,0 @@ expect(generateProps(props)).toMatchSnapshot(); |
@@ -18,8 +18,9 @@ const generatePropType = require('../../bin/generateMarkdown/generatePropType'); | ||
const enumProp = | ||
{ name: 'enum', | ||
{ | ||
name: 'enum', | ||
value: | ||
[{ value: '\'default\'' }, | ||
{ value: '\'link\'' }, | ||
{ value: '\'primary\'' }, | ||
{ value: '\'secondary\'' }], | ||
{ value: '\'link\'' }, | ||
{ value: '\'primary\'' }, | ||
{ value: '\'secondary\'' }], | ||
}; | ||
@@ -31,8 +32,9 @@ expect(generatePropType(enumProp)).toEqual('`string`'); | ||
const enumProp = | ||
{ name: 'enum', | ||
{ | ||
name: 'enum', | ||
value: | ||
[{ value: '2' }, | ||
{ value: '4' }, | ||
{ value: '6' }, | ||
{ value: '3' }], | ||
{ value: '4' }, | ||
{ value: '6' }, | ||
{ value: '3' }], | ||
}; | ||
@@ -44,3 +46,4 @@ expect(generatePropType(enumProp)).toEqual('`number`'); | ||
const propType = | ||
{ name: 'union', | ||
{ | ||
name: 'union', | ||
value: | ||
@@ -54,3 +57,4 @@ [{ name: 'string' }, { name: 'number' }], | ||
const propType = | ||
{ name: 'arrayOf', | ||
{ | ||
name: 'arrayOf', | ||
value: | ||
@@ -64,3 +68,4 @@ { name: 'string' }, | ||
const propType = | ||
{ name: 'arrayOf', | ||
{ | ||
name: 'arrayOf', | ||
value: { | ||
@@ -76,3 +81,4 @@ name: 'shape', | ||
const propType = | ||
{ name: 'shape', | ||
{ | ||
name: 'shape', | ||
value: { row: 'string', icon: 'element' }, | ||
@@ -79,0 +85,0 @@ }; |
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
52499
875
Updatedterra-markdown@^2.11.0