Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Stefane Fermigier
jio
Commits
a70dfbc1
Commit
a70dfbc1
authored
Feb 06, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style_guide.rst trailling spaces removed
parent
eddcb757
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
69 deletions
+68
-69
docs/style_guide.rst
docs/style_guide.rst
+68
-69
No files found.
docs/style_guide.rst
View file @
a70dfbc1
...
@@ -25,19 +25,19 @@ Good Example
...
@@ -25,19 +25,19 @@ Good Example
.. code-block:: javascript
.. code-block:: javascript
function sum(x, y) {
function sum(x, y) {
var result = x + y;
var result = x + y;
return result;
return result;
}
}
Bad Example
Bad Example
.. code-block:: javascript
.. code-block:: javascript
function sum(x, y) {
function sum(x, y) {
// missing var declaration, implied global
// missing var declaration, implied global
result = x + y;
result = x + y;
return result;
return result;
}
}
...
@@ -61,7 +61,7 @@ In this project, JavaScript sources have to begin with the header:
...
@@ -61,7 +61,7 @@ In this project, JavaScript sources have to begin with the header:
.. code-block:: javascript
.. code-block:: javascript
/*jslint indent: 2, maxlen: 80, nomen: true */
/*jslint indent: 2, maxlen: 80, nomen: true */
which means it uses two spaces indentation, 80
which means it uses two spaces indentation, 80
maximum characters per line and allows variable names starting with '_'.
maximum characters per line and allows variable names starting with '_'.
Other JSLint options can be added in sub functions if necessary.
Other JSLint options can be added in sub functions if necessary.
...
@@ -111,22 +111,22 @@ Good Example
...
@@ -111,22 +111,22 @@ Good Example
};
};
};
};
}
}
return inner;
return inner;
}
}
Bad Example
Bad Example
.. code-block:: javascript
.. code-block:: javascript
function outer(a, b) {
function outer(a, b) {
var c = 1,
var c = 1,
d = 2,
d = 2,
inner;
inner;
if (a > b) {
if (a > b) {
inner = function () {
inner = function () {
return {
return {
r: c - d
r: c - d
}}}};
}}}};
...
@@ -170,12 +170,12 @@ Bad Example
...
@@ -170,12 +170,12 @@ Bad Example
.. code-block:: javascript
.. code-block:: javascript
function func()
function func()
{
{
return
return
{
{
"name": "Batman"
"name": "Batman"
};
};
}
}
...
@@ -183,9 +183,9 @@ Good Example
...
@@ -183,9 +183,9 @@ Good Example
.. code-block:: javascript
.. code-block:: javascript
function func() {
function func() {
return {
return {
"name": "Batman"
"name": "Batman"
};
};
}
}
...
@@ -200,19 +200,20 @@ Bad Example
...
@@ -200,19 +200,20 @@ Bad Example
.. code-block:: javascript
.. code-block:: javascript
function func() {
function func() {
return {
return {
"name": "Batman"
"name": "Batman"
};
};
}
}
Good Example
Good Example
.. code-block:: javascript
.. code-block:: javascript
function func() {
function func() {
return {
return {
"name": "Batman"
"name": "Batman"
};
};
}
}
}
...
@@ -355,7 +356,7 @@ Example
...
@@ -355,7 +356,7 @@ Example
test.setAttribute("id", "uniqueIdentifier");
test.setAttribute("id", "uniqueIdentifier");
// good example
// good example
test.setAttribute("id", "unique_identifier");
test.setAttribute("id", "unique_identifier");
Discuss - checked with jQuery UI/jQuery Mobile, they don't use written name conventions, only
Discuss - checked with jQuery UI/jQuery Mobile, they don't use written name conventions, only
...
@@ -374,29 +375,29 @@ Good Example
...
@@ -374,29 +375,29 @@ Good Example
.. code-block:: javascript
.. code-block:: javascript
var person = {
var person = {
"getName": function () {
"getName": function () {
return this._getFirst() + " " + this._getLast();
return this._getFirst() + " " + this._getLast();
},
},
"_getFirst": function () {
"_getFirst": function () {
// ...
// ...
},
},
"_getLast": function () {
"_getLast": function () {
// ...
// ...
}
}
};
};
Bad Example
Bad Example
.. code-block:: javascript
.. code-block:: javascript
var person = {
var person = {
"getName": function () {
"getName": function () {
return this.getFirst() + " " + this.getLast();
return this.getFirst() + " " + this.getLast();
},
},
// private function
// private function
"getFirst": function () {
"getFirst": function () {
// ...
// ...
}
}
};
};
...
@@ -448,19 +449,19 @@ Good Example
...
@@ -448,19 +449,19 @@ Good Example
var person = {
var person = {
// returns full name string
// returns full name string
"getName": function () {
"getName": function () {
return this._getFirst() + " " + this._getLast();
return this._getFirst() + " " + this._getLast();
}
}
};
};
Bad Example
Bad Example
.. code-block:: javascript
.. code-block:: javascript
var person = {
var person = {
"getName": function () {
"getName": function () {
return this._getFirst() + " " + this._getLast();
return this._getFirst() + " " + this._getLast();
}
}
};
};
Documentation
Documentation
...
@@ -474,14 +475,14 @@ Good Example
...
@@ -474,14 +475,14 @@ Good Example
.. code-block:: javascript
.. code-block:: javascript
/**
/**
* Reverse a string
* Reverse a string
*
*
* @param {String} input_string String to reverse
* @param {String} input_string String to reverse
* @return {String} The reversed string
* @return {String} The reversed string
*/
*/
function reverse(input_string) {
function reverse(input_string) {
// ...
// ...
return output_string;
return output_string;
};
};
...
@@ -489,10 +490,10 @@ Bad Example
...
@@ -489,10 +490,10 @@ Bad Example
.. code-block:: javascript
.. code-block:: javascript
function reverse(input_string) {
function reverse(input_string) {
// ...
// ...
return output_string;
return output_string;
};
};
Additional Readings
Additional Readings
...
@@ -504,5 +505,3 @@ Resources, additional reading materials and links:
...
@@ -504,5 +505,3 @@ Resources, additional reading materials and links:
* `JSLint <http://www.jslint.com/>`_, code quality tool.
* `JSLint <http://www.jslint.com/>`_, code quality tool.
* `JSLint Error Explanations <http://jslinterrors.com/>`_, a useful reference.
* `JSLint Error Explanations <http://jslinterrors.com/>`_, a useful reference.
* `YUIDoc <http://yuilibrary.com/projects/yuidoc>`_, generate documentation from code.
* `YUIDoc <http://yuilibrary.com/projects/yuidoc>`_, generate documentation from code.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment