diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2018-01-24 00:28:06 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2018-01-26 10:42:23 -0800 |
commit | 65bab30384577c9aac88fb7b34f8877a95d86704 (patch) | |
tree | ef548dc35d30437ec3f9031f2f876c1d40e66f4d /platform/darwin/scripts/generate-style-code.js | |
parent | b38618b450a8153d0b93f9a44b78039181f6c3f9 (diff) | |
download | qtlocation-mapboxgl-65bab30384577c9aac88fb7b34f8877a95d86704.tar.gz |
[ios, macos] Documented ranges of style properties
Diffstat (limited to 'platform/darwin/scripts/generate-style-code.js')
-rwxr-xr-x | platform/darwin/scripts/generate-style-code.js | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/platform/darwin/scripts/generate-style-code.js b/platform/darwin/scripts/generate-style-code.js index a7804ac948..f919a649cb 100755 --- a/platform/darwin/scripts/generate-style-code.js +++ b/platform/darwin/scripts/generate-style-code.js @@ -300,7 +300,17 @@ global.propertyDoc = function (propertyName, property, layerType, kind) { doc += `\n\nThis attribute corresponds to the <a href="https://www.mapbox.com/mapbox-gl-style-spec/#${anchor}"><code>${property.original}</code></a> layout property in the Mapbox Style Specification.`; } doc += '\n\nYou can set this property to an expression containing any of the following:\n\n'; - doc += `* Constant ${describeType(property)} values\n`; + doc += `* Constant ${describeType(property)} values`; + if ('minimum' in property) { + if ('maximum' in property) { + doc += ` between ${formatNumber(property.minimum)} and ${formatNumber(property.maximum)} inclusive`; + } else { + doc += ` no less than ${formatNumber(property.minimum)}`; + } + } else if ('maximum' in property) { + doc += ` no greater than ${formatNumber(property.maximum)}`; + } + doc += '\n'; if (property.type === 'enum') { doc += '* Any of the following constant string values:\n'; doc += Object.keys(property.values).map(value => ' * `' + value + '`: ' + property.values[value].doc).join('\n') + '\n'; @@ -392,7 +402,7 @@ global.describeValue = function (value, property, layerType) { case 'boolean': return value ? '`YES`' : '`NO`'; case 'number': - return 'the float `' + value + '`'; + return 'the float ' + formatNumber(value); case 'string': if (value === '') { return 'the empty string'; @@ -427,7 +437,7 @@ global.describeValue = function (value, property, layerType) { if (color.r === 1 && color.g === 1 && color.b === 1 && color.a === 1) { return '`UIColor.whiteColor`'; } - return 'a `UIColor`' + ` object whose RGB value is ${color.r}, ${color.g}, ${color.b} and whose alpha value is ${color.a}`; + return 'a `UIColor`' + ` object whose RGB value is ${formatNumber(color.r)}, ${formatNumber(color.g)}, ${formatNumber(color.b)} and whose alpha value is ${formatNumber(color.a)}`; case 'array': let units = property.units || ''; if (units) { @@ -438,12 +448,12 @@ global.describeValue = function (value, property, layerType) { if (value[0] === 0 && value[1] === 0 && value[2] === 0 && value[3] === 0) { return 'an `NSValue` object containing `UIEdgeInsetsZero`'; } - return 'an `NSValue` object containing a `UIEdgeInsets` struct set to' + ` ${value[0]}${units} on the top, ${value[3]}${units} on the left, ${value[2]}${units} on the bottom, and ${value[1]}${units} on the right`; + return 'an `NSValue` object containing a `UIEdgeInsets` struct set to' + ` ${formatNumber(value[0])}${units} on the top, ${formatNumber(value[3])}${units} on the left, ${formatNumber(value[2])}${units} on the bottom, and ${formatNumber(value[1])}${units} on the right`; case 'offset': case 'translate': - return 'an `NSValue` object containing a `CGVector` struct set to' + ` ${value[0]}${units} rightward and ${value[1]}${units} downward`; + return 'an `NSValue` object containing a `CGVector` struct set to' + ` ${formatNumber(value[0])}${units} rightward and ${formatNumber(value[1])}${units} downward`; case 'position': - return 'an `MGLSphericalPosition` struct set to' + ` ${value[0]} radial, ${value[1]} azimuthal and ${value[2]} polar`; + return 'an `MGLSphericalPosition` struct set to' + ` ${formatNumber(value[0])} radial, ${formatNumber(value[1])} azimuthal and ${formatNumber(value[2])} polar`; default: return 'the array `' + value.join('`, `') + '`'; } @@ -452,6 +462,10 @@ global.describeValue = function (value, property, layerType) { } }; +global.formatNumber = function (num) { + return num.toLocaleString().replace('-', '\u2212'); +} + global.propertyDefault = function (property, layerType) { if (property.name === 'heatmap-color') { return 'an expression that evaluates to a rainbow color scale from blue to red'; |