简体   繁体   English

如何使用 Js 文档记录柯里化函数

[英]how to document curried functions with Js docs

Im trying to use Js docs to generate a static documentation of my project but i got a lot of parse errors when i try to run the js doc command, occurs only where I have curried function, my code works normaly the error are only on js docs, its a lib error or did i do something wrong ?我试图使用 Js docs 来生成我的项目的静态文档,但是当我尝试运行 js doc 命令时我遇到了很多解析错误,仅发生在我有柯里化函数的地方,我的代码正常工作,错误仅发生在 js 上文档,它是一个库错误还是我做错了什么?

/**Responsible for fetch the data that will be loaded in the graph within the dialog
 *
 * @param {function} dispatch redux dispatch function
 * @param {String} timeMode time mode used on metric page Example: 'Mensal'
 * @param {String} dialogType type of the dialog used to request de correct data and render the body Example: 'WARN_NETWORK_DRIVE'
 * @returns {(timeMode: String) => (dialogType: String) => Promise<void>}
 */
export const fetchGraphicData = dispatch => timeMode => async dialogType => {...function logic }

error:错误: 在此处输入图片说明

I don't think you can document arguments for a returned function from the function that receives it.. you'd have to split out the documentation like:我不认为你可以记录从接收它的函数返回的函数的参数..你必须把文档分开,比如:

/**
 * @param {String} dialogType type of the dialog used to request de correct data and render the body Example: 'WARN_NETWORK_DRIVE'
 */
const dialogFn = async dialogType => { };

/**
 * @param {String} timeMode time mode used on metric page Example: 'Mensal'
 */
const timeModeFn = timeMode => dialogFn;

/**
 * Responsible for fetch the data that will be loaded in the graph within the dialog
 *
 * @param {function} dispatch redux dispatch function
 * @returns {timeModeFn} timeModeFn
 */
export const fetchGraphicData = dispatch => timeModeFn;

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

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