summaryrefslogtreecommitdiff
path: root/platform/android/scripts/generate-style-code.js
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/scripts/generate-style-code.js')
-rw-r--r--platform/android/scripts/generate-style-code.js42
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