Skip to content
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

Merged
merged 15 commits into from
Mar 13, 2017
Merged

Add JsDoc for Class Contact #321

merged 15 commits into from
Mar 13, 2017

Conversation

lijiarui
Copy link
Member

#73
#252
use JsDoc to generate contact doc here.
Doc: Contact

Copy link
Member

@huan huan left a 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
Copy link
Member

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)

Copy link
Member Author

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
Copy link
Member

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.

Copy link
Member Author

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 */
Copy link
Member

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`
Copy link
Member

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
 * ```
 */

Copy link
Member Author

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?

Copy link
Member

@huan huan Mar 13, 2017

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.

Copy link
Member Author

@lijiarui lijiarui Mar 13, 2017

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
Copy link
Member

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.
Copy link
Member

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
Copy link
Member

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.

Copy link
Member Author

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 ?

Copy link
Member

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"} )
* ```
Copy link
Member

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

Copy link
Member

@huan huan left a 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
Copy link
Member

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.

Copy link
Member Author

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Member Author

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
Copy link
Member

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.

@lijiarui
Copy link
Member Author

lijiarui commented Mar 13, 2017

@zixia
done all of your request.

  • @memberof
    removed all @memberOf
  • example
    You are right, maybe I'm too familiar with Wechaty, so I add examples for all API functions.

@huan
Copy link
Member

huan commented Mar 13, 2017

No, you are not done.

Please mark all my reviews as resolved after you confirmed it is resolved.

I noticed that there has some reviews you did not reply/react.

@lijiarui
Copy link
Member Author

How about this time?

@huan
Copy link
Member

huan commented Mar 13, 2017

I don't know.

Please tell me you are done after you are done.

@lijiarui
Copy link
Member Author

done

@lijiarui
Copy link
Member Author

lijiarui commented Mar 13, 2017

I'm sorry....

I thought I used wrong git command...
I should use git rm –cached instead of git rm to delete index instead of delete both index and the file.

But I thought your bot can generate the docs automatically.

@huan
Copy link
Member

huan commented Mar 13, 2017

No, you are not done.

  1. you leave one un-resolved review.
  2. you should not commit the file docs/index.md. this time you still commit it, with worse behaviour: deleted it. I need your PR only include one file modification instead of two.

@lijiarui
Copy link
Member Author

done

@huan
Copy link
Member

huan commented Mar 13, 2017

Not yet.

@lijiarui
Copy link
Member Author

lijiarui commented Mar 13, 2017

I'm not sure which haven't done....

1.you leave one un-resolved review.
2.you should not commit the file docs/index.md. this time you still commit it, with worse behaviour: deleted it. I need your PR only include one file modification instead of two.

  1. I have replyed your example review and added all methods examples in c367b99
  2. I have recovered file I deleted in 1e16c0b

So could you tell me more?
Thanks.

Copy link
Member

@huan huan left a 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 | ''}
Copy link
Member

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 || '' }
Copy link
Member

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 | ''}
Copy link
Member

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 }
Copy link
Member

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 }
Copy link
Member

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 }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public gender(): Gender

@huan
Copy link
Member

huan commented Mar 13, 2017

Last time you leave this review unresolved:

image

@lijiarui
Copy link
Member Author

done fulfill all the return type for functions...
But I'm not sure whether I have resolved the example review...
Could you tell me?
Thanks

@huan
Copy link
Member

huan commented Mar 13, 2017

You still leave one review unresolved.

But it's ok, I'll merge this PR now.

@huan
Copy link
Member

huan commented Mar 13, 2017

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.

@huan huan merged commit b3a876d into wechaty:master Mar 13, 2017
@lijiarui
Copy link
Member Author

Could you tell me how to resolve the review?
Thanks

@huan
Copy link
Member

huan commented Mar 13, 2017

I do not know because I can not see your account.

@lijiarui lijiarui deleted the testDoc branch March 27, 2017 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants