简体   繁体   English

go 如何使用 JSDoc 记录 JSON ZA8CFDE6331BD54B666C9 内部的 function?

[英]How would one go about using JSDoc to document a function inside of a JSON object?

I am trying to document the function parameters message and client in my code for a discord bot.我正在尝试在 discord 机器人的代码中记录 function 参数messageclient But I'm not sure how to go about doing that.但我不确定如何 go 这样做。 Heres some example code that roughly follows what my code is:下面是一些示例代码,大致遵循我的代码:

var discord = require("discord.js");

module.exports = {
   name: "exampleCommand",
   aliases: ["example", "example2"],
   execute(message, client){
   message.channel.send("example")
   }
}

A few things I've tried:我尝试过的几件事:

/*
 * Execute command
 * @param {discord.Message} message - The message that was sent
 * @param {discord.Client} client - The discord bot client
*/
execute(message, client){
message.channel.send("example")
}
}

I found this in a different question here, but that didn't do it either:我在这里的另一个问题中发现了这一点,但也没有这样做:

/*
 * @param {name:string, aliases:Array, execute(discord.Message, discord.Client)}
*/
{
    name:"exampleCommand",
    aliases:["example", "example2"],
    execute(message, client){
    message.channel.send("example")
    }
}

I assume my IDE (Visual studio code) is supposed to auto-detect JSDoc comments and give the proper IntelliSense recommendations, but it just shows that their type is any still.我假设我的 IDE(Visual Studio 代码)应该自动检测 JSDoc 注释并给出正确的 IntelliSense 建议,但它只是表明它们any类型仍然是。 What is the proper way to document this function inside of JSON?在 JSON 内记录这个 function 的正确方法是什么?

This is way simpler than I originally thought.这比我最初想象的要简单得多。 I was starting my JSDOC comments incorrectly.我错误地开始了我的 JSDOC 评论。 I was starting them with /* when I should have been starting them with /** .我应该用/*开始它们,而我应该用/**开始它们。 This little fix made everything work as intended.这个小修复使一切按预期工作。

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

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