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:
Christopher Chedeau 2016-01-27 17:08:11 -08:00 committed by facebook-github-bot-7
parent 2529179769
commit 47f863c4da
1 changed files with 9 additions and 1 deletions

View File

@ -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') {