如何在VSCode中显示自定义API悬停时的文档



我有一个自定义的API,当我悬停在方法上时,我希望在其中显示文档。例如:

class A: 
// What foo does
foo() { }

因此,如果我使用类A的实例,当我在A上调用方法foo时,例如:

A.foo()

当我把鼠标悬停在foo上时,我想看看它会做什么。我不确定在哪里可以实现vs代码中的这种自定义行为,我一直在浏览文档,但似乎找不到任何有利于构建这种行为并将其用作扩展的东西。如果有人能指导我应该查看vs代码API中文档的哪一部分,那么我可以从这一部分开始。请让我知道我是否可以进一步澄清我含糊的任何方面。

您可以添加多行注释,它将在悬停时显示:

class A {
/**
* @name foo
* @param { string } text - text parameter
* @returns { object }
* @description Does this and that.
* The `RequestBodySearch` object provides methods generating an elasticsearch
search request body. The search request can be executed with a search DSL,
which includes the Query DSL, within its body.
*/
foo(){
}
}

最新更新