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 jsdoc #227

Merged
merged 6 commits into from Mar 20, 2020
Merged

docs: add jsdoc #227

merged 6 commits into from Mar 20, 2020

Conversation

NateScarlet
Copy link
Contributor

这样可以直接在 IDE 里面看文档

image

@@ -17,7 +17,7 @@
"dependencies": {
"diff-match-patch": "^1.0.4"
},
"types": "src/ts/types/index.d.ts",
"types": "dist/index.d.ts",
Copy link
Owner

Choose a reason for hiding this comment

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

必须要放到 dist 下面么?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

webpack 打包默认输出在 index.js 旁边

Copy link
Contributor Author

Choose a reason for hiding this comment

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

src 里面的这个不是完整类型定义啊

Copy link
Owner

Choose a reason for hiding this comment

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

我把2个合并了,要不要维护2份,webpack 打包那个我删了,我看你又加上了。。。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

源码就是typescript的部分为啥还要手动维护一个.d.ts 直接webpack生成的就是最新的类型定义啊

我做完之后rebase的dev分支 没注意到这个更改

src/ts/types/index.d.ts 里面不需要写 Vditor 的定义的 因为tsc会自动生成

Copy link
Owner

Choose a reason for hiding this comment

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

要怎么配置才会生成?我的这个上次配置了下,不会自动生成。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

要怎么配置才会生成?我的这个上次配置了下,不会自动生成。

https://github.com/TypeStrong/ts-loader#declarations-dts
tsconfig.json 加 declaration: true 就行

@@ -5,17 +5,7 @@ import {Hint} from "./ts/hint/index";
import {IR} from "./ts/ir";
import {input as irInput} from "./ts/ir/input";
import {processAfterRender} from "./ts/ir/process";
import {abcRender} from "./ts/markdown/abcRender";
Copy link
Owner

@Vanessa219 Vanessa219 Mar 20, 2020

Choose a reason for hiding this comment

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

这些删除了的目的是?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

和 method.ts 代码重复 直接复用避免维护2份文档

Copy link
Owner

Choose a reason for hiding this comment

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

文档可以写在 type 上么?

method 是提供给不需要编辑器,只渲染 UI 时使用的。

使用编辑器只引用一个,2 个引入的话不使用 import ,变量会冲突。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

文档写在type上指什么

要是写在函数上是看不到的 因为class里面是赋值 赋值看到的文档是字段的文档不是值的文档

Copy link
Contributor Author

Choose a reason for hiding this comment

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

要是不删就是重复代码一边有文档一边没文档

Copy link
Owner

Choose a reason for hiding this comment

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

就是把注释写在 index.d.ts 上,我试了下,应该可以的。
image
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

interface的文档我都是这么写的啊

但是class不删重复的就要写两遍

@NateScarlet
Copy link
Contributor Author

好像没法在不重构类型定义的情况下实现完美的.d.ts构建

我下周再研究下

@NateScarlet NateScarlet reopened this Mar 20, 2020
@NateScarlet
Copy link
Contributor Author

图片

原来模块的reference会相对于package.json 的types文件解析
这样我这个配置就是对的

你直接 npm run build 就会有自动生成的定义了

@Vanessa219 Vanessa219 merged commit 3fa8a74 into Vanessa219:dev Mar 20, 2020
@Vanessa219 Vanessa219 added this to the 3.0.0 milestone Mar 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants