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

docs: add script for building standard lib docs #432

Merged
merged 9 commits into from
Dec 30, 2019
Merged

Conversation

antfu
Copy link
Member

@antfu antfu commented Dec 30, 2019

Resolves #383

This approach adds a script to auto-generate standard lib docs from comments. The format would look like this:

疏曰「「餘弦。同犀之Math.cos也。」」

You can see the rendered Standard Library Cheatsheet here


Thanks for help from @statementreply

@antfu antfu marked this pull request as ready for review December 30, 2019 12:06
@LingDong-
Copy link
Member

LingDong- commented Dec 30, 2019

Nice! two thoughts:

  • I heard that 疏 is a comment to 注, so not sure if it is correct usage here. Perhaps using 注 is good enough since we can regex on the content of the comment?

  • I think we can simply spell out "JavaScript" instead of 犀, since we're already using latin alphabet to write Math.cos etc.

Thanks!

EDIT: A third thought:

  • Perhaps we should not limit it to JavaScript equivalence, since we might add features that JS lacks direct support. One solution is that we can write a small JS function inside the comment that does the same thing, but I think it would be better if we allow any general description in the comment?

@antfu
Copy link
Member Author

antfu commented Dec 30, 2019

I heard that 疏 is a comment to 注, so not sure if it is correct usage here. Perhaps using 注 is good enough since we can regex on the content of the comment?

The original idea for this is to distinguish with the other comments in the file. And yes as you said, since the regex is strict enough, it won't be messed up with the others. I have replaced them to 注 now.

think we can simply spell out "JavaScript" instead of 犀

Sure. Replaced.

Perhaps we should not limit it to JavaScript equivalence, since we might add features that JS lacks direct support. One solution is that we can write a small JS function inside the comment that does the same thing, but I think it would be better if we allow any general description in the comment?

Yes. I was just thinking the same thing. Thing like 求和 in 籌經 has not Javascript stdlib (should use reduce((a,b)=>a+b)) and can be better expressed in Python as sum.

But if we add a Python Equivalent then it will be double the workload. And it will also be other languages to support.

For this, maybe we can do something like Pseudo code. If so, we may also consider using it the Syntax Cheatsheet.

@LingDong- LingDong- merged commit 1aaf8f6 into master Dec 30, 2019
@antfu antfu mentioned this pull request Dec 30, 2019
@antfu antfu deleted the docs/stdlib branch December 31, 2019 07:07
LingDong- added a commit that referenced this pull request Jan 20, 2020
docs: add script for building standard lib docs
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.

Standard Library Cheatsheet
3 participants