diff options
author | Jesse Crocker <jesse@gaiagps.com> | 2017-03-01 11:15:11 -0700 |
---|---|---|
committer | Jesse Crocker <jesse@gaiagps.com> | 2017-03-01 11:15:11 -0700 |
commit | 9e8dc9a9e3e86adb9987ae69766cc42c7d9efece (patch) | |
tree | f5f0abd4d342c89ad0405d01969f9d6caecc1c90 /platform/android/scripts/generate-style-code.js | |
parent | 16fb0672e64a72b7400c321d55858b73cd5d8c3f (diff) | |
parent | f28d75dccd9bf4a7615df87faccc5cf5eff8df89 (diff) | |
download | qtlocation-mapboxgl-9e8dc9a9e3e86adb9987ae69766cc42c7d9efece.tar.gz |
Merge remote-tracking branch 'origin/master' into feature/custom-vector-source
Diffstat (limited to 'platform/android/scripts/generate-style-code.js')
-rw-r--r-- | platform/android/scripts/generate-style-code.js | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/platform/android/scripts/generate-style-code.js b/platform/android/scripts/generate-style-code.js index bcfd6bc0df..09563f3b9d 100644 --- a/platform/android/scripts/generate-style-code.js +++ b/platform/android/scripts/generate-style-code.js @@ -2,15 +2,15 @@ const fs = require('fs'); const ejs = require('ejs'); -const spec = require('mapbox-gl-style-spec').latest; +const spec = require('../../../mapbox-gl-js/src/style-spec/reference/v8'); const _ = require('lodash'); require('../../../scripts/style-code'); // Specification parsing // -//Collect layer types from spec -const layers = Object.keys(spec.layer.type.values).map((type) => { +// Collect layer types from spec +var layers = Object.keys(spec.layer.type.values).map((type) => { const layoutProperties = Object.keys(spec[`layout_${type}`]).reduce((memo, name) => { if (name !== 'visibility') { spec[`layout_${type}`][name].name = name; @@ -34,7 +34,10 @@ const layers = Object.keys(spec.layer.type.values).map((type) => { }; }); -//Process all layer properties +// XXX Remove fill-extrusion layer for now +layers = _(layers).filter(layer => layer.type != "fill-extrusion").value(); + +// Process all layer properties const layoutProperties = _(layers).map('layoutProperties').flatten().value(); const paintProperties = _(layers).map('paintProperties').flatten().value(); const allProperties = _(layoutProperties).union(paintProperties).value(); @@ -155,18 +158,21 @@ global.defaultValueJava = function(property) { * Produces documentation for property factory methods */ global.propertyFactoryMethodDoc = function (property) { - let doc = property.doc; - //Match other items in back ticks + var replaceIfPixels = function (doc) { + return doc.replace('pixels', 'density-independent pixels') + } + let doc = replaceIfPixels(property.doc); + // Match other items in back ticks doc = doc.replace(/`(.+?)`/g, function (m, symbol, offset, str) { if (str.substr(offset - 4, 3) !== 'CSS' && symbol[0].toUpperCase() != symbol[0] && _(enumProperties).filter({'name': symbol}).value().length > 0) { - //Property 'enums' + // Property 'enums' symbol = snakeCaseUpper(symbol); return '{@link Property.' + symbol + '}'; } else if( _(allProperties).filter({'name': symbol}).value().length > 0) { - //Other properties + // Other properties return '{@link PropertyFactory#' + camelizeWithLeadingLowercase(symbol) + '}'; } else { - //Left overs + // Left overs return '`' + symbol + '`'; } }); @@ -193,25 +199,33 @@ global.propertyValueDoc = function (property, value) { return 'is equivalent to {@link Property#' + propertyValue + '}'; }); - //Match other items in back ticks + // Match other items in back ticks doc = doc.replace(/`(.+?)`/g, function (m, symbol, offset, str) { if ('values' in property && Object.keys(property.values).indexOf(symbol) !== -1) { - //Property values + // Property values propertyValue = snakeCaseUpper(property.name) + '_' + snakeCaseUpper(symbol); console.log("Transforming", symbol, propertyValue); return '{@link Property#' + `${propertyValue}` + '}'; } else if (str.substr(offset - 4, 3) !== 'CSS' && symbol[0].toUpperCase() != symbol[0]) { - //Property 'enums' + // Property 'enums' symbol = snakeCaseUpper(symbol); return '{@link ' + symbol + '}'; } else { - //Left overs + // Left overs return symbol } }); return doc; }; +global.supportsZoomFunction = function (property) { + return property['zoom-function'] === true; +}; + +global.supportsPropertyFunction = function (property) { + return property['property-function'] === true; +}; + // Template processing // // Java + JNI Layers (Peer model) @@ -242,7 +256,7 @@ writeIfModified( enumPropertyJavaTemplate({properties: enumProperties}) ); -//De-duplicate enum properties before processing jni property templates +// De-duplicate enum properties before processing jni property templates const enumPropertiesDeDup = _(enumProperties).uniqBy(global.propertyNativeType).value(); // JNI Enum property conversion templates |