cmake-language-support
cmake-language-support copied to clipboard
[feature request] Documentation of a cmake command from CMake site (like in CLion)
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 :
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 :
-
https://cmake.org/cmake/help/latest/command/project.html is URL to get
project
documentation -
https://cmake.org/cmake/help/latest/command/add_executable.html is URL to get project
add_executable
documentation
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 :