mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-31 19:37:21 +02:00
Updated Style Guide (markdown)
parent
19570a54ca
commit
7f06092484
@ -3,18 +3,43 @@
|
|||||||
* Indentation - 2 spaces
|
* Indentation - 2 spaces
|
||||||
* Line Length - 80 characters
|
* Line Length - 80 characters
|
||||||
|
|
||||||
|
## Naming
|
||||||
|
* variables and functions - lowerCamelCase
|
||||||
|
* constructor like functions - UpperCamelCase
|
||||||
|
* constants - ALL_UPPER_CASE_WITH_UNDERSCORES
|
||||||
|
|
||||||
|
## Braces
|
||||||
|
* No braces for single line control statements
|
||||||
|
```
|
||||||
|
if (someVar)
|
||||||
|
return true;
|
||||||
|
```
|
||||||
|
* Opening brace on the same line
|
||||||
|
```
|
||||||
|
if (someVar) {
|
||||||
|
someVar += 2;
|
||||||
|
return someVar;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## White Space
|
||||||
|
* Space after control statements (if, else, while, for, ...)
|
||||||
|
```
|
||||||
|
if (somevar)
|
||||||
|
```
|
||||||
|
|
||||||
## Classes
|
## Classes
|
||||||
The standard way of creating classes in pdf.js is the following. Please note that by class we mean an object that is class-like.
|
The standard way of creating classes in pdf.js is the following. Please note that by class we mean an object that is class-like.
|
||||||
<pre>
|
```
|
||||||
var Name = (function NameClosure() {
|
var Name = (function NameClosure() {
|
||||||
function Name(name) {
|
function Name(name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Name.prototype = {
|
Name.prototype = {
|
||||||
|
...
|
||||||
};
|
};
|
||||||
...
|
|
||||||
|
|
||||||
return Name;
|
return Name;
|
||||||
})();
|
})();
|
||||||
</pre>
|
```
|
||||||
Loading…
x
Reference in New Issue
Block a user