Skip to content

Commit da9c101

Browse files
authored
Merge pull request #1059 from starwed/doc-kind
Document the "kind" of thing associated with a docblock
2 parents 0e0dcde + 80347d1 commit da9c101

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1596
-858
lines changed

build/api-gen/doc-components.jsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ var MarkdownBlock = React.createClass({
2626
render: function() {
2727
var raw = this.props.value;
2828
var rawHtml = this.convert(raw);
29-
var key = this.props.key;
30-
return <span key={key} className="markdown" dangerouslySetInnerHTML={{__html: rawHtml}} />
29+
return <span className="markdown" dangerouslySetInnerHTML={{__html: rawHtml}} />
3130
}
3231
})
3332

@@ -46,21 +45,23 @@ var ToC = React.createClass({
4645
}
4746
}
4847
catArray.sort(nameSort);
49-
var catElements = catArray.map( function(cat, index){return <Category key={cat.name} catName = {cat.name} pages = {cat.pages}/>});
50-
return (
48+
var catElements = catArray.map( function(cat, index){return <Category key={cat.name} catName = {cat.name} pages = {cat.pages} />});
49+
return (
5150
<ul id = "doc-level-one">
5251
<li><a href="events.html">List of Events</a></li>
53-
<Category catName = {primary} pages = {toc.categories[primary].pages}/>
52+
<Category catName = {primary} pages = {toc.categories[primary].pages} />
5453
{catElements}
5554
</ul>
5655
)
5756
}
5857

5958
})
6059

60+
// The logic for choosing the link name and target is complicated due to the inconsistent way these are tagged in source
6161
var DocLink = React.createClass({
6262
render: function() {
6363
var target = this.props.target;
64+
var kind = this.props.kind || "missing";
6465
var linkText, href;
6566
var parent = (this.props.parentPage) ? this.props.parentPage.main.name : undefined;
6667
// If the link target starts with the name of the page, assume it is an internal link
@@ -94,14 +95,16 @@ var DocLink = React.createClass({
9495
linkText = target;
9596
href = cleanName(target) + ".html";
9697
}
97-
return <a href={href}>{linkText}</a>
98+
return <a href={href} className={"kind-" + kind}>{linkText}</a>
9899
}
99100
})
100101

101102
var Category = React.createClass({
102103
render: function() {
103-
this.props.pages.sort(stringSort);
104-
var pages = this.props.pages.map(function(page, index){return <li key={page}><DocLink target={page}/></li>});
104+
this.props.pages.sort(nameSort);
105+
var dictionary = this.props.dict;
106+
var pages = this.props.pages.map(function(page, index){return <li key={page.name}><DocLink target={page.name} kind={page.kind}/></li>});
107+
105108
return (
106109
<li className="category">
107110
{this.props.catName}

build/api-gen/dynamic-server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var cleanName = require("./clean-name");
1313
function startServer(grunt, input){
1414
var api = grunt.file.readJSON(input),
1515
index = createIndex(api),
16-
pages = index.pages,
16+
pages = index.pages,
1717
props = {data: api, index: index};
1818

1919
function createPage(selector, filename) {

build/api-gen/index-docs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function createIndex(blocks) {
1717
if (block.categories) {
1818
for (var j = 0; j < block.categories.length; j++) {
1919
if (block.name) {
20-
cat(block.categories[j]).pages.push(block.name)
20+
cat(block.categories[j]).pages.push( {name: block.name, kind: block.kind});
2121
}
2222
comp(block.name).main = block;
2323
}

build/parseNodes.coffee

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,18 @@ addNode =
136136
parent.requires = iterator.current().value
137137
iterator.next()
138138

139+
kind: (parent, iterator)->
140+
parent.kind = iterator.current().value
141+
iterator.next()
142+
143+
private: (parent, iterator)->
144+
parent.private = true
145+
iterator.next()
146+
147+
139148
#These are used only in 2d math files, and so don't have much meaning!
140149
public: (parent, iterator)->
141-
parent.public = true;
150+
parent.private = false;
142151
iterator.next()
143152
class: (parent, iterator)->
144153
parent.class = iterator.current().value

build/parseSourceDocs.coffee

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,17 @@ nameRe = /^\s*\#[^\#]/
6464
emptyRe = /^\s*$/
6565

6666
# Check whether a tag should be greedy or lazy when consuming subsequent lines
67+
# A lazy tag will stop parsing at a newline
6768
lazyTag = (tag) ->
6869
switch tag
69-
when "name", "comp", "category", "example", "sign"
70+
when "name", "comp", "category", "example", "sign", "kind", "private"
7071
true
7172
else
7273
false
7374

7475
# Assign each line to a node, throwing away empty lines that aren't directly after untagged lines
75-
# Guaranteed to leave the buffer in a state where buffer.current() hasn't yet been processed
76+
# Promises to leave the buffer in a state where buffer.current() hasn't yet been processed
7677
nextNode = (buffer)->
77-
7878

7979
# Find next non-empty line
8080
while (buffer.isOpen() and buffer.current().indexOf('*/') == -1) and (clean = cleanLine( buffer.current() )).length == 0
@@ -188,7 +188,7 @@ parseNode = (tag, value)->
188188
}
189189

190190

191-
191+
192192
# The top level method: given a list of files, parses each file into an array of docblocks, which are themeselves arrays of nodes
193193
# Returns one array of all the docblocks parsed
194194
parse = (files)->

src/controls/controls-system.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ ToggleInputGroup.prototype = {
7272
/**@
7373
* #Controls
7474
* @category Controls
75+
* @kind System
7576
*
7677
* A built-in system for linking specific inputs to general types of input events.
7778
*

src/controls/controls.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var Crafty = require('../core/core.js');
33
/**@
44
* #Draggable
55
* @category Controls
6+
* @kind Component
67
* Enable drag and drop of the entity. Listens to events from `MouseDrag` and moves entity accordingly.
78
*
89
* @see MouseDrag
@@ -130,6 +131,7 @@ Crafty.c("Draggable", {
130131
/**@
131132
* #Controllable
132133
* @category Controls
134+
* @kind Component
133135
*
134136
* Used to bind methods to generalized input events.
135137
*
@@ -256,6 +258,7 @@ Crafty.c("Controllable", {
256258
/**@
257259
* #Multiway
258260
* @category Controls
261+
* @kind Component
259262
*
260263
* Used to bind keys to directions and have the entity move accordingly.
261264
*
@@ -380,6 +383,7 @@ Crafty.c("Multiway", {
380383
/**@
381384
* #Jumper
382385
* @category Controls
386+
* @kind Component
383387
* @trigger CheckJumping - When entity is about to jump. This event is triggered with the object the entity is about to jump from (if it exists). Third parties can respond to this event and enable the entity to jump.
384388
*
385389
* Make the entity jump in response to key events.
@@ -548,6 +552,7 @@ Crafty.c("Jumper", {
548552
/**@
549553
* #Fourway
550554
* @category Controls
555+
* @kind Component
551556
*
552557
* Move an entity in four directions by using the
553558
* `Up Arrow`, `Left Arrow`, `Down Arrow`, `Right Arrow` keys or `W`, `A`, `S`, `D`.
@@ -594,6 +599,7 @@ Crafty.c("Fourway", {
594599
/**@
595600
* #Twoway
596601
* @category Controls
602+
* @kind Component
597603
*
598604
* Move an entity left or right using the `Left Arrow`, `Right Arrow` keys or `D` and `A`
599605
* and make it jump using `Up Arrow` or `W`.

src/controls/device.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Crafty.extend({
55
/**@
66
* #Crafty.device
77
* @category Misc
8+
* @kind Property
89
*
910
* Methods relating to devices such as tablets or phones
1011
*/
@@ -83,6 +84,8 @@ Crafty.extend({
8384
/**@
8485
* #Crafty.device.deviceOrientation
8586
* @comp Crafty.device
87+
* @kind Method
88+
*
8689
* @sign public Crafty.device.deviceOrientation(Function callback)
8790
* @param callback - Callback method executed once as soon as device orientation is change
8891
*
@@ -122,6 +125,8 @@ Crafty.extend({
122125
/**@
123126
* #Crafty.device.deviceMotion
124127
* @comp Crafty.device
128+
* @kind Method
129+
*
125130
* @sign public Crafty.device.deviceMotion(Function callback)
126131
* @param callback - Callback method executed once as soon as device motion is change
127132
*

src/controls/inputs.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Crafty.extend({
1010
/**@
1111
* #Crafty.lastEvent
1212
* @category Input
13+
* @kind Property
1314
* Check which mouse event occured most recently (useful for determining mouse position in every frame).
1415
*
1516
* The native [`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) is augmented with additional properties.
@@ -34,6 +35,7 @@ Crafty.extend({
3435
/**@
3536
* #Crafty.keydown
3637
* @category Input
38+
* @kind Property
3739
* Check which keys (referred by `Crafty.keys` key codes) are currently down.
3840
*
3941
* @example
@@ -48,6 +50,7 @@ Crafty.extend({
4850
/**@
4951
* #Crafty.selected
5052
* @category Input
53+
* @kind Property
5154
* @trigger CraftyFocus - is triggered when Crafty's stage gets selected
5255
* @trigger CraftyBlur - is triggered when Crafty's stage is no longer selected
5356
*
@@ -78,6 +81,7 @@ Crafty.extend({
7881
/**@
7982
* #Crafty.multitouch
8083
* @category Input
84+
* @kind Method
8185
* @sign public this .multitouch(Boolean bool)
8286
* @param bool - Turns multitouch on and off. The initial state is off (false).
8387
*
@@ -132,6 +136,8 @@ Crafty.extend({
132136
/**@
133137
* #Crafty.mouseDispatch
134138
* @category Input
139+
* @private
140+
* @kind Method
135141
*
136142
* Internal method which dispatches mouse events received by Crafty.
137143
*
@@ -230,6 +236,8 @@ Crafty.extend({
230236
/**@
231237
* #Crafty.touchDispatch
232238
* @category Input
239+
* @kind Method
240+
* @private
233241
*
234242
* Internal method which dispatches touch events received by Crafty (crafty.stage.elem).
235243
* The touch events get dispatched to the closest entity to the source of the event (if available).
@@ -416,6 +424,8 @@ Crafty.extend({
416424
/**@
417425
* #Crafty.findPointerEventTargetByComponent
418426
* @category Input
427+
* @kind Method
428+
* @private
419429
*
420430
* @sign public this .findPointerEventTargetByComponent(String comp, Event e[, Object target])
421431
* Finds closest entity with certain component at a given event.
@@ -502,6 +512,8 @@ Crafty.extend({
502512
/**@
503513
* #Crafty.mouseWheelDispatch
504514
* @category Input
515+
* @kind Method
516+
* @private
505517
*
506518
* Internal method which dispatches mouse wheel events received by Crafty.
507519
* @trigger MouseWheelScroll - is triggered when mouse is scrolled on stage - { direction: +1 | -1} - Scroll direction (up | down)
@@ -579,6 +591,8 @@ Crafty.extend({
579591
/**@
580592
* #Crafty.keyboardDispatch
581593
* @category Input
594+
* @kind Method
595+
* @private
582596
*
583597
* Internal method which dispatches keyboard events received by Crafty.
584598
* @trigger KeyDown - is triggered for each entity when the DOM 'keydown' event is triggered. - { key: `Crafty.keys` keyCode (Number), originalEvent: original KeyboardEvent } - Crafty's KeyboardEvent
@@ -706,6 +720,7 @@ Crafty._preBind("CraftyStop", function () {
706720
/**@
707721
* #Mouse
708722
* @category Input
723+
* @kind Component
709724
*
710725
* Provides the entity with mouse related events.
711726
*
@@ -771,6 +786,7 @@ Crafty.c("Mouse", {
771786
/**@
772787
* #Touch
773788
* @category Input
789+
* @kind Component
774790
* Provides the entity with touch related events
775791
* @trigger TouchStart - when entity is touched - TouchPoint
776792
* @trigger TouchMove - when finger is moved over entity - TouchPoint
@@ -817,6 +833,8 @@ Crafty.c("Touch", {
817833
/**@
818834
* #AreaMap
819835
* @category Input
836+
* @kind Component
837+
*
820838
* Component used by Mouse and Touch.
821839
* Can be added to other entities for use with the Crafty.findClosestEntityByComponent method.
822840
*
@@ -848,6 +866,7 @@ Crafty.c("AreaMap", {
848866
/**@
849867
* #.areaMap
850868
* @comp AreaMap
869+
* @kind Method
851870
*
852871
* @trigger NewAreaMap - when a new areaMap is assigned - Crafty.polygon
853872
*
@@ -904,6 +923,8 @@ Crafty.c("AreaMap", {
904923
/**@
905924
* #Button
906925
* @category Input
926+
* @kind Component
927+
*
907928
* Provides the entity with touch or mouse functionality, depending on whether this is a pc
908929
* or mobile device, and also on multitouch configuration.
909930
*
@@ -921,6 +942,8 @@ Crafty.c("Button", {
921942
/**@
922943
* #MouseDrag
923944
* @category Input
945+
* @kind Component
946+
*
924947
* Provides the entity with drag and drop mouse events.
925948
* @trigger Dragging - is triggered each frame the entity is being dragged - MouseEvent
926949
* @trigger StartDrag - is triggered when dragging begins - MouseEvent
@@ -962,6 +985,8 @@ Crafty.c("MouseDrag", {
962985
/**@
963986
* #.startDrag
964987
* @comp MouseDrag
988+
* @kind Method
989+
*
965990
* @sign public this .startDrag(void)
966991
*
967992
* Make the entity produce drag events, essentially making the entity follow the mouse positions.
@@ -983,6 +1008,8 @@ Crafty.c("MouseDrag", {
9831008
/**@
9841009
* #.stopDrag
9851010
* @comp MouseDrag
1011+
* @kind Method
1012+
*
9861013
* @sign public this .stopDrag(void)
9871014
*
9881015
* Stop the entity from producing drag events, essentially reproducing the drop.
@@ -1005,6 +1032,7 @@ Crafty.c("MouseDrag", {
10051032
/**@
10061033
* #Keyboard
10071034
* @category Input
1035+
* @kind Component
10081036
*
10091037
* Provides entity with keyboard events.
10101038
* @trigger KeyDown - is triggered for each entity when the DOM 'keydown' event is triggered. - { key: `Crafty.keys` keyCode (Number), originalEvent: original KeyboardEvent } - Crafty's KeyboardEvent
@@ -1038,6 +1066,8 @@ Crafty.c("Keyboard", {
10381066
/**@
10391067
* #.isDown
10401068
* @comp Keyboard
1069+
* @kind Method
1070+
*
10411071
* @sign public Boolean isDown(String keyName)
10421072
* @param keyName - Name of the key to check. See `Crafty.keys`.
10431073
* @sign public Boolean isDown(Number keyCode)

src/controls/keycodes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Crafty.extend({
55
/**@
66
* #Crafty.keys
77
* @category Input
8+
* @kind Property
9+
*
810
* Object of key names and the corresponding Unicode key code.
911
*
1012
* ~~~
@@ -199,6 +201,8 @@ Crafty.extend({
199201
/**@
200202
* #Crafty.mouseButtons
201203
* @category Input
204+
* @kind Property
205+
*
202206
* An object mapping mouseButton names to the corresponding button ID.
203207
* In all mouseEvents, we add the `e.mouseButton` property with a value normalized to match e.button of modern webkit browsers:
204208
*

0 commit comments

Comments
 (0)