Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
iOS code gen updates for enum values docs
Browse files Browse the repository at this point in the history
  • Loading branch information
incanus committed Sep 29, 2016
1 parent 66557b2 commit e9be66b
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 27 deletions.
6 changes: 3 additions & 3 deletions platform/darwin/scripts/generate-style-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ global.testHelperMessage = function (property, layerType, isFunction) {
return 'testString' + fnSuffix;
case 'enum':
let objCType = `${prefix}${camelize(layerType)}${suffix}${camelize(property.name)}`;
let objCEnum = `${objCType}${camelize(property.values[property.values.length-1])}`;
let objCEnum = `${objCType}${camelize(Object.keys(property.values)[Object.keys(property.values).length-1])}`;
return `testEnum${fnSuffix}:${objCEnum} type:@encode(${objCType})`;
case 'color':
return 'testColor' + fnSuffix;
Expand All @@ -79,7 +79,7 @@ global.testHelperMessage = function (property, layerType, isFunction) {

global.propertyDoc = function (property, layerType) {
let doc = property.doc.replace(/`(.+?)`/g, function (m, symbol, offset, str) {
if ('values' in property && property.values.indexOf(symbol) !== -1) {
if ('values' in property && Object.keys(property.values).indexOf(symbol) !== -1) {
let objCType = `${prefix}${camelize(layerType)}${suffix}${camelize(property.name)}`;
return '`' + `${objCType}${camelize(symbol)}` + '`';
}
Expand Down Expand Up @@ -299,7 +299,7 @@ const layerH = ejs.compile(fs.readFileSync('platform/darwin/src/MGLStyleLayer.h.
const layerM = ejs.compile(fs.readFileSync('platform/darwin/src/MGLStyleLayer.mm.ejs', 'utf8'), { strict: true});
const testLayers = ejs.compile(fs.readFileSync('platform/darwin/src/MGLRuntimeStylingTests.m.ejs', 'utf8'), { strict: true});

const layers = spec.layer.type.values.map((type) => {
const 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;
Expand Down
16 changes: 14 additions & 2 deletions platform/darwin/src/MGLCircleStyleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,24 @@
NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, MGLCircleStyleLayerCircleTranslateAnchor) {
/**
The circle is translated relative to the map.
*/
MGLCircleStyleLayerCircleTranslateAnchorMap,
/**
The circle is translated relative to the viewport.
*/
MGLCircleStyleLayerCircleTranslateAnchorViewport,
};

typedef NS_ENUM(NSUInteger, MGLCircleStyleLayerCirclePitchScale) {
/**
Circles are scaled according to their apparent distance to the camera.
*/
MGLCircleStyleLayerCirclePitchScaleMap,
/**
Circles are not scaled.
*/
MGLCircleStyleLayerCirclePitchScaleViewport,
};

Expand Down Expand Up @@ -87,7 +99,7 @@ typedef NS_ENUM(NSUInteger, MGLCircleStyleLayerCirclePitchScale) {
@property (nonatomic, null_resettable) id <MGLStyleAttributeValue> circleTranslate;

/**
Control whether the translation is relative to the map (north) or viewport (screen)
Controls the translation reference point.
The default value of this property is an `NSValue` object containing `MGLCircleStyleLayerCircleTranslateAnchorMap`. Set this property to `nil` to reset it to the default value.
Expand All @@ -96,7 +108,7 @@ typedef NS_ENUM(NSUInteger, MGLCircleStyleLayerCirclePitchScale) {
@property (nonatomic, null_resettable) id <MGLStyleAttributeValue> circleTranslateAnchor;

/**
Controls the scaling behavior of the circle when the map is pitched. The value `MGLCircleStyleLayerCirclePitchScaleMap` scales circles according to their apparent distance to the camera. The value `MGLCircleStyleLayerCirclePitchScaleViewport` results in no pitch-related scaling.
Controls the scaling behavior of the circle when the map is pitched.
The default value of this property is an `NSValue` object containing `MGLCircleStyleLayerCirclePitchScaleMap`. Set this property to `nil` to reset it to the default value.
*/
Expand Down
14 changes: 10 additions & 4 deletions platform/darwin/src/MGLFillStyleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, MGLFillStyleLayerFillTranslateAnchor) {
/**
The fill is translated relative to the map.
*/
MGLFillStyleLayerFillTranslateAnchorMap,
/**
The fill is translated relative to the viewport.
*/
MGLFillStyleLayerFillTranslateAnchorViewport,
};

Expand Down Expand Up @@ -41,15 +47,15 @@ typedef NS_ENUM(NSUInteger, MGLFillStyleLayerFillTranslateAnchor) {
@property (nonatomic, null_resettable) id <MGLStyleAttributeValue> fillAntialias;

/**
The opacity of the entire fill layer. In contrast to the fill-color, this value will also affect the 1pt stroke around the fill, if the stroke is used.
The opacity of the entire fill layer. In contrast to the `fillColor`, this value will also affect the 1pt stroke around the fill, if the stroke is used.
The default value of this property is an `NSNumber` object containing the float `1`. Set this property to `nil` to reset it to the default value.
*/
@property (nonatomic, null_resettable) id <MGLStyleAttributeValue> fillOpacity;

#if TARGET_OS_IPHONE
/**
The color of the filled part of this layer. This color can be specified as rgba with an alpha component and the color's opacity will not affect the opacity of the 1pt stroke, if it is used.
The color of the filled part of this layer. This color can be specified as `rgba` with an alpha component and the color's opacity will not affect the opacity of the 1pt stroke, if it is used.
The default value of this property is `UIColor.blackColor`. Set this property to `nil` to reset it to the default value.
Expand All @@ -58,7 +64,7 @@ typedef NS_ENUM(NSUInteger, MGLFillStyleLayerFillTranslateAnchor) {
@property (nonatomic, null_resettable) id <MGLStyleAttributeValue> fillColor;
#else
/**
The color of the filled part of this layer. This color can be specified as rgba with an alpha component and the color's opacity will not affect the opacity of the 1pt stroke, if it is used.
The color of the filled part of this layer. This color can be specified as `rgba` with an alpha component and the color's opacity will not affect the opacity of the 1pt stroke, if it is used.
The default value of this property is `NSColor.blackColor`. Set this property to `nil` to reset it to the default value.
Expand All @@ -84,7 +90,7 @@ typedef NS_ENUM(NSUInteger, MGLFillStyleLayerFillTranslateAnchor) {
@property (nonatomic, null_resettable) id <MGLStyleAttributeValue> fillTranslate;

/**
Control whether the translation is relative to the map (north) or viewport (screen)
Controls the translation reference point.
The default value of this property is an `NSValue` object containing `MGLFillStyleLayerFillTranslateAnchorMap`. Set this property to `nil` to reset it to the default value.
Expand Down
26 changes: 25 additions & 1 deletion platform/darwin/src/MGLLineStyleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,43 @@
NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, MGLLineStyleLayerLineCap) {
/**
A cap with a squared-off end which is drawn to the exact endpoint of the line.
*/
MGLLineStyleLayerLineCapButt,
/**
A cap with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line.
*/
MGLLineStyleLayerLineCapRound,
/**
A cap with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width.
*/
MGLLineStyleLayerLineCapSquare,
};

typedef NS_ENUM(NSUInteger, MGLLineStyleLayerLineJoin) {
/**
A join with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width.
*/
MGLLineStyleLayerLineJoinBevel,
/**
A join with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line.
*/
MGLLineStyleLayerLineJoinRound,
/**
A join with a sharp, angled corner which is drawn with the outer sides beyond the endpoint of the path until they meet.
*/
MGLLineStyleLayerLineJoinMiter,
};

typedef NS_ENUM(NSUInteger, MGLLineStyleLayerLineTranslateAnchor) {
/**
The line is translated relative to the map.
*/
MGLLineStyleLayerLineTranslateAnchorMap,
/**
The line is translated relative to the viewport.
*/
MGLLineStyleLayerLineTranslateAnchorViewport,
};

Expand Down Expand Up @@ -116,7 +140,7 @@ typedef NS_ENUM(NSUInteger, MGLLineStyleLayerLineTranslateAnchor) {
@property (nonatomic, null_resettable) id <MGLStyleAttributeValue> lineTranslate;

/**
Control whether the translation is relative to the map (north) or viewport (screen)
Controls the translation reference point.
The default value of this property is an `NSValue` object containing `MGLLineStyleLayerLineTranslateAnchorMap`. Set this property to `nil` to reset it to the default value.
Expand Down
10 changes: 8 additions & 2 deletions platform/darwin/src/MGLStyleLayer.h.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ NS_ASSUME_NONNULL_BEGIN
<% for (const property of layoutProperties) { -%>
<% if (property.type == "enum") { -%>
typedef NS_ENUM(NSUInteger, MGL<%- camelize(type) %>StyleLayer<%- camelize(property.name) %>) {
<% for (const value of property.values) { -%>
<% for (const value in property.values) { -%>
/**
<%- propertyDoc(property.values[value], type) %>
*/
MGL<%- camelize(type) %>StyleLayer<%- camelize(property.name) %><%- camelize(value) %>,
<% } -%>
};
Expand All @@ -26,7 +29,10 @@ typedef NS_ENUM(NSUInteger, MGL<%- camelize(type) %>StyleLayer<%- camelize(prope
<% for (const property of paintProperties) { -%>
<% if (property.type == "enum") { -%>
typedef NS_ENUM(NSUInteger, MGL<%- camelize(type) %>StyleLayer<%- camelize(property.name) %>) {
<% for (const value of property.values) { -%>
<% for (const value in property.values) { -%>
/**
<%- propertyDoc(property.values[value], type) %>
*/
MGL<%- camelize(type) %>StyleLayer<%- camelize(property.name) %><%- camelize(value) %>,
<% } -%>
};
Expand Down
Loading

0 comments on commit e9be66b

Please sign in to comment.