Skip to content
louisstow edited this page Mar 31, 2011 · 15 revisions

Proposed style guide in development

Components

Components should be in title case and resemble Classes.

Crafty.c("MyComponent", {

Methods

Methods should use camel case.

.myMethod()

Properties

Properties should again be camel case.

.myProperty

Visibility

Private members must have an underscore _ before the name. Only make it private if the user/developer should never invoke it or modify it. Public members can be anything as long as there is no underscore at the beginning.

If the property is to be modified through Crafty Builder, it should be public.

Events

Events should describe the action taking place. The event name should be in title case.

this.trigger("ButtonClicked")

Comments

Multiline comments should be at the start of every component detailing the purpose and the start of every public method and property. The multiline comments will be generated into the API. Use Markdown syntax to describe the method, property or component. It should start with /**@ to denote that this should be generated.

Use the following template for documenting:

/**@
* #nameOfThing
* `public ReturnValue nameOfThing(Type arg)`
* **Parameters:**
* `arg`
* :   `Type` Description of argument
*
* **Returns:**
* Description of what it returns.
*
* Description of the thing, what it does and why.
*
* ##Use
*   [code example of how to use it]
*/

Use single line comments whenever necessary.

Clone this wiki locally