cmake-language-support icon indicating copy to clipboard operation
cmake-language-support copied to clipboard

[feature request] Documentation of a cmake command from CMake site (like in CLion)

Open DridriLaBastos opened this issue 2 years ago • 0 comments

I started using this extension instead of the previous cmake language server made by twxs and its great. The only trouble I have is with the documentation of a hovered keyword. It is better than twxs extension but still I think some improvements can be done.

I like the way CLion displays documentation when the mouse hovers over a CMake command: instead of displaying a text created by the developer, it shows the same documentation as the cmake website. I didn't tested but I am pretty sure they get it from the CMake website. I found it very convenient to have all the official documentation available when coding and I would really like to have this feature available in vscode. Here is what it looks like from CLion : Enregistrement de l’écran 2022-09-01 à 22 40 59

Since vscode is web-based, I think it should be possible to fetch the documentation of a hovered cmake keyword and displays it inside vscode. I made some research and the documentation can be get by using a URL created with the hovered keyword: https://cmake.org/cmake/help/latest/command/<hovered cmake keyword>.html.

For example :

When used like that the page returned is always the latest version of the documentation. It is possible to access a specific version by changing /latest in the URL to /v<version> where version is the first two digits of the value returned by cmake --version. The version could be obtained from cmake_minimum_required for example to have the most compatible version of the documentation, or always fetch the latest to have the most recent features (this can be a switch in the options).

For example, if I want the documentation for version 3.10 of the later commands, the URLs become :

DridriLaBastos avatar Sep 01 '22 21:09 DridriLaBastos