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

Document ranges of style properties #11018

Merged
merged 2 commits into from
Jan 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion platform/darwin/docs/guides/For Style Authors.md.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ In style specification | Method, function, or predicate type | Format string syn
<% if (macOS) { -%>
`rgb` | `+[NSColor colorWithCalibratedRed:green:blue:alpha:]` |
`rgba` | `+[NSColor colorWithCalibratedRed:green:blue:alpha:]` |
<% } else { %>
<% } else { -%>
`rgb` | `+[UIColor colorWithRed:green:blue:alpha:]` |
`rgba` | `+[UIColor colorWithRed:green:blue:alpha:]` |
<% } -%>
Expand Down
26 changes: 20 additions & 6 deletions platform/darwin/scripts/generate-style-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand All @@ -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('`, `') + '`';
}
Expand All @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions platform/darwin/src/MGLBackgroundStyleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ which it is added.
The opacity at which the background will be drawn.

The default value of this property is an expression that evaluates to the float
`1`. Set this property to `nil` to reset it to the default value.
1. Set this property to `nil` to reset it to the default value.

You can set this property to an expression containing any of the following:

* Constant numeric values
* Constant numeric values between 0 and 1 inclusive
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
Expand Down
18 changes: 9 additions & 9 deletions platform/darwin/src/MGLCircleStyleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ MGL_EXPORT
full opacity.

The default value of this property is an expression that evaluates to the float
`0`. Set this property to `nil` to reset it to the default value.
0. Set this property to `nil` to reset it to the default value.

You can set this property to an expression containing any of the following:

Expand Down Expand Up @@ -165,11 +165,11 @@ MGL_EXPORT
The opacity at which the circle will be drawn.

The default value of this property is an expression that evaluates to the float
`1`. Set this property to `nil` to reset it to the default value.
1. Set this property to `nil` to reset it to the default value.

You can set this property to an expression containing any of the following:

* Constant numeric values
* Constant numeric values between 0 and 1 inclusive
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
Expand Down Expand Up @@ -214,11 +214,11 @@ MGL_EXPORT
This property is measured in points.

The default value of this property is an expression that evaluates to the float
`5`. Set this property to `nil` to reset it to the default value.
5. Set this property to `nil` to reset it to the default value.

You can set this property to an expression containing any of the following:

* Constant numeric values
* Constant numeric values no less than 0
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
Expand Down Expand Up @@ -293,11 +293,11 @@ MGL_EXPORT
The opacity of the circle's stroke.

The default value of this property is an expression that evaluates to the float
`1`. Set this property to `nil` to reset it to the default value.
1. Set this property to `nil` to reset it to the default value.

You can set this property to an expression containing any of the following:

* Constant numeric values
* Constant numeric values between 0 and 1 inclusive
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
Expand All @@ -320,11 +320,11 @@ MGL_EXPORT
This property is measured in points.

The default value of this property is an expression that evaluates to the float
`0`. Set this property to `nil` to reset it to the default value.
0. Set this property to `nil` to reset it to the default value.

You can set this property to an expression containing any of the following:

* Constant numeric values
* Constant numeric values no less than 0
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
Expand Down
12 changes: 6 additions & 6 deletions platform/darwin/src/MGLFillExtrusionStyleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ MGL_EXPORT
This property is measured in meters.

The default value of this property is an expression that evaluates to the float
`0`. Set this property to `nil` to reset it to the default value.
0. Set this property to `nil` to reset it to the default value.

This property is only applied to the style if `fillExtrusionHeight` is
non-`nil`. Otherwise, it is ignored.

You can set this property to an expression containing any of the following:

* Constant numeric values
* Constant numeric values no less than 0
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
Expand Down Expand Up @@ -137,11 +137,11 @@ MGL_EXPORT
This property is measured in meters.

The default value of this property is an expression that evaluates to the float
`0`. Set this property to `nil` to reset it to the default value.
0. Set this property to `nil` to reset it to the default value.

You can set this property to an expression containing any of the following:

* Constant numeric values
* Constant numeric values no less than 0
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
Expand All @@ -162,11 +162,11 @@ MGL_EXPORT
per-layer, not per-feature, basis, and data-driven styling is not available.

The default value of this property is an expression that evaluates to the float
`1`. Set this property to `nil` to reset it to the default value.
1. Set this property to `nil` to reset it to the default value.

You can set this property to an expression containing any of the following:

* Constant numeric values
* Constant numeric values between 0 and 1 inclusive
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
Expand Down
4 changes: 2 additions & 2 deletions platform/darwin/src/MGLFillStyleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ MGL_EXPORT
value will also affect the 1pt stroke around the fill, if the stroke is used.

The default value of this property is an expression that evaluates to the float
`1`. Set this property to `nil` to reset it to the default value.
1. Set this property to `nil` to reset it to the default value.

You can set this property to an expression containing any of the following:

* Constant numeric values
* Constant numeric values between 0 and 1 inclusive
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
Expand Down
8 changes: 4 additions & 4 deletions platform/darwin/src/MGLHillshadeStyleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ MGL_EXPORT
Intensity of the hillshade

The default value of this property is an expression that evaluates to the float
`0.5`. Set this property to `nil` to reset it to the default value.
0.5. Set this property to `nil` to reset it to the default value.

You can set this property to an expression containing any of the following:

* Constant numeric values
* Constant numeric values between 0 and 1 inclusive
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
Expand Down Expand Up @@ -187,11 +187,11 @@ MGL_EXPORT
`hillshadeIlluminationAnchor` is set to `MGLHillshadeIlluminationAnchorMap`.

The default value of this property is an expression that evaluates to the float
`335`. Set this property to `nil` to reset it to the default value.
335. Set this property to `nil` to reset it to the default value.

You can set this property to an expression containing any of the following:

* Constant numeric values
* Constant numeric values between 0 and 359 inclusive
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
Expand Down
4 changes: 2 additions & 2 deletions platform/darwin/src/MGLLight.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ MGL_EXPORT
more extreme contrast.

The default value of this property is an expression that evaluates to the float
`0.5`.
0.5.

You can set this property to an expression containing any of the following:

* Constant numeric values
* Constant numeric values between 0 and 1 inclusive
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
Expand Down
24 changes: 12 additions & 12 deletions platform/darwin/src/MGLLineStyleLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ MGL_EXPORT
Used to automatically convert miter joins to bevel joins for sharp angles.

The default value of this property is an expression that evaluates to the float
`2`. Set this property to `nil` to reset it to the default value.
2. Set this property to `nil` to reset it to the default value.

This property is only applied to the style if `lineJoin` is set to an
expression that evaluates to `miter`. Otherwise, it is ignored.
Expand All @@ -201,7 +201,7 @@ MGL_EXPORT
Used to automatically convert round joins to miter joins for shallow angles.

The default value of this property is an expression that evaluates to the float
`1.05`. Set this property to `nil` to reset it to the default value.
1.05. Set this property to `nil` to reset it to the default value.

This property is only applied to the style if `lineJoin` is set to an
expression that evaluates to `round`. Otherwise, it is ignored.
Expand All @@ -227,11 +227,11 @@ MGL_EXPORT
This property is measured in points.

The default value of this property is an expression that evaluates to the float
`0`. Set this property to `nil` to reset it to the default value.
0. Set this property to `nil` to reset it to the default value.

You can set this property to an expression containing any of the following:

* Constant numeric values
* Constant numeric values no less than 0
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
Expand Down Expand Up @@ -291,7 +291,7 @@ MGL_EXPORT

You can set this property to an expression containing any of the following:

* Constant array values
* Constant array values no less than 0
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
Expand Down Expand Up @@ -319,11 +319,11 @@ MGL_EXPORT
This property is measured in points.

The default value of this property is an expression that evaluates to the float
`0`. Set this property to `nil` to reset it to the default value.
0. Set this property to `nil` to reset it to the default value.

You can set this property to an expression containing any of the following:

* Constant numeric values
* Constant numeric values no less than 0
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
Expand All @@ -348,7 +348,7 @@ MGL_EXPORT
This property is measured in points.

The default value of this property is an expression that evaluates to the float
`0`. Set this property to `nil` to reset it to the default value.
0. Set this property to `nil` to reset it to the default value.

You can set this property to an expression containing any of the following:

Expand All @@ -372,11 +372,11 @@ MGL_EXPORT
The opacity at which the line will be drawn.

The default value of this property is an expression that evaluates to the float
`1`. Set this property to `nil` to reset it to the default value.
1. Set this property to `nil` to reset it to the default value.

You can set this property to an expression containing any of the following:

* Constant numeric values
* Constant numeric values between 0 and 1 inclusive
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
Expand Down Expand Up @@ -518,11 +518,11 @@ MGL_EXPORT
This property is measured in points.

The default value of this property is an expression that evaluates to the float
`1`. Set this property to `nil` to reset it to the default value.
1. Set this property to `nil` to reset it to the default value.

You can set this property to an expression containing any of the following:

* Constant numeric values
* Constant numeric values no less than 0
* Predefined functions, including mathematical and string operators
* Conditional expressions
* Variable assignments and references to assigned variables
Expand Down
Loading