-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Anand Thakker
committed
Aug 31, 2017
1 parent
e3d5271
commit 9ee7362
Showing
8 changed files
with
467 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,5 @@ | ||
{ | ||
"parser": "espree", | ||
"parserOptions": { | ||
"ecmaVersion": 5 | ||
}, | ||
"env": { | ||
"es6": false, | ||
"browser": true | ||
}, | ||
"globals": { | ||
"Uint8Array": true | ||
"rules": { | ||
"flowtype/require-valid-file-annotation": [0] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
'use strict'; | ||
require('flow-remove-types/register'); | ||
|
||
const toString = require('../../../src/style-spec/function/types').toString; | ||
const CompoundExpression = require('../../../src/style-spec/function/compound_expression').CompoundExpression; | ||
|
||
// registers compound expressions | ||
require('../../../src/style-spec/function/definitions'); | ||
|
||
const results = { | ||
array: [{ | ||
type: 'Array', | ||
parameters: ['Value'], | ||
}, { | ||
type: 'Array<type>', | ||
parameters: [ | ||
{name: 'type', type: '"String" | "Number" | "Boolean"'}, | ||
'Value' | ||
], | ||
}, { | ||
type: 'Array<type, N>', | ||
parameters: [ | ||
{name: 'type', type: '"String" | "Number" | "Boolean"'}, | ||
{name: 'N', type: 'Number (literal)'}, | ||
'Value' | ||
] | ||
}], | ||
at: [{ | ||
type: 'T', | ||
parameters: ['Number', 'Array'] | ||
}], | ||
case: [{ | ||
type: 'T', | ||
parameters: [{ repeat: ['Boolean', 'T'] }, 'T'] | ||
}], | ||
coalesce: [{ | ||
type: 'T', | ||
parameters: [{repeat: 'T'}] | ||
}], | ||
contains: [{ | ||
type: 'Boolean', | ||
parameters: ['T', 'Array<T> | Array<T, N>'] | ||
}], | ||
curve: [{ | ||
type: 'T', | ||
parameters: [ | ||
{name: 'input', type: 'Number'}, | ||
'["step"]', | ||
'T', | ||
{repeat: ['Number', 'T']} | ||
] | ||
}, { | ||
type: 'T: Number, ', | ||
parameters: [ | ||
{name: 'input', type: 'Number'}, | ||
{name: 'interpolation', type: '["step"] | ["linear"] | ["exponential", base] | ["cubic-bezier", x1, y1, x2, y2 ]'}, | ||
{repeat: ['Number', 'T']} | ||
] | ||
}], | ||
let: [{ | ||
type: 'T', | ||
parameters: [{ repeat: ['String (alphanumeric literal)', 'any']}, 'T'] | ||
}], | ||
literal: [{ | ||
type: 'Array<T, N>', | ||
parameters: ['[...] (JSON array literal)'] | ||
}, { | ||
type: 'Object', | ||
parameters: ['{...} (JSON object literal)'] | ||
}], | ||
match: [{ | ||
type: 'U', | ||
parameters: [ | ||
{name: 'input', type: 'T: Number (integer literal) | String (literal)'}, | ||
{repeat: ['T | [T, T, ...]', 'U']}, | ||
'U' | ||
] | ||
}], | ||
var: [{ | ||
type: 'the type of the bound expression', | ||
parameters: ['previously bound variable name'] | ||
}] | ||
}; | ||
|
||
for (const name in CompoundExpression.definitions) { | ||
const definition = CompoundExpression.definitions[name]; | ||
if (Array.isArray(definition)) { | ||
results[name] = [{ | ||
type: toString(definition[0]), | ||
parameters: processParameters(definition[1]) | ||
}]; | ||
} else { | ||
results[name] = definition.overloads.map((o) => { | ||
return { | ||
type: toString(definition.type), | ||
parameters: processParameters(o[0]) | ||
}; | ||
}); | ||
} | ||
} | ||
|
||
function processParameters(params) { | ||
if (Array.isArray(params)) { | ||
return params.map(toString); | ||
} else { | ||
return [{repeat: [toString(params.type)]}]; | ||
} | ||
} | ||
|
||
module.exports = results; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div class='col12 clearfix pad0y pad2x space-top0'> | ||
<span class='space-right'> | ||
<%= md("<a class='code' id='types-expression-" + name + "' href='#types-expression-" + name + "'>" + name + "</a> " + (expressionDocs[name] ? ('<br>' + expressionDocs[name].doc) : '').trim()) %> | ||
</span> | ||
<% for (const overload of expressionTypes[name]) { %> | ||
<div> | ||
{% highlight javascript %} | ||
<%=renderSignature(name, overload) %> | ||
{% endhighlight %} | ||
</div> | ||
<% } %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.