Skip to content

Commit bbeb50c

Browse files
committed
Updates to the coding standards manual
1 parent 76e09a9 commit bbeb50c

File tree

15 files changed

+145
-52
lines changed

15 files changed

+145
-52
lines changed

assets/css/manual.css

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,47 @@ th
1313
{
1414
border: 1px solid gray;
1515
padding: 10px;
16+
}
17+
.manual-image {
18+
margin: .5em 0 2em 0;
19+
text-align: center;
20+
}
21+
h1,h2,h3 {
22+
line-height:36px;
23+
}
24+
h1 {
25+
font-size:34.5px;
26+
}
27+
h2 {
28+
font-size:28.5px;
29+
}
30+
h3 {
31+
font-size:22.5px;
32+
}
33+
h4 {
34+
font-size:18.5px;
35+
}
36+
h5 {
37+
font-size:14px;
38+
}
39+
h6 {
40+
font-size:11.9px;
41+
}
42+
h1 small {
43+
font-size:22.5px;
44+
}
45+
h2 small {
46+
font-size:18.5px;
47+
}
48+
h3 small {
49+
font-size:14px;
50+
}
51+
h4 small {
52+
font-size:14px;
53+
}
54+
#version {
55+
float:right;
56+
font-size:.85em;
57+
font-weight:bold;
58+
}
1659
}

assets/js/manual.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ var populateMenu = function() {
5252
}).send();
5353
}
5454

55+
var populateVersion = function() {
56+
var versionRequest = new Request({
57+
"url": here + 'manual/en-US/version.md',
58+
"method": "get",
59+
"onSuccess": function(response) {
60+
$('version').set('html', marked(response));
61+
}
62+
}).send();
63+
}
64+
5565
window.addEvent('domready', function() {
5666
var urlParts = document.URL.split('?', 2);
5767
state = {};
@@ -63,7 +73,7 @@ window.addEvent('domready', function() {
6373
}
6474
else
6575
{
66-
var currentDoc = "chapters/introduction.md";
76+
var currentDoc = "coding-standards/introduction.md";
6777
}
6878

6979
marked.setOptions({
@@ -78,6 +88,7 @@ window.addEvent('domready', function() {
7888
})
7989
populateMenu();
8090
populateWindow(currentDoc);
91+
populateVersion();
8192

8293
document.id('main').addEvent('click:relay(a)', function (event, target) {
8394
if (target.get('href').substring(0, 4) != 'http' && target.get('href').substring(0, 1) != '#')

index.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,21 @@
3333
<span class="icon-bar"></span>
3434
<span class="icon-bar"></span>
3535
</a>
36-
<a class="brand" href="#">Joomla! Coding Standards Manual</a>
36+
<a class="brand" href="/coding-standards/">Joomla! Coding Standards Manual</a>
3737
</div>
3838
</div>
3939
</div>
4040

4141
<div id="main" class="container-fluid">
4242
<div class="row-fluid">
4343
<div class="span3">
44+
<div class="manual-image">
45+
<img src="https://github.com/Hutchy68/coding-standards/blob/gh-pages/manual/en-US/coding-standards/joomla_coding_standards_manual.png?raw=true" alt="Joomla! Graphic">
46+
</div>
4447
<div class="well sidebar-nav" id="doc-menu">
4548
</div><!--/.well -->
4649
</div><!--/span-->
47-
<div class="span9">
50+
<div class="span9">
4851
<div id="docwin">
4952
</div>
5053
</div><!--/span-->
@@ -53,13 +56,17 @@
5356
<hr>
5457

5558
<footer>
59+
<div class="well">
60+
<h4>License</h4>
5661
<p>The contents of the Joomla! Coding Standards Manual are subject to copyright law and are made available under the <a href="http://docs.joomla.org/JEDL"
5762
title="Joomla! Electronic Documentation License (JEDL)">Joomla! Electronic Documentation License (JEDL)</a> unless otherwise stated.
5863
You may find the <a href="http://docs.joomla.org/JEDL/FAQ" title="JEDL Frequently Asked Questions">JEDL Frequently Asked Questions</a>
5964
useful in determining if your proposed use of this material is allowed. If you have any questions regarding licensing of this
6065
material please contact <a href="mailto:legal@opensourcematters.org" title="Email Open Source Matters">legal@opensourcematters.org</a>.
6166
If you wish to report a possible violation of the license terms for the material on this site then please contact
6267
<a href="mailto:legal@opensourcematters.org" title="Email Open Source Matters">legal@opensourcematters.org</a>.</p>
68+
</div>
69+
<div id="version"></div>
6370
</footer>
6471

6572
</div><!--/.fluid-container-->
Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
### Configuring Code Analysis Tools
1+
## Coding Standards Analysis
22

3-
#### Coding Standards Analysis
3+
For new contributions we are going to be enforcing coding standards to ensure that the coding style in the source code is consistent. Ensuring that your code meets these standards will make the process of code contribution smoother.
44

5-
In order to improve the consistency and readability of the source code,
6-
we run a coding style analysis tool everytime changes are pushed in the
7-
repo. For new contributions we are going to be enforcing coding
8-
standards to ensure that the coding style in the source code is
9-
consistent. Ensuring that your code meets these standards will make the
10-
process of code contribution smoother.
5+
## Configuring Code Analysis Tools
6+
7+
In order to improve the consistency and readability of the source code, the Joomla project runs a coding style analysis tool, CodeSniffer, everytime changes are pushed to a Joomla project's repository.
8+
9+
### Running CodeSniffer
1110

1211
The Joomla Platform sniffer rules are written to be used with a tool
1312
called PHP\_CodeSniffer. Please see the [PHP\_CodeSniffer Pear
1413
Page](http://pear.php.net/package/PHP_CodeSniffer) for information on
1514
installing PHP\_CodeSniffer on your system.
1615

17-
##### Running CodeSniffer
18-
1916
You can run the CodeSniffer by going to the platform root directory and
2017
executing `phpcs --report=checkstyle
2118
--report-file=build/logs/checkstyle.xml --standard=/path/to/platform/build/phpcs/Joomla /path/to/platform`
@@ -24,10 +21,17 @@ Alternatively, if you have Ant installed on your system, you may run the
2421
CodeSniffer by going to the platform root directory and executing
2522
`ant phpcs`
2623

27-
##### Known Issues
24+
#### Known Issues
2825

2926
- There is currently an issue with running the Code Sniffer on the
3027
Simplepie library. Pointing the sniffs at the libraries/joomla
3128
directory or below will avoid the issue.
3229

30+
## Other Tools
31+
32+
Here are some other tools available to developers who are planning to submit source code to the project.
33+
34+
### PhpStorm Code Style Scheme
35+
36+
3337

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## Code Examples

manual/en-US/coding-standards/chapters/basic-guidelines.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
## Basic Guidelines
22

3-
This chapter outlines the basic guidelines that cover and files.
3+
This chapter outlines the basic guidelines covering files contributed to the Joomla project. The most important rule to remember when coding for the Joomla project, **if in doubt, please ask**.
44

5-
## File Format
5+
### File Format
66

7-
All files contributed to Joomla must be stored as ASCII text, use UTF-8 character encoding and be Unix formatted. Lines must end only with a line feed (LF). Line feeds are represented as ordinal 10, octal 012 and hex 0A. Do not use carriage returns (CR) like Macintosh computers do or the carriage return/line feed combination (CRLF) like Windows computers do.
7+
All files contributed to Joomla must be:
88

9-
## Spelling
9+
* Stored as ASCII text
10+
* Use UTF-8 character encoding
11+
* Be Unix formatted following these rules.
12+
1. Lines must end only with a line feed (LF).
13+
2. Line feeds are represented as ordinal 10, octal 012 and hex 0A.
14+
3. Do not use carriage returns (CR) like Macintosh computers do or the carriage return/line feed combination (CRLF) like Windows computers do.
1015

11-
The spelling of words and terms used in code comments and in the naming of class, functions, variables and constant should generally be in accordance with British English rules (en\_GB). However, some exceptions are permitted, for example where common programming names are used that align with the PHP API or other established conventions such as for “color” where is it common practice to maintain US English spelling.
16+
### Spelling
1217

13-
## Indenting
18+
The spelling of words and terms used in code comments and in the naming of class, functions, variables and constant should generally be in accordance with British English rules (en\_GB).
19+
Some exceptions are permitted, for example where common programming names are used that align with the PHP API or other established conventions such as for `color` where is it common practice to maintain US English spelling.
20+
21+
### Indenting
1422

1523
Tabs are used for indenting code (not spaces as required by the PEAR standard). Source code editors or Integrated Development Environments (IDE’s) such as Eclipse must have the tab-stops for indenting measuring four (4) spaces in length.
1624

17-
## Line Length
25+
### Line Length
1826

1927
There is no maximum limit for line lengths in files, however, a notional value of about 150 characters is recommended to achieve a good level of readability without horizontal scrolling. Longer lines are permitted if the nature of the code for individual lines requires it and line breaks would have an adverse affect on the final output (such as for mixed PHP/HTML layout files).
2028

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## DocBlocks
2+
3+
@TODO - Entend information about DocBlocks specific to the Framework and CMS. Other project?

manual/en-US/coding-standards/chapters/comments.md renamed to manual/en-US/coding-standards/chapters/inline-comments.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
## Comments
1+
## Inline Code Comments
22

3-
This chapter covers inline commenting in more detail. Inline comments are all comments not included in doc blocs. The goal of in line commenting is to explain code in context. Such explanation may take many different forms.
3+
This chapter covers inline code commenting in more detail. Inline comments are all comments not included in doc blocs. The goal of in line commenting is to explain code in context. Such explanation may take many different forms.
44

55
Comments that are written in a readable and narrative style, especially when explaining a complex process, are encouraged. In general they should be placed close to the code explained rather than before the entire block of code.
66

77
Comments should be as sentence like as possible, which is to say that they should be complete and readable, not in short hand.
88

99
Comments are not a replacement for detailed doc blocks. Comments serve to explain the logic and structure of code itself rather than the use of code.
1010

11-
## Formatting of Comments
11+
### Formatting of Comments
1212

1313
Comment blocks that introduce large sections of code and are more than 2 lines long should use `/* */` (C) style and should use `*` on each line with the same space/tab rules as doc blocks. If you need a large introduction consider whether this block should be separated into a method to reduce complexity and therefore providing a full docblock.
1414

@@ -22,7 +22,7 @@ Comments should align with the code they refer to, using the same indenting as t
2222

2323
Comments should be indented with tabs (like code, not like doc blocks).
2424

25-
## Content of comments
25+
### Content of comments
2626

2727
Comments should use en-GB (See below).
2828

@@ -46,23 +46,23 @@ Comments may include forward looking statements of how something will be extende
4646

4747
Remember that humor and sarcasm are difficult to translate.
4848

49-
## Acronyms
49+
### Acronyms
5050

5151
Capitalise all letters of acronyms such as HTML, XML, SQL, GMT, and UTC. This is an exception to the general use of en-GB rules.
5252

53-
## Common spelling and grammar errors for which to check.
53+
### Common spelling and grammar errors for which to check.
5454

5555
Joomla contributors include many non-native speakers of en-GB which makes it understandable that there are sometimes spelling and grammar errors. At the same time, some people reading comments also are non native speakers and may even use automated translation to understand comments. This makes it very important that comments should follow proper en-GB spelling and grammar rules. Unfortunately, these can be tricky.
5656

57-
Wikipedia provides a good summary of common differences between en-US and en-GB. http://en.wikipedia.org/wiki/American\_and\_British\_English\_spelling\_differences Note that there are some instances where en-GB common usage (but not actual rules) varies slightly from en-AU and using en-AU is considered acceptable.
57+
Wikipedia provides a good summary of [common differences between en-US and en-GB](http://en.wikipedia.org/wiki/American_and_British_English_spelling_differences). Note that there are some instances where en-GB common usage (but not actual rules) varies slightly from en-AU and using en-AU is considered acceptable.
5858

59-
### S vs Z
59+
#### S vs Z
6060

6161
en-GB most commonly uses `ise` where en-US would use `ize`, such as `normalise` instead of `normalize`. (Note that there are some exceptions to this rule and some differences between en-GB and en-AU in common usage.)
6262

6363
Use of apostrophes is one of the trickier parts of English.
6464

65-
### Lets versus let’s
65+
#### Lets versus let’s
6666

6767
Lets means permits or allows to:
6868

@@ -76,7 +76,7 @@ Let’s is a contraction for let us and means we are going to do this now:
7676
// Let's validate the field
7777
```
7878

79-
### Its versus it’s
79+
#### Its versus it’s
8080

8181
Its is the possessive form of it:
8282

@@ -90,8 +90,8 @@ It’s is a contraction of it is
9090
// It's time to save
9191
```
9292

93-
### The correct Joomla spelling of some commonly used words.
94-
95-
- Dependant
93+
#### The correct Joomla spelling of some commonly used words.
9694

95+
- dependant
96+
- deprecated
9797

manual/en-US/coding-standards/chapters/php.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ For example, do not include feature submissions like:
163163
//$code = broken($fixme);
164164
```
165165

166+
More details on inline code comments can be found in the chapter on [Inline Code Comments](coding-standards/chapters/inline-comments.md).
167+
166168
### Comment Docblocks
167169

168170
Documentation headers for PHP and Javascript code in files, classes, class properties, methods and functions, called the docblocks, follow a convention similar to JavaDoc or phpDOC.

manual/en-US/coding-standards/chapters/source-code-management.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
## Source Code Management
22

3-
Before we start talking about what code should look like, it is appropriate to look at how and where the source code is stored. All serious software projects, whether driven by an Open Source community or developed within a company for proprietary purposes will manage the source code is some sort of source or version management system.
3+
Before we start talking about what Joomla! code should look like, it is appropriate to look at how and where the source code is stored. All serious software projects, whether driven by an Open Source community or developed within a company for proprietary purposes will manage the source code is some sort of source or version management system. The Joomla project uses a Distributed Version Control System (DVCS) called Git hosted at [GitHub.com](http://github.com).
44

5-
## The Joomla Framework
5+
### The Joomla Framework
66

77
The [Joomla Framework](https://github.com/joomla/joomla-framework) is a PHP framework that is designed to serve as a foundation for not only web applications (like a CMS) but other types of software such as command line applications. The files that form the Joomla Framework are stored in a Distributed Version Control System (DVCS) called Git hosted at github.com
88

99
You can learn about how to get the Joomla Framework source code from the Git repository, https://github.com/joomla/joomla-framework.
1010

1111
Because Git treats the concepts of file revision numbers differently than Subversion, the repository revision number is not required in files (that is, the `@version` tag is not necessary).
1212

13-
## The Joomla CMS
13+
### The Joomla CMS
1414
The [Joomla! CMS](https://github.com/joomla/joomla-cms) is a Content Management System (CMS) which enables you to build Web sites and powerful online applications. It's a free and OpenSource software, distributed under the GNU General Public License version 2 or later. The files that form the Joomla CMS are stored in a Distributed Version Control System (DVCS) called Git hosted at github.com
1515

1616
You can learn about how to get the Joomla CMS source code from the Git repository, https://github.com/joomla/joomla-cms.

0 commit comments

Comments
 (0)