update style generation code for new style spec enum values docs#6508
Conversation
|
@incanus, thanks for your PR! By analyzing this pull request, we identified @jfirebaugh, @mikemorris and @yhahn to be potential reviewers. |
|
Only thing I'm not crazy about with e9be66b is failure to fully get typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerIconRotationAlignment) {
/**
When `symbolPlacement` is set to `point`, aligns icons east-west. When `symbolPlacement` is set to `line`, aligns icon x-axes with the line.
*/
MGLSymbolStyleLayerIconRotationAlignmentMap,
/**
Produces icons whose x-axes are aligned with the x-axis of the viewport, regardless of the value of `symbolPlacement`.
*/
MGLSymbolStyleLayerIconRotationAlignmentViewport,
/**
When `symbolPlacement` is set to `point`, this is equivalent to `viewport`. When `symbolPlacement` is set to `line`, this is equivalent to `map`.
*/
MGLSymbolStyleLayerIconRotationAlignmentAuto,
};Note the Do we get this nitpicky? |
Yes. The existing logic is robust enough to handle values of the property currently being described (first-person values), but not enough to handle values of another property being referenced (third-person values). |
|
We can maybe detect constructions such as “x is set to y” and find candidate values accordingly. Getting this right will ensure that jazzy can autolink the referenced symbols. I think autolinking is important for enabling users to effectively navigate our documentation, which is spread out among many headers or many webpages. |
| switch (value) { | ||
| <% for (const value of property.values) { -%> | ||
| <% for (const value in property.values) { -%> | ||
| //<%- property.values[value].doc %> |
There was a problem hiding this comment.
This is a left-over comment?
|
@ivovandongen Curious about your feedback again now after 0c8cc78 and c58f90a. |
|
Working on some final Darwin-side |
| NS_ASSUME_NONNULL_BEGIN | ||
|
|
||
| /** | ||
| Controls the translation reference point. |
There was a problem hiding this comment.
Since the enums are on a different page than the properties that use them, perhaps this documentation could mention those properties.
There was a problem hiding this comment.
For example:
Used by the
MGLCircleStyleLayer.circleTranslateAnchorproperty.
| */ | ||
| typedef NS_ENUM(NSUInteger, MGLSymbolStyleLayerIconRotationAlignment) { | ||
| /** | ||
| When `symbolPlacement` is set to `point`, aligns icons east-west. When `symbolPlacement` is set to `line`, aligns icon x-axes with the line. |
There was a problem hiding this comment.
Hopefully we can rely on this “x is set to y” phrase and expand y to the right enum value.
There was a problem hiding this comment.
Done pending improvements in #6508 (comment).
| The default value of this property is an `NSValue` object containing `NSEdgeInsetsZero` or `UIEdgeInsetsZero`. Set this property to `nil` to reset it to the default value. | ||
|
|
||
| This property is only applied to the style if `iconImage` is non-`nil`, and `iconTextFit` is non-`nil`, and `textField` is non-`nil`. Otherwise, it is ignored. | ||
| This property is only applied to the style if `iconImage` is non-`nil`, and `textField` is non-`nil`, and `iconTextFit` is set to an `NSValue` object containing `MGLSymbolStyleLayerIconTextFitBoth`, `MGLSymbolStyleLayerIconTextFitWidth`, or `MGLSymbolStyleLayerIconTextFitHeight`. Otherwise, it is ignored. |
| @@ -143,7 +143,7 @@ public PropertyValue<String> getFillColor() { | |||
| return (PropertyValue<String>) new PropertyValue(nativeGetFillColor()); | |||
| } | |||
| /** | |||
There was a problem hiding this comment.
Some funky indentation going on here.
|
Got the last mile of Darwin docs in e08bc5a. Formatting rules documented in |
|
@ivovandongen To build on #6508 (comment), 1325127 brings over some of the logic from Darwin where we properly format symbol names in the Before: After: Note how we go from referring to Previously, unlike on Darwin, we didn't refer to symbols as they actually appear in the Android API, which can be confusing and lose people. A few more questions about how much further we should go on this:
Note how we lost context like the fact that |
| global.propertyDoc = function (propertyName, property, layerType) { | ||
| // Match references to other property names & values. | ||
| // Requires the format 'When `foo` is set to `bar`,'. | ||
| let doc = property.doc.replace(/When `(.+?)` is set to `(.+?)`,/g, function (m, peerPropertyName, propertyValue, offset, str) { |
There was a problem hiding this comment.
Is "When" needed? If so, can it be case-insensitive using the i flag? Is the comma needed? I think we should try to avoid coupling too tightly to how things are worded right now, because the style spec repo doesn't have any documentation that would inform a contributor that they need to worry about these details.
There was a problem hiding this comment.
I tried without the When and comma, but ran into issues that crossed sentence boundaries. I can try to refine it further.
There was a problem hiding this comment.
If the +? is matching too greedily for some reason, you can replace . with:
[^`]
There was a problem hiding this comment.
Specifically I tried things like .[^\.]+? in the regex to avoid sentence-spanning over periods. Will take another crack.
There was a problem hiding this comment.
> "When `foo` is set to `bar`, `baz` is set to `boo`.".match(/`(.+?)` is set to `(.+?)`/g)
[ "`foo` is set to `bar`", "`baz` is set to `boo`" ]
> "When `foo` is set to `bar`, `baz` becomes `boo`. When `moo` is set to `goo`, `oog` becomes `oop`.".match(/`(.+?)` is set to `(.+?)`/g)
[ "`foo` is set to `bar`", "`baz` becomes `boo`. When `moo` is set to `goo`" ]
> "When `foo` is set to `bar`, `baz` becomes `boo`. When `moo` is set to `goo`, `oog` becomes `oop`.".match(/`([^`]+?)` is set to `([^`]+?)`/g)
[ "`foo` is set to `bar`", "`moo` is set to `goo`" ]
How about a |
| /** | ||
| * Layer visibility | ||
| */ | ||
| public static final String VISIBLE = "visible"; |
There was a problem hiding this comment.
@incanus If you document in this way, it is only applied to the first constant VISIBLE. The // I used don't show up at all in javadoc. I use those more as you'd use #pragma mark, to organize the source, not to document. If you apply javadoc, you need to do it on all constants I'm afraid.
| /** | ||
| * `line-cap`: The display of line endings. | ||
| */ | ||
| //A cap with a squared-off end which is drawn to the exact endpoint of the line. |
There was a problem hiding this comment.
Same thing here. I would invert this, start the header with // and the individual comments with /** */
http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#CHDDIECH |
|
Still pushing on Android finishing work here per discussion with @ivovandongen and more learnin' in the JavaDocs department. |
|
The JavaDoc stuff gets tricky since we don't know the argument quantity or types, which only lets us do something like |
|
I'm going to flag some things above in response to comments as tail work. The main goal here is to get use of |
Tail work per #6508 (comment). |
Adds `doc` property to all enum `values`, moving them from JSON arrays to objects. Downstream mobile SDK work in mapbox/mapbox-gl-native#6508. Downstream Studio work in mapbox/studio#7765. Fixes a typo in `icon-text-fit`. Also updates validation, docs generation, and tests.
|
The Qt build failed; looks like a spurious core test failure: |
|
Restarted tests and all now pass. Working on merge now. |


Downstream work for mapbox/mapbox-gl-style-spec#510.
/cc @1ec5 @frederoni @ivovandongen