-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Add JsDoc for Class Contact #321
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job. Please follow my reviews.
docs/index.md
Outdated
|
||
**Kind**: global enum | ||
**Read only**: true | ||
**Export**: | ||
<a name="config_1"></a> | ||
|
||
## config_1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice here; there must be someplace mis-documented in the source code.
Please get rid of this.(by modifying code, instead of the auto-generated doc file)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After I modified as you requested, it has changed automatically, maybe it is correct now.
src/contact.ts
Outdated
/** | ||
* Enum for Gender values. | ||
* @readonly | ||
* @export |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you confirm that @readonly
& @export
here is necessary?
If so, please explain why.
As my understanding, this is not necessary at here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, keep it simple, only list the useful thing.
src/contact.ts
Outdated
export enum Gender { | ||
/** The Unknown value */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments here is not necessary: the code already can explain itself.
Also the following two: Male & Female.
* | ||
* `Contact` is `Sayable` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add example to each method.
like:
/**
* @example
* ```ts
* code here
* ```
*/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should add each method, some method like Contact.name()
, the code already can explain itself as Gender
you said.
I have added method Contact.find()
in this commit.
But your suggestion make sense, except method find
, I think I should add the following method:
- avatar()
- say()
What other functions do you think I should add too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not agree. The Document is different to the Code.
Examples can help users to understand easier how to use it rather than reading the API reference.
Now what you think it's obviously but for others are not, that's because you are too familiar with Wechaty.
I think to add examples for all API functions is necessary, but I'll leave this decision to you.
Please add examples to the APIs which you think is needed, leave it without example as you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, maybe I'm too familiar with Wechaty, so I add examples for all API functions.
And I added all the methods examples
src/contact.ts
Outdated
public name() { return UtilLib.plainText(this.obj && this.obj.name || '') } | ||
|
||
/** | ||
* Check if contact is strange |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is stranger.
src/contact.ts
Outdated
* @static | ||
* @param {ContactQueryFilter} [queryArg] | ||
* @returns {Promise<Contact[]>} | ||
* @description If use Contact.findAll() get the contact list of the bot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put @description at the beginning of the comment block.
Because the comments at the beginning of the comment block is default to be @description.
src/contact.ts
Outdated
* | ||
* @returns {(string | null)} | ||
* | ||
* @memberOf Contact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@memberOf
is not needed in ES6/Typescript.
Because the JsDoc is already known it is member of the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So your suggestion is to delete all @memberOf
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
Unless you have a reason for keeping it.
src/contact.ts
Outdated
* ``` | ||
* const contactFindByName = await Contact.find({ name:"ContactName"} ) | ||
* const contactFindByAlias = await Contact.find({ alias:"ContactAlias"} ) | ||
* ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specify the type of the example.
here should be:
```ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You did not follow my last reviews.
docs/index.md
Outdated
@@ -25,9 +25,8 @@ Wechaty.instance() // Singleton | |||
<p>Add/Del/Topic: <a href="https://github.com/wechaty/wechaty/issues/32">https://github.com/wechaty/wechaty/issues/32</a></p> | |||
</dd> | |||
<dt><a href="#Contact">Contact</a></dt> | |||
<dd><p>Class Contact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not commit the new docs/index.md in this PR.
Because this is not necessary.
Please only commit the code file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't commit docs/index.md in this PR any more.
src/contact.ts
Outdated
* | ||
* @returns {string | ''} | ||
* | ||
* @memberOf Contact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't commit yet after your comment...
src/contact.ts
Outdated
* | ||
* @returns {string | ''} | ||
* | ||
* @memberOf Contact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@memberof is not necessary as we discussed.
No, you are not done. Please mark all my reviews as I noticed that there has some reviews you did not reply/react. |
How about this time? |
I don't know. Please tell me you are done after you are done. |
done |
I'm sorry.... I thought I used wrong git command... But I thought your bot can generate the docs automatically. |
No, you are not done.
|
done |
Not yet. |
I'm not sure which haven't done....
So could you tell me more? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fulfill all the return type for functions, and make sure the function body is returning the right type.
src/contact.ts
Outdated
/** | ||
* Get the weixin number from a contact | ||
* Sometimes cannot get weixin number due to weixin security mechanism, not recommend. | ||
* @returns {string | ''} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@returns {string}
or {string|null} is better, for null is standing for we can not get the wexin id.
src/contact.ts
Outdated
* ```ts | ||
* const weixin = contact.weixin() | ||
* ``` | ||
*/ | ||
public weixin() { return this.obj && this.obj.weixin || '' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public weixin(): string
or
public wexin(): string | null
src/contact.ts
Outdated
/** | ||
* Get the name from a contact | ||
* | ||
* @returns {string | ''} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@returns {string}
src/contact.ts
Outdated
* ```ts | ||
* const isStranger = contact.stranger() | ||
* ``` | ||
*/ | ||
public stranger() { return this.obj && this.obj.stranger } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public stranger(): boolean
and make sure the function is return a type of boolean
src/contact.ts
Outdated
* ```ts | ||
* const isStar = contact.star() | ||
* ``` | ||
*/ | ||
public star() { return this.obj && this.obj.star } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public star(): boolean
and make sure the function is return a type of boolean
src/contact.ts
Outdated
* @example | ||
* ```ts | ||
* const gender = contact.gender() | ||
* ``` | ||
*/ | ||
public gender() { return this.obj ? this.obj.sex : Gender.Unknown } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public gender(): Gender
done |
You still leave one review unresolved. But it's ok, I'll merge this PR now. |
BTW: there's a bug that causing the unit test failed, it seems related to the PR from you recently. Please have a look when you have time. Thanks. |
Could you tell me how to resolve the review? |
I do not know because I can not see your account. |
#73
#252
use JsDoc to generate contact doc here.
Doc: Contact