-
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.
Add docs and style-spec JSON entries
- Loading branch information
Anand Thakker
committed
Aug 29, 2017
1 parent
635a4d3
commit 75fcd51
Showing
8 changed files
with
440 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,102 @@ | ||
'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'}, | ||
{name: 'interpolation', type: '["step"] | ["linear"] | ["exponential", base] | ["cubic-bezier", x1, y1, x2, y2 ]'}, | ||
{repeat: ['number', 'T']} | ||
] | ||
}], | ||
let: [{ | ||
type: 'T', | ||
parameters: [{ repeat: ['alphanumeric string 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'}, | ||
{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,13 @@ | ||
<div class='col12 clearfix pad0y pad2x'> | ||
<span class='code space-right'><a id='types-expression-<%= name %>' href='#types-expression-<%= name %>'><%= name %></a></span> | ||
<% for (const overload of expressionTypes[name]) { %> | ||
<div> | ||
{% highlight javascript %} | ||
[<%= JSON.stringify(name) %><%=renderParams(overload.parameters) %>]: <%= overload.type %> | ||
{% endhighlight %} | ||
</div> | ||
<% } %> | ||
<% if (expressionDocs[name] && expressionDocs[name].doc.trim().length) { %> | ||
<div class="space-bottom1"><%= md(expressionDocs[name].doc) %></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.