-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AngularJSプロジェクトにおけるngdoc・jsdocルール案 #65
Comments
必ずなルール
|
|
|
|
|
|
AngularJS | Angular Material | ionic |
---|---|---|
string | string | string |
boolean | boolean | boolean |
Function | function | function / Function |
number | number | number |
Object | object | object/Object |
DOMElement /Element | el | HTMLElement |
expression | expression | expression |
Error | 使用箇所なし | 使用箇所なし |
RegExp | 使用箇所なし | 使用箇所なし |
Array | 使用箇所なし | 使用箇所なし |
DOMEvent | ||
int | ||
Promise/promise |
typeの表現を以下に決めてみた
type |
---|
string |
boolean |
Function |
number |
Object |
DOMElement |
expression |
Error |
RegExp |
Array |
Promise |
色々探したところだとこれが一番まとまっているかも?
http://www38.atwiki.jp/aias-jsstyleguide2/pages/17.html#id_6f37ee9a
その他のTips
複数の型を指定したいとき
|
でtypeをつなぐ
@param {string|DOMElement}
絶対にnullでない値であることを指定したいとき
!
をtypeの先頭に書く
@param {!Object}
省略可能な値(undefinedを許す)であることを指定したいとき
=
をtypeの後方に書く
@param {Object=}
nullとundefinedを意識した型定義
/**
* 4つの引数を取ります。そのうち2つはnullを許容し、2つは省略可能です。
* @param {!Object} nonNull 必須(undefinedは不可)、nullは不可。
* @param {Object} mayBeNull 必須(undefinedは不可)、nullでもよい。
* @param {!Object=} opt_nonNull 省略可 (undefinedでもよい)、しかし値があるなら、
* それはnullであってはならない!
* @param {Object=} opt_mayBeNull 省略可 (undefinedでもよい)、nullでもよい。
*/
function strangeButTrue(nonNull, mayBeNull, opt_nonNull, opt_mayBeNull) {
// ...
};
|
|
ルールまとめ
アノテーションで必ず意識するべきアノテーション7選
|
@ngdoc |
@name |
@module |
@description |
@restrict |
@param |
@returns |
---|---|---|---|---|---|---|
module | ○ | × | ○ | × | × | × |
directive | ○ | ○ | ○ | ○ | △ | × |
service | ○ | ○ | ○ | × | △ | ○ |
provider | ○ | ○ | ○ | × | × | △ |
filter | ○ | ○ | ○ | × | ○ | ○ |
object | ○ | ○ | ○ | × | × | × |
これ以外のアノテーション
- 書かなくても良い
- 書いてあった方がもちろん良い
ポイント
文献
The text was updated successfully, but these errors were encountered: