Single quotes in enum values
Summary: This was driving me crazy :p Turns out that if the value is `'auto' /* default */`, then the docparser will not only trim the comment but also normalize the quote to double quote. This is not pretty but does the job. Closes https://github.com/facebook/react-native/pull/5509 Reviewed By: svcscm Differential Revision: D2872482 Pulled By: vjeux fb-gh-sync-id: 8ba5dad695f747f82b7680ee26bdc0792e21ea8f
This commit is contained in:
parent
2529179769
commit
47f863c4da
|
@ -20,12 +20,20 @@ var slugify = require('slugify');
|
|||
|
||||
var styleReferencePattern = /^[^.]+\.propTypes\.style$/;
|
||||
|
||||
function renderEnumValue(value) {
|
||||
// Use single quote strings even when we are given double quotes
|
||||
if (value.match(/^"(.+)"$/)) {
|
||||
return "'" + value.slice(1, -1) + "'";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function renderType(type) {
|
||||
if (type.name === 'enum') {
|
||||
if (typeof type.value === 'string') {
|
||||
return type.value;
|
||||
}
|
||||
return 'enum(' + type.value.map((v) => v.value).join(', ') + ')';
|
||||
return 'enum(' + type.value.map((v) => renderEnumValue(v.value)).join(', ') + ')';
|
||||
}
|
||||
|
||||
if (type.name === 'shape') {
|
||||
|
|
Loading…
Reference in New Issue