简体   繁体   English

如何为使用箭头函数的 class 方法的参数生成 jsdoc?

[英]How to get jsdoc generation for parms of class methods that use arrow functions?

I'm a student who's capstone project/work intergrated learning is about to end.我是一名学生,其顶点项目/工作综合学习即将结束。 I'm working on producing technical documentation to hand off to the next team that will continue on with this work, but I've hit a snag.我正在制作技术文档,以便将继续进行这项工作的下一个团队交给下一个团队,但我遇到了障碍。

My class methods that use arrow functions aren't generating params documentation when I create documentation using the jsdoc tool.当我使用jsdoc工具创建文档时,使用箭头函数的 class 方法不会生成 params 文档。

ie: IE: 源代码中的文档图像。 becomes变成生成的 jsdoc 输出的图像。

The documentation works as intended in visual studio code/intellisense:该文档在 Visual Studio 代码/智能感知中按预期工作: 文档的图像在参数的 Visual Studio 代码中正确工作

I've been googling around to try and figure out what the problem was, but I failed to find anything.我一直在谷歌搜索试图找出问题所在,但我没有找到任何东西。

I mean, my research yielded:我的意思是,我的研究得出:

Of note is that I'm using the jsdoc-export-default-interop plugin so that jsdoc will actually generate things for export default [CLASS OR FUNCTION] .值得注意的是,我使用的是jsdoc-export-default-interop插件,因此 jsdoc 实际上会为export default [CLASS OR FUNCTION]生成东西。

I've found a solution that fits my requirements我找到了符合我要求的解决方案

However, while it is good enough for my purposes, I'm not entirely sure it's acurate and would be happy to hear critisims, other people's viewpoints and solutions.然而,虽然它对我的目的来说已经足够好了,但我并不完全确定它是否准确,并且很乐意听到批评、其他人的观点和解决方案。 I'll explain the concerns I have at the end.我将在最后解释我的担忧。

The problem: It looks like jsdoc cannot automatically detect if a member assignment is a function when parsing.问题:在解析时,jsdoc 似乎无法自动检测成员分配是否为 function。

I have no idea why VSCode is able to detect it automatically, but it appears the JSDoc tool cannot.我不知道为什么 VSCode 能够自动检测到它,但似乎 JSDoc 工具不能。 Here it is stated in the official documentation这里在官方文档中有说明文档图片 Link to documentation: ( https://jsdoc.app/tags-function.html )文档链接:( https://jsdoc.app/tags-function.html

The solution: Document the member with the @function tag (or an alias like @method ).解决方案:使用@function标记(或类似@method的别名)记录成员。

By documenting the class member with the @function tag like so:通过使用@function标记记录 class 成员,如下所示: 使用 @function 标记记录的代码图像

I am able to get the arrow function to generate as a class method, and get params documentation:我能够获得箭头 function 以生成为 class 方法,并获得参数文档: 生成的文档的图像

My concerns我的担忧

Well the biggest concern/annoyance is now I need to go through all the source code and add a bunch of @function tags.那么最大的担忧/烦恼是现在我需要通过所有源代码 go 并添加一堆@function标签。 Ah whelp.啊小崽子。

Other concerns are that I may have misunderstood the problem/I'm not quite sure if this is best practice.其他担忧是我可能误解了这个问题/我不太确定这是否是最佳实践。

And I'm not too certain if this documentation is accurate in terms of if there is actually a tangible difference between a class member arrow function and a class method that I need to capture in the API documentation. And I'm not too certain if this documentation is accurate in terms of if there is actually a tangible difference between a class member arrow function and a class method that I need to capture in the API documentation.

Anyway, I think this will be what I go with, but I'll be monitoring this answer to read any input/feedback:)无论如何,我认为这将是我 go 的内容,但我会监控这个答案以阅读任何输入/反馈:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM