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

build: format docs in pre-commit #681

Merged
merged 5 commits into from
Jun 14, 2023

Conversation

a631807682
Copy link
Member

@a631807682 a631807682 commented Jun 5, 2023

What type of PR is this?

build

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.

(Optional) Translate the PR title into Chinese.

通过 pre-commit hook 格式化文档

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
At present, the document format is not uniform, especially for Chinese documents. The space between letters/Chinese/numbers depends on code review, which is a waste of manpower and easy to miss.
This PR avoids such problems by automatically fixing the format in pre-commit, and returning an error message to allow contributors to check whether the document fixes meet expectations, and then commit.
zh(optional):
目前文档格式不太统一,特别是中文文档,关于字母/中文/数字之间的空格依赖于 CR ,浪费人力也容易遗漏。
这个 PR 通过在 pre-commit 中自动修复格式,并返回错误信息让贡献者检查文档修复是否符合预期,再进行提交来避免这样的问题。

...
fixing file content/en/docs/hertz/tutorials/toolkit/usage/usage-protobuf.md
fixing file content/en/docs/hertz/tutorials/toolkit/usage/usage-thrift.md
fixing file content/en/docs/hertz/tutorials/toolkit/usage/usage.md

Proper commits require formatted documentation.
The document has been automatically repaired, please check whether the formatted document is as expected.

由于文档太多, 我只检查了 hertz 文档中文部分的修改,因此只开了 hertz 文档等格式化。

(Optional) Which issue(s) this PR fixes:

@a631807682 a631807682 requested review from a team as code owners June 5, 2023 07:00
@vercel
Copy link

vercel bot commented Jun 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cloudwego ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 13, 2023 9:26am

@a631807682 a631807682 changed the title build: format docs in pre-commit build(WIP): format docs in pre-commit Jun 5, 2023
@a631807682 a631807682 changed the title build(WIP): format docs in pre-commit build: format docs in pre-commit Jun 5, 2023
@GuangmingLuo GuangmingLuo linked an issue Jun 5, 2023 that may be closed by this pull request
package.json Outdated Show resolved Hide resolved
@rogerogers
Copy link
Contributor

整体效果感觉不如prettier,prettier使用起来也比较傻瓜式

image

@a631807682
Copy link
Member Author

整体效果感觉不如prettier,prettier使用起来也比较傻瓜式

image

这个倒无所谓,将 lint.js 改一下或者使用 prettier 指令就行了。

prettier/language-markdown/parser-markdown.js#L29 使用的是 unifiedjs - > remarkjs -> syntax-tree,实际上会修复更多的问题,确实有利于后续的格式化,这也意味着更多的变更,以及变更带来的 CR 工作,我开始是直接用 remark 做然后变更太多看不过来。打个比分,我们文档使用了大量数学公式,里面包含未转义字符10 * 20 * 30,实际上应该是10 \* 20 \* 30,疑问*是有特殊含义的,但是更改比较多实在看不过来。

@GuangmingLuo
Copy link
Member

@a631807682 Please resolve conflicts

@a631807682
Copy link
Member Author

@a631807682 Please resolve conflicts

done

@li-jin-gou
Copy link
Member

感谢 PR,关于字母/中文/数字之间的空格不规范问题在 CR 的时候很常见❤️,我这里看了一下没什么问题, @GuangmingLuo @rogerogers 可以再看下。

@GuangmingLuo GuangmingLuo merged commit 6c06667 into cloudwego:main Jun 14, 2023
4 checks passed
@a631807682 a631807682 deleted the build_commit_vaild branch June 14, 2023 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants