'How to show documentation on hover for custom API in VSCode?

I have a custom API for use where I am looking to show the documentation when I hover over the method. For example:

class A: 

       // What foo does
       foo() { }

So, if I am using an instance of class A where when I call the method foo on A for example:

A.foo()

I want see what foo does when I hover over it. I am quite unsure where to look for in order to implement such custom behavior in vs code and I have been going through the documentation but cant seem to find anything that could be beneficial to build such behavior and use it as an extension. If anyone can guide me which part of the documentation in vs code API I should be looking at then I can start with that. Please let me know if I can further clarify on any aspect I went vaguely.



Solution 1:[1]

You can add multi-line comments and it will show on hover:

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

  }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tushar Shahi