You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: manual/zh-TW/coding-standards/chapters/docblocks.md
+58-61Lines changed: 58 additions & 61 deletions
Original file line number
Diff line number
Diff line change
@@ -1,32 +1,32 @@
1
-
## DocBlocks
1
+
## 區塊註解
2
2
3
-
Documentation headers for PHP code in: files, classes, class properties, methods and functions, called the docblocks, follow a convention similar to JavaDoc or phpDOC.
Whereas normal code indenting uses real tabs, all whitespace in a Docblock uses real spaces. This provides better readability in source code browsers. The minimum whitespace between any text elements, such as tags, variable types, variable names and tag descriptions, is two real spaces. Variable types and tag descriptions should be aligned according to the longest Docblock tag and type-plus-variable respectively.
Code contributed to the Joomla project that will become the copyright of the project is not allowed to include @authortags. You should update the contribution log in CREDITS.php. Joomla's philosophy is that the code is written "all together" and there is no notion of any one person "owning" any section of code. The @authortags are permitted in third-party libraries that are included in the core libraries.
Files included from third party sources must leave DocBlocks intact. Layout files use the same DocBlocks as other PHP files.
11
+
第三方程式資源編碼必須要留下完整的註解檔說明,說明註解寫法必須與其他PHP文件相同。
12
12
13
-
### File DocBlock Headers
14
-
The file header DocBlock consists of the following required and optional elements in the following order:
15
-
Short description (optional unless the file contains more than two classes or functions), followed by a blank line). Long description (optional, followed by a blank line).
13
+
### 區塊註解開頭
14
+
文件區塊註解開頭必須按照以下必填或非必填規則。
15
+
簡短說明 (非必填,除非該文件包含兩個以上的物件或函數,結尾處需要斷行)。
16
+
詳細說明 (非必填,結尾處需要斷行)。
16
17
17
-
*@category (optional and rarely used)
18
-
*@package (generally optional but required when files contain only procedural code)
19
-
*@subpackage (optional)
20
-
*@author (optional but only permitted in non-Joomla source files, for example, included third-party libraries like Geshi)
21
-
*@copyright (required)
22
-
*@license (required and must be compatible with the Joomla license)
23
-
*@deprecated (optional)
24
-
*@link (optional)
25
-
*@see (optional)
26
-
*@since (generally optional but required when files contain only procedural code)
Class definitions start on a new line and the opening and closing braces are also placed on new lines. Class methods must follow the guidelines for Function Definitions. Properties and methods must follow OOP standards and be declared appropriately (using public, protected, private and static as applicable).
42
-
Class definitions, properties and methods must each be provided with a DocBlock in accordance with the following sections.
43
-
44
-
#### Class DocBlock Headers
45
-
The class Docblock consists of the following required and optional elements in the fol-lowing order.
46
-
Short description (required, unless the file contains more than two classes or functions), followed by a blank line). Long description (optional, followed by a blank line).
47
-
*@category (optional and rarely used)
48
-
*@package (required)
49
-
*@subpackage (optional)
50
-
*@author (optional but only permitted in non-Joomla source files, for example, included third-party libraries like Geshi)
51
-
*@copyright (optional unless different from the file Docblock)
52
-
*@license (optional unless different from the file Docblock)
53
-
*@deprecated (optional)
54
-
*@link (optional)
55
-
*@see (optional)
56
-
*@since (required, being the version of the software the class was introduced)
* Controller class to initialise the database for the Joomla Installer.
@@ -66,16 +66,15 @@ Example of a Class file DocBlock header:
66
66
*/
67
67
```
68
68
69
-
#### Class Property DocBlocks
70
-
The class property Docblock consists of the following required and optional elements in the following order.
71
-
Short description (required, followed by a blank line)
72
-
73
-
*@var (required, followed by the property type)
74
-
*@deprecated (optional)
75
-
*@since (required)
69
+
#### 物件屬性區塊註解:
70
+
物件屬性區塊註解定義必須按照以下區塊註解條件規則。
71
+
簡短說明 (非必填,結尾處需要斷行)。
76
72
77
-
Example of Class property DocBlock:
73
+
*@var (必填,必須是屬性類型)
74
+
*@deprecated (非必填)
75
+
*@since (必填)
78
76
77
+
物件屬性區塊註解的範例:
79
78
```php
80
79
/**
81
80
* The generated user ID
@@ -86,20 +85,18 @@ Example of Class property DocBlock:
86
85
protected static $userId = 0;
87
86
```
88
87
88
+
#### 物件方法區塊註解和函式區塊註解
89
+
函數必須在一個新的行列和結束括號也放在新行列。空行應先行指定的返回值。
89
90
91
+
函數定義必須按照以下區塊註解條件規則。
90
92
91
-
#### Class Method DocBlocks and Functions DocBlocks
92
-
Function definitions start on a new line and the opening and closing braces are also placed on new lines. An empty line should precede lines specifying the return value.
93
-
94
-
Function definitions must include a documentation comment in accordance with the Commenting section of this document.
95
-
96
-
* Short description (required, followed by a blank line)
97
-
* Long description (optional, followed by a blank line)
98
-
*@param (required if there are method or function arguments, the last @param tag is followed by a blank line)
99
-
*@return (required, followed by a blank line)
100
-
* All other tags in alphabetical order, however @since is always required.
93
+
* 簡短說明 (必填,結尾處需要斷行)
94
+
* 詳細說明 (非必填,結尾處需要斷行)
95
+
*@param (必填,如果有方法或函數參數,最後 @param 標籤後面跟著一個斷行)
96
+
*@return (必填,結尾處需要斷行)
97
+
* 其他標籤須按字母排序,不管怎樣一定要有 @since
101
98
102
-
Example of Method DocBlock:
99
+
函數註解範例:
103
100
```php
104
101
/**
105
102
* Set a controller class suffix for a given HTTP method.
@@ -118,10 +115,10 @@ Example of Method DocBlock:
118
115
public function setHttpMethodSuffix($method, $suffix)
119
116
```
120
117
121
-
If a function definition goes over multiple lines, all lines must be indented with one tab and the closing brace must go on the same line as the last parameter.
0 commit comments