Skip to content
This repository has been archived by the owner on Apr 10, 2018. It is now read-only.

fixes #497: document enum values #510

Merged
merged 33 commits into from
Sep 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f39eba9
data sources
incanus Sep 28, 2016
99ef21b
geometry types
incanus Sep 28, 2016
996b8a4
layer display
incanus Sep 28, 2016
d97d180
line cap & join
incanus Sep 28, 2016
029b14a
placement
incanus Sep 28, 2016
04c8fb7
alignment, translation, scaling, anchor, justification
incanus Sep 28, 2016
b6d542d
text transformation
incanus Sep 28, 2016
0cecf5d
filter operators & geometries
incanus Sep 28, 2016
0471e09
function interpolation
incanus Sep 28, 2016
44da3a8
remove dead color operations
incanus Sep 28, 2016
d6c5510
minor formatting tweaks
incanus Sep 28, 2016
de06217
fix missing `line` description
incanus Sep 28, 2016
db47134
align filter operator descriptions with online docs
incanus Sep 28, 2016
5422987
validate both scalar & object enum values
incanus Sep 28, 2016
cbca231
fix indentation and implicit parentheses
incanus Sep 28, 2016
b6d9220
split up sections, add comments, add parentheses
incanus Sep 28, 2016
4e0932a
update validation for enum value docs
incanus Sep 28, 2016
10aab62
update enum validation for objects
incanus Sep 28, 2016
cecad91
refresh minified v8
incanus Sep 28, 2016
83aa844
wording tweaks per @1ec5
incanus Sep 28, 2016
742bc7a
better contextual placement
incanus Sep 28, 2016
ca7b446
clarify relationship
incanus Sep 28, 2016
6b79dae
more accurate
incanus Sep 28, 2016
3477118
rearrange to natural order
incanus Sep 28, 2016
6b8c8e2
scaling clarifications
incanus Sep 28, 2016
ab29a11
plainer text
incanus Sep 28, 2016
0795459
bump minified v8
incanus Sep 28, 2016
674a1e1
update docs enum generator
incanus Sep 28, 2016
77826c0
tweaks to online docs for enum values
incanus Sep 28, 2016
cc63f58
change to literal values
incanus Sep 28, 2016
95d98f6
fix typo
incanus Sep 29, 2016
5848d76
better filter operation docs
incanus Sep 30, 2016
0c01dde
Merge remote-tracking branch 'origin/mb-pages' into 497-enum-value-docs
incanus Sep 30, 2016
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
10 changes: 8 additions & 2 deletions docs/_generate/item.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
<%= prop.required ? 'Required' : 'Optional' %>
<% if (prop.type && prop.type !== '*') { %><a href='#types-<%= prop.type %>'><%= prop.type %></a>.<% } %>
</em>
<% if (prop.values) { %><span class='space-right quiet'>
<em>One of</em> <%= _(prop.values).map(function(opt) { return '<var>' + opt + '</var>' }).join(', ') %>.
<% if (prop.values && Array.isArray(prop.values) === false) { // skips $root.version %><span class='space-right quiet'>
<em>One of</em> <%= _(Object.keys(prop.values)).map(function(opt) { return '<var>' + opt + '</var>' }).join(', ') %>.
</span><% } %>
<% if (prop.units) { %><span class='space-right quiet'>
<em>Units in</em>
Expand Down Expand Up @@ -45,6 +45,12 @@
<% if (prop.doc) { %>
<div class='space-bottom1'><%= md(prop.doc) %></div>
<% } %>
<% if (prop.values && Array.isArray(prop.values) === false) { // skips $root.version %><div class='space-bottom1'><dl>
<% for (var v in prop.values) { %>
<dt><var><%= v %></var></dt>
<dd><%= md(prop.values[v].doc) %></dd>
<% } %>
</dl></div><% } %>
<% if (prop.example) { %>
<div class='space-bottom1 clearfix'>
{% highlight json %}
Expand Down
10 changes: 8 additions & 2 deletions lib/validate/validate_enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ module.exports = function validateEnum(options) {
var valueSpec = options.valueSpec;
var errors = [];

if (valueSpec.values.indexOf(unbundle(value)) === -1) {
errors.push(new ValidationError(key, value, 'expected one of [%s], %s found', valueSpec.values.join(', '), value));
if (Array.isArray(valueSpec.values)) { // <=v7
if (valueSpec.values.indexOf(unbundle(value)) === -1) {
errors.push(new ValidationError(key, value, 'expected one of [%s], %s found', valueSpec.values.join(', '), value));
}
} else { // >=v8
if (Object.keys(valueSpec.values).indexOf(unbundle(value)) === -1) {
errors.push(new ValidationError(key, value, 'expected one of [%s], %s found', Object.keys(valueSpec.values).join(', '), value));
}
}
return errors;
};
Loading