Skip to content

Commit cde3365

Browse files
committed
Updated packages.
Prevented handlebars helpers from running on undefined values. Updated test fixtures to match latest dox output.
1 parent ef678a4 commit cde3365

File tree

5 files changed

+143
-15
lines changed

5 files changed

+143
-15
lines changed

lib/helpers.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,21 @@ module.exports = function (hbs) {
1010

1111
hbs.registerHelper('highlightBlock', function (block) {
1212

13-
return hljs.highlight('javascript', block).value;
13+
if (block) {
14+
15+
return hljs.highlight('javascript', block).value;
16+
17+
}
1418

1519
});
1620

1721
hbs.registerHelper('markdown', function (block) {
1822

19-
return markdown.render(block);
23+
if (block) {
24+
25+
return markdown.render(block);
26+
27+
}
2028

2129
});
2230

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"dependencies": {
99
"adm-zip": "0.4.7",
1010
"chalk": "1.0.0",
11-
"dox": "0.7.0",
11+
"dox": "0.7.1",
1212
"handlebars": "3.0.1",
13-
"highlight.js": "8.4.0",
13+
"highlight.js": "8.5.0",
1414
"markdown-it": "4.1.0",
1515
"promise": "6.1.0",
1616
"sqlite3": "3.0.5",

test/fixtures/dox.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
"description": "escaped html"
2929
}
3030
],
31-
"api": []
31+
"api": [
32+
"public"
33+
]
3234
},
3335
"params": "html"
3436
}

test/fixtures/facade.js

Lines changed: 78 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
/**
22
* Create a polygon object. Inherits all methods from <b>Facade.Entity</b>.
33
*
4-
* var polygon = new Facade.Polygon({
5-
* x: 0,
6-
* y: 0,
7-
* points: [ [100, 0], [200, 100], [100, 200], [0, 100] ],
8-
* lineWidth: 10,
9-
* strokeStyle: '#333E4B',
10-
* fillStyle: '#1C73A8',
11-
* anchor: 'top/left'
12-
* });
4+
* ```
5+
* var polygon = new Facade.Polygon({
6+
* x: 0,
7+
* y: 0,
8+
* points: [ [100, 0], [200, 100], [100, 200], [0, 100] ],
9+
* lineWidth: 10,
10+
* strokeStyle: '#333E4B',
11+
* fillStyle: '#1C73A8',
12+
* anchor: 'top/left'
13+
* });
14+
* ```
1315
*
1416
* @param {Object} [options] Options to create the polygon with.
1517
* @param {String} [options.anchor] Position to anchor the polygon. <i>Default:</i> "top/left"<br><ul><li>top/left</li><li>top/center</li><li>top/right</li><li>center/left</li><li>center</li><li>center/right</li><li>bottom/left</li><li>bottom/center</li><li>bottom/right</li></ul>
@@ -93,3 +95,70 @@ Facade.Polygon.prototype._defaultOptions = function (updated) {
9395
return options;
9496

9597
};
98+
99+
/**
100+
* Renders a polygon entity to a canvas.
101+
*
102+
* @example polygon._draw(facade, options, metrics);
103+
* @param {Object} facade Facade.js object.
104+
* @param {Object} options Options used to render the polygon.
105+
* @param {Object} metrics Metrics used to render the polygon.
106+
* @return {Void}
107+
* @private
108+
*/
109+
110+
Facade.Polygon.prototype._draw = function (facade, options, metrics) {
111+
112+
var context = facade.context,
113+
i,
114+
length;
115+
116+
this._applyTransforms(context, options, metrics);
117+
118+
if (options.points.length) {
119+
120+
context.beginPath();
121+
122+
for (i = 0, length = options.points.length; i < length; i += 1) {
123+
124+
if (options.points[i].length === 6) {
125+
126+
context.bezierCurveTo.apply(context, options.points[i]);
127+
128+
} else if (options.points[i].length === 5) {
129+
130+
context.arc.apply(context, options.points[i]);
131+
132+
} else if (options.points[i].length === 2) {
133+
134+
context.lineTo.apply(context, options.points[i]);
135+
136+
}
137+
138+
}
139+
140+
if (options.closePath) {
141+
142+
context.closePath();
143+
144+
} else {
145+
146+
context.moveTo.apply(context, options.points[length - 1]);
147+
148+
}
149+
150+
if (options.fillStyle) {
151+
152+
context.fill();
153+
154+
}
155+
156+
if (options.lineWidth > 0) {
157+
158+
context.stroke();
159+
160+
}
161+
162+
}
163+
164+
};

test/fixtures/facade.json

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "method",
66
"name": "Facade.Polygon",
77
"description": "Create a polygon object. Inherits all methods from <b>Facade.Entity</b>.",
8-
"body": " var polygon = new Facade.Polygon({\n x: 0,\n y: 0,\n points: [ [100, 0], [200, 100], [100, 200], [0, 100] ],\n lineWidth: 10,\n strokeStyle: '#333E4B',\n fillStyle: '#1C73A8',\n anchor: 'top/left'\n });\n",
8+
"body": "```\nvar polygon = new Facade.Polygon({\n x: 0,\n y: 0,\n points: [ [100, 0], [200, 100], [100, 200], [0, 100] ],\n lineWidth: 10,\n strokeStyle: '#333E4B',\n fillStyle: '#1C73A8',\n anchor: 'top/left'\n});\n```\n",
99
"tags": {
1010
"example": [],
1111
"param": [
@@ -166,5 +166,54 @@
166166
"private": []
167167
},
168168
"params": "updated"
169+
},
170+
{
171+
"uid": "facade.js-facade.polygon.prototype._draw",
172+
"isPrivate": true,
173+
"type": "method",
174+
"name": "Facade.Polygon._draw",
175+
"description": "Renders a polygon entity to a canvas.\n",
176+
"body": "",
177+
"tags": {
178+
"example": [
179+
"polygon._draw(facade, options, metrics);"
180+
],
181+
"param": [
182+
{
183+
"name": "facade",
184+
"isOptional": false,
185+
"types": [
186+
"Object"
187+
],
188+
"description": "Facade.js object."
189+
},
190+
{
191+
"name": "options",
192+
"isOptional": false,
193+
"types": [
194+
"Object"
195+
],
196+
"description": "Options used to render the polygon."
197+
},
198+
{
199+
"name": "metrics",
200+
"isOptional": false,
201+
"types": [
202+
"Object"
203+
],
204+
"description": "Metrics used to render the polygon."
205+
}
206+
],
207+
"return": [
208+
{
209+
"types": [
210+
"Void"
211+
],
212+
"description": ""
213+
}
214+
],
215+
"private": []
216+
},
217+
"params": "facade, options, metrics"
169218
}
170219
]

0 commit comments

Comments
 (0)