From cc32a95b72adfda27ca77da5efe43f7a4da57b0d Mon Sep 17 00:00:00 2001 From: Huan LI Date: Wed, 15 Feb 2017 20:30:42 +0800 Subject: [PATCH] add all main class to docs --- docs/index.md | 123 +++++++++++++++++++++++++++++++++++++++++++++++-- package.json | 2 +- src/contact.ts | 16 +++---- 3 files changed, 126 insertions(+), 15 deletions(-) diff --git a/docs/index.md b/docs/index.md index 271ee62e..1b090442 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,3 +1,46 @@ +## Classes + +
+
Wechaty
+

Wechaty: Wechat for ChatBots. +Connect ChatBots

+

Class Wechaty

+

Licenst: ISC +https://github.com/zixia/wechaty

+

Example

+
// The World's Shortest ChatBot Code: 6 lines of JavaScript
+const { Wechaty } = require('wechaty')
+
+Wechaty.instance() // Singleton
+.on('scan', (url, code) => console.log(`Scan QR Code to login: ${code}\n${url}`))
+.on('login',       user => console.log(`User ${user} logined`))
+.on('message',  message => console.log(`Message: ${message}`))
+.init()
+
+
+
Room
+

wechaty: Wechat for Bot. and for human who talk to bot/robot

+

Licenst: ISC +https://github.com/zixia/wechaty

+

Add/Del/Topic: https://github.com/wechaty/wechaty/issues/32

+
+
Contact
+

Class Contact +blabla... +IMPORTANT

+
+
+ +## Constants + +
+
config_1
+

Wechaty: Wechaty - Wechat for Bot. Connecting ChatBots

+

Licenst: ISC +https://github.com/wechaty/wechaty

+
+
+ ## Wechaty @@ -29,12 +72,12 @@ Wechaty.instance() // Singleton * [Wechaty](#Wechaty) * _instance_ * [.version([forceNpm])](#Wechaty+version) ⇒ string - * ~~[.user()](#Wechaty+user) ⇒ Contact~~ + * ~~[.user()](#Wechaty+user) ⇒ [Contact](#Contact)~~ * [.init()](#Wechaty+init) * [.on()](#Wechaty+on) * [.quit()](#Wechaty+quit) * [.logout()](#Wechaty+logout) - * [.self()](#Wechaty+self) ⇒ Contact + * [.self()](#Wechaty+self) ⇒ [Contact](#Contact) * [.send()](#Wechaty+send) * [.say()](#Wechaty+say) * [.sleep()](#Wechaty+sleep) @@ -62,7 +105,7 @@ console.log(Wechaty.instance().version()) ``` -### ~~wechaty.user() ⇒ Contact~~ +### ~~wechaty.user() ⇒ [Contact](#Contact)~~ ***Deprecated*** **Kind**: instance method of [Wechaty](#Wechaty) @@ -104,11 +147,11 @@ console.log(Wechaty.instance().version()) -### wechaty.self() ⇒ Contact +### wechaty.self() ⇒ [Contact](#Contact) get current user **Kind**: instance method of [Wechaty](#Wechaty) -**Returns**: Contact - current logined user +**Returns**: [Contact](#Contact) - current logined user ### wechaty.send() @@ -139,3 +182,73 @@ get current user get the singleton instance of Wechaty **Kind**: static method of [Wechaty](#Wechaty) + + +## Room +wechaty: Wechat for Bot. and for human who talk to bot/robot + +Licenst: ISC +https://github.com/zixia/wechaty + +Add/Del/Topic: https://github.com/wechaty/wechaty/issues/32 + +**Kind**: global class + + +### Room.load() +**Kind**: static method of [Room](#Room) +**Todo** + +- [ ] document me + + + +## Contact +Class Contact +blabla... +**IMPORTANT** + +**Kind**: global class + +* [Contact](#Contact) + * _instance_ + * [.gender()](#Contact+gender) ⇒ + * [.avatar()](#Contact+avatar) + * _static_ + * [.findAll()](#Contact.findAll) + * [.find()](#Contact.find) + + + +### contact.gender() ⇒ +Contact gender + +**Kind**: instance method of [Contact](#Contact) +**Returns**: Gender.Male(2) | Gender.Female(1) | Gender.Unknown(0) + + +### contact.avatar() +Get avatar picture file stream + +**Kind**: instance method of [Contact](#Contact) + + +### Contact.findAll() +find contact by `name` or `alias` + +**Kind**: static method of [Contact](#Contact) + + +### Contact.find() +try to find a contact by filter: {name: string | RegExp} + +**Kind**: static method of [Contact](#Contact) + + +## config_1 +Wechaty: * * Wechaty - Wechat for Bot. Connecting ChatBots + +Licenst: ISC +https://github.com/wechaty/wechaty + +**Kind**: global constant diff --git a/package.json b/package.json index 901a0500..e13762a5 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "ava": "ava --verbose --extension ts", "ts-node": "ts-node", "dist": "npm run clean && tsc && shx cp package.json dist/ && shx cp src/puppet-web/*.js dist/src/puppet-web/", - "doc": "npm run dist && jsdoc2md dist/src/wechaty.js > docs/index.md", + "doc": "npm run dist && jsdoc2md dist/src/{wechaty,room,contact,friend-request,message}.js > docs/index.md", "coverage": "nyc report --reporter=text-lcov | coveralls", "changelog": "github_changelog_generator -u wechaty -p wechaty && sed -i /greenkeeper/d CHANGELOG.md", "doctor": "npm run check-node-version && ts-node bin/doctor", diff --git a/src/contact.ts b/src/contact.ts index bdec798a..a67727ff 100644 --- a/src/contact.ts +++ b/src/contact.ts @@ -1,11 +1,3 @@ -/** - * - * wechaty: Wechat for Bot. and for human who talk to bot/robot - * - * Licenst: ISC - * https://github.com/zixia/wechaty - * - */ import { Config , Sayable @@ -61,6 +53,12 @@ export type ContactQueryFilter = { remark?: string | RegExp } +/** + * Class Contact + * blabla... + * **IMPORTANT** + * + */ export class Contact implements Sayable { private static pool = new Map() @@ -115,7 +113,7 @@ export class Contact implements Sayable { public star() { return this.obj && this.obj.star } /** * Contact gender - * @return Gender.Male(2) | Gender.Female(1) | Gender.Unknown(0) + * @returns Gender.Male(2) | Gender.Female(1) | Gender.Unknown(0) */ public gender() { return this.obj ? this.obj.sex : Gender.Unknown } public province() { return this.obj && this.obj.province } -- GitLab