Coding conventions - Heigvd/Wegas GitHub Wiki

Java

JavaScript

Space conventions

Example

If (ttt = 0) {
    example: function (str) {
            return "asdasddasd";
        }
}

for (i=0; i<10; i++) {
}

JsDoc General Information

JSDoc module allows generating the JavaScript documentation. To recognize automatically the comments from a Js document, there are some rules.

  1. The first tag in the JS file should be @fileoverview. This tag allows the plugin JSDoc to recognize that the file must be parsed and also allows him to interpret the tags @authors and @version
  2. For declaring the class you need to use the tag @class preceded by @name tag with the name of the class
  3. A class can also extend another one. For this, two tags exists : @extends and @augments
  4. Directly after instantiating the widget add the tag @lends class name# Attention the # at end of the tag, means that is NOT a static method
  5. before commenting on ATTRS, you must add the tag @lends class name again Attention This time there is no # at end of the tag, this indicate that is a static method. To be clear, all method of this section has the tag @static
  6. For add an event, you must use the tag @event
  7. JSDoc didn’t contain a tag for attributes (ATTRS), follow the attributes example

For complete examples you can refer to wegas-app.js, wegas-joingamewidget.js, wegas-jointeamwidget.js and wegas-panelwidget.js

Comment conventions

First file tag

@fileoverview
Eventual description of the JS file content
@authors authors name

Declare Class

@name Y.Wegas.PanelWidget
@extends Y.Panel
@class  class for creating panel from a JSON file with children
@constructor
@param Object Will be used to fill attributes field 
@description Create a panel with all children

Extends class

@name Class name
@extends Extended class name
@class Class description

###After instantiating the widget###

@lends Y.Wegas.App#

Method

@function
@return {type} Return description
@description Method description

Static method

 @function
 @static
 @description Method description

Private method

 @function
 @private
 @description Method description

Event

 @event
 @description Event description

Before comments Attrs###

@lends Y.Wegas.App

Attributes convention

 @field
 @static
 @description
 <p><strong>Method</strong></p>
   <ul>
    <li>base: Base Url for app, <i>default: /Wegas/</i></li>
    <li>layoutSrc : xxxxxxxxxxxxxxx</li>
 </ul>

Links

Wiki jsdoc plugin : http://code.google.com/p/jsdoc-toolkit/w/list

Available tags : http://code.google.com/p/jsdoc-toolkit/wiki/TagReference

⚠️ **GitHub.com Fallback** ⚠️