diff options
author | David Clark <dclark@mapbox.com> | 2016-09-24 07:39:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-24 07:39:56 -0700 |
commit | bf18c330406a44b36218aab20a11b74f0151f6e7 (patch) | |
tree | ab8fe1b87d9bca960e585ab07ddf7759da5b3a28 | |
parent | b9fafbc2ee34f09c2f90dcf3407e959b1bd4124c (diff) | |
download | qtlocation-mapboxgl-bf18c330406a44b36218aab20a11b74f0151f6e7.tar.gz |
[ios, macos] Doc gen handles arrays as required property values (#6448)
-rw-r--r-- | platform/darwin/scripts/generate-style-code.js | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js index 023bf648c6..33ac014295 100644 --- a/platform/darwin/scripts/generate-style-code.js +++ b/platform/darwin/scripts/generate-style-code.js @@ -107,7 +107,7 @@ global.propertyReqs = function (property, layoutPropertiesByName, type) { return '`' + camelizeWithLeadingLowercase(req['!']) + '` is set to `nil`'; } else { let name = Object.keys(req)[0]; - return '`' + camelizeWithLeadingLowercase(name) + '` is set to ' + describeValue(req[Object.keys(req)[0]], layoutPropertiesByName[name], type); + return '`' + camelizeWithLeadingLowercase(name) + '` is set to ' + describeValue(req[name], layoutPropertiesByName[name], type); } }).join(', and ') + '. Otherwise, it is ignored.'; }; @@ -131,8 +131,21 @@ global.describeValue = function (value, property, layerType) { case 'string': return 'the string `' + value + '`'; case 'enum': - let objCType = `${prefix}${camelize(layerType)}${suffix}${camelize(property.name)}`; - return 'an `NSValue` object containing `' + `${objCType}${camelize(value)}` + '`'; + let displayValue; + if (Array.isArray(value)) { + let separator = (value.length === 2) ? ' ' : ', '; + displayValue = value.map((possibleValue, i) => { + let conjunction = ''; + if (value.length === 2 && i === 0) conjunction = 'either '; + if (i === value.length - 1) conjunction = 'or '; + let objCType = `${prefix}${camelize(layerType)}${suffix}${camelize(property.name)}`; + return `${conjunction}\`${objCType}${camelize(possibleValue)}\``; + }).join(separator); + } else { + let objCType = `${prefix}${camelize(layerType)}${suffix}${camelize(property.name)}`; + displayValue = `\`${objCType}${camelize(value)}\``; + } + return `an \`NSValue\` object containing ${displayValue}`; case 'color': let color = parseColor(value); if (!color) { @@ -182,14 +195,14 @@ global.initLayerIdentifierOnly = function (layerType) { global.initLayer = function (layerType) { if (layerType == "background") { - return `_layer = new mbgl::style::${camelize(layerType)}Layer(layerIdentifier.UTF8String);` + return `_layer = new mbgl::style::${camelize(layerType)}Layer(layerIdentifier.UTF8String);` } else { return `_layer = new mbgl::style::${camelize(layerType)}Layer(layerIdentifier.UTF8String, source.sourceIdentifier.UTF8String);` } } global.initLayerWithSourceLayer = function(layerType) { - return `_layer = new mbgl::style::${camelize(layerType)}Layer(layerIdentifier.UTF8String, source.sourceIdentifier.UTF8String);` + return `_layer = new mbgl::style::${camelize(layerType)}Layer(layerIdentifier.UTF8String, source.sourceIdentifier.UTF8String);` } global.setSourceLayer = function() { |