-
Notifications
You must be signed in to change notification settings - Fork 237
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
Improve Docs: contact part #289
Conversation
GaryDu0123
commented
Jan 4, 2022
- 将JavaScript代码替换为python代码
- 将文档翻译为中文
- 小幅度修改了文档结构
…translate the docs to Chinese
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.
Your improvement is great. Are you interested in writing documentation for other modules? If so, it will be a great thing.
Sure, that will be my pleasure, I will request a new pr after I complete |
I’m very glad to hear that. Our document and code need a lot of improvements which are opened for developers. So there are many challenging improvements on docs and codes. Back to the point, you can put all changes at here and modify the title of pr. We are looking forward to your future great works. Please go head and feel free to discuss with us at here. |
OK, I will change this PR title, and try to improve the |
Almost done, but I am not yet familiar with the methods and attributes in |
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.
Your improvements are so great, I think it will make a big change on docs of python-wechaty. Here are some suggestions about some detailed problem. Let's discuss about it.
docs/references/contact-self.md
Outdated
* [contactSelf.qrcode\(\) ⇒ `Promise <string>`](contact-self.md#contactselfqrcode-⇒-promise) | ||
* [contactSelf.signature\(signature\) ⇒ `Promise <string>`](contact-self.md#contactselfsignaturesignature) | ||
* [contactSelf.name\(\[name\]\) ⇒ `Promise <void> | string`](contact-self.md#contactselfname-⇒-promisestring) | ||
* [contactSelf.avatar\(\[file\]\) ⇒ `None | FileBox`](contact-self.md#contactselfavatarfile-⇒-promise) |
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 are some suggestions:
- the variable should be all lower case by python naming conventions. So the
contactSelf
should becontact_self
that you can change lots of variables. How do you think about it? - If the method is async-based, the typing of return result should be
Coroutine
, please refer to:- Document how to type hint for an async function used as a callback python/typing#424
- Coroutine functions should return Coroutine, not Awaitable python/mypy#3569
- So, I suggest that the return type annotation of async method is:
Coroutine[..., ..., ...]
- if the result is
None | FileBox
which is the program language gramar in ts, it shoule be: Optional[Filebox]
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.
@GaryDu0123 there are some discussion topic in outline comment, we can get deep into discussion about one of topic as sub-comment. eg this comment is the sub-comment about type annotations.
If you can not understand, let use the generated stubfile type annotation in pyi file. For example:
Here is the generated stubfile with subgen
tools. You can have a detail look. The following code is the example:
class ContactSelf(Contact):
async def avatar(self, file: Optional[FileBox] = ...) -> FileBox: ...
async def qr_code(self) -> str: ...
@property
def name(self) -> str: ...
@name.setter
def name(self, name: Optional[str]) -> None: ...
async def signature(self, signature: str) -> Any: ...
The suggested command is:
# install the mypy and stubgen tools
pip install mypy
# generate stubfiles
stubgen -o ./src ./src
Please feel free to discuss more about this problem.
Wechaty Contributors NominationLink to wechaty/PMC#16 |
Yea, I think you are right, it should be like |
I was trying to find the description of using |
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 have done a great improvement on docs, and it takes a while to read this. But here are some details to discuss, please read it and try to make another change. Looking forward to your next commit.
docs/references/contact-self.md
Outdated
|
||
### contactSelf.avatar\(\[file\]\) ⇒ `Promise <void | FileBox>` | ||
### async def avatar(self, file: `Optional[FileBox]` = None) ⇒ `FileBox` |
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 type of return result is Optinal[FileBox]
.
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 give a mention it by the way that it's more elegant to use overload
at here which will make code clear and code complete more precise. The example code is:
@overload
async def avatar(self) -> FileBox: ...
@overload
async def avatar(self, file: FileBox) -> None: ...
There are many method should be refactored. If you have any interest at this python trick, It's will be great for you and python-wechaty.
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.
Cool, I like the @overload
way hahaha, thanks for your mention, I will modify my commit
ping @GaryDu0123 Looking forward to your new commit to fix the above issue. |
coooool |
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.
LGTM
@huan Can I join Wechaty Contributor Program? |
Of course, and thank you very much for your contribution! You are welcome to join Wechaty Contributor Program1. Join Wechaty Organization
I have invited you to join our Wechaty GitHub Organization, please accept it by following the above message. (See also: wechaty/PMC#16) 2. Update Your Wechaty Contributor Profile
3. Join The Contributor Only WeChat RoomWe also have a WeChat room for contributors only which can discuss Wechaty at a deeper level, you are welcome to join and if you are interested. Please add @lijiarui wechat: ruirui_0914 and send her this pr link. She will invite you into Wechaty Contributor Room Cheers! |
thanks |