Skip to content

Commit

Permalink
Address review comments:
Browse files Browse the repository at this point in the history
- "FormattedExpression" -> "FormatExpression" (reasoning: the expression itself is a verb, the result is a noun)
- Remove dead/debug code
- Add comments
  • Loading branch information
ChrisLoer committed Aug 1, 2018
1 parent 8e7fd21 commit cc46fea
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 10 deletions.
1 change: 0 additions & 1 deletion build/generate-style-code.js
Expand Up @@ -5,7 +5,6 @@ const fs = require('fs');
const ejs = require('ejs');
const spec = require('../src/style-spec/reference/v8');
const Color = require('../src/style-spec/util/color');
const {Formatted} = require('../src/style-spec/expression/definitions/formatted');

global.camelize = function (str) {
return str.replace(/(?:^|-)(.)/g, function (_, x) {
Expand Down
4 changes: 2 additions & 2 deletions src/style-spec/expression/definitions/formatted.js
Expand Up @@ -50,7 +50,7 @@ type FormattedSectionExpression = {
font: Expression | null;
}

export class FormattedExpression implements Expression {
export class FormatExpression implements Expression {
type: Type;
sections: Array<FormattedSectionExpression>;

Expand Down Expand Up @@ -94,7 +94,7 @@ export class FormattedExpression implements Expression {
sections.push({text, scale, font});
}

return new FormattedExpression(sections);
return new FormatExpression(sections);
}

evaluate(ctx: EvaluationContext) {
Expand Down
4 changes: 2 additions & 2 deletions src/style-spec/expression/definitions/index.js
Expand Up @@ -26,7 +26,7 @@ import {
GreaterThanOrEqual
} from './comparison';
import { CollatorExpression } from './collator';
import { Formatted, FormattedExpression } from './formatted';
import { Formatted, FormatExpression } from './formatted';
import Length from './length';

import type { Type } from '../types';
Expand All @@ -47,7 +47,7 @@ const expressions: ExpressionRegistry = {
'case': Case,
'coalesce': Coalesce,
'collator': CollatorExpression,
'format': FormattedExpression,
'format': FormatExpression,
'interpolate': Interpolate,
'length': Length,
'let': Let,
Expand Down
3 changes: 0 additions & 3 deletions src/style-spec/validate/validate.js
Expand Up @@ -69,9 +69,6 @@ export default function validate(options) {
const valid = validateObject(extend({}, options, {
valueSpec: valueSpec.type ? styleSpec[valueSpec.type] : valueSpec
}));
if (!valid) {
console.log("not valid");
}
return valid;
}
}
2 changes: 1 addition & 1 deletion src/symbol/shaping.js
Expand Up @@ -44,7 +44,7 @@ type TextJustify = 'left' | 'center' | 'right';

class TaggedString {
text: string;
sectionIndex: Array<number>
sectionIndex: Array<number> // maps each character in 'text' to its corresponding entry in 'sections'
sections: Array<{ scale: number, fontStack: string }>

constructor() {
Expand Down
1 change: 0 additions & 1 deletion src/symbol/transform_text.js
Expand Up @@ -24,7 +24,6 @@ function transformText(text: string, layer: SymbolStyleLayer, feature: Feature)

export default function(text: string | Formatted, layer: SymbolStyleLayer, feature: Feature) {
if (text instanceof Formatted) {
// OK to transform in place?
text.sections.forEach(section => {
section.text = transformText(section.text, layer, feature);
});
Expand Down

0 comments on commit cc46fea

Please sign in to comment.