【问题标题】:How to show documentation on hover for custom API in VSCode?如何在 VSCode 中显示自定义 API 的悬停文档?
【发布时间】:2020-04-21 19:11:00
【问题描述】:

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

class A: 

       // What foo does
       foo() { }

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

A.foo()

我想看看当我将鼠标悬停在 foo 上时它做了什么。我很不确定在哪里寻找以便在 vs 代码中实现这种自定义行为,我一直在阅读文档,但似乎找不到任何可能有益于构建这种行为并将其用作扩展的东西。如果有人可以指导我应该查看 vs code API 中文档的哪一部分,那么我可以从它开始。如果我可以进一步澄清我模糊不清的任何方面,请告诉我。

【问题讨论】:

    标签: javascript visual-studio-code vscode-settings vscode-extensions


    【解决方案1】:

    您可以添加多行 cmets,它会在悬停时显示:

      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(){
    
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2022-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-31
      • 2013-09-19
      • 2022-01-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多