VladRassokhin / intellij-hcl

HCL language support for IntelliJ platform based IDEs
Apache License 2.0
244 stars 47 forks source link

Feature request: linking to terraform documentation #113

Open whatisaphone opened 7 years ago

whatisaphone commented 7 years ago

This one is a feature request. It would be nice to be able to press shift+F1 on a resource (and maybe even data, backend, provider, etc) and have it take you to straight to the Terraform docs. This feature is called External Documentation in the keymap. It's supported pretty well for Java and Python methods.

Example:

resource "aws_instance" "my-machine" {

Putting the cursor on aws_instance and hitting shift+F1 would take you here.

Another nice-to-have would be ctrl+q, or Quick Documentation. This pops up a window right in the IDE.

I'm not sure whether Terraform has enough metadata about the resources to make this possible. Keeping a manual list of URLs would not be fun. Either way, this is on my wishlist :)

eschwartz commented 6 years ago

This would be so helpful! Terraform docs are difficult to navigate and locate (especially for AWS, where I have to scroll for days to find anything), so being able to jump right to the documentation would save a lot of time

whatisaphone commented 6 years ago

VSCode has this feature:

However they don't support all providers like this plugin does. They only support the "big three" (AWS/Azure/GCloud). I did a tiny bit of research on their implementation. Here is their data source. It was generated with this script (written in Node/TypeScript).

I wonder if the links couldn't be generated with just dumb string concateneation. If you look at the URL format, it seems very standard:

https://www.terraform.io/docs/providers/aws/r/cloudfront_distribution.html

Maybe just assume https:\//www.terraform.io/docs/providers/$provider/$type/$name.html?

saiya commented 5 years ago

This patch seems to be very helpful https://github.com/VladRassokhin/intellij-hcl/pull/221#issuecomment-500211731 but not yet merged into https://github.com/VladRassokhin/intellij-hcl/blob/master/src/kotlin/org/intellij/plugins/hcl/terraform/config/TerraformDocumentationProvider.kt

VladRassokhin commented 5 years ago

@saiya in one of recent updates I've added next feature:

'Quick Documentation' is now able to show link to terraform.io.

martynassateika commented 4 years ago

@saiya in one of recent updates I've added next feature:

'Quick Documentation' is now able to show link to terraform.io.

@VladRassokhin I'm using version 0.7.9 and cannot seem to get quick documentation to work.

With the following in place I assume I should be able to invoke "Quick Documentation" on aws_lambda_function, but nothing happens:

resource "aws_lambda_function" foo {
}

Any idea what might be wrong?

VladRassokhin commented 4 years ago

If you put caret/cursor on foo it would work 100%, on other places - may not, yet nothing could be done as foo is identifier of a element (resource) and IntelliJ shows documentation for identifiers.

Although if you reference element somewhere, e.g. output x {value=aws_lambda_function.foo<caret>}, quick documentation should work.

martynassateika commented 4 years ago

If you put caret/cursor on foo it would work 100%

Wow, can't believe I missed that. Thanks!

fdcds commented 3 years ago

If you put caret/cursor on foo it would work 100%, on other places - may not, yet nothing could be done as foo is identifier of a element (resource) and IntelliJ shows documentation for identifiers.

Here for a "google_service_account" resource it does not display a quick documentation text and the link displayed when pressing ctrl+q points to https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account while the documentation is actually at https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_service_account. Also it uses "latest" as the version, which is not correct in my case: .terraform.lock.hcl does not point to the "latest" version as of today. Version used is 0.7.10, GoLand is at version 2020.3.4.

carlduevel commented 2 years ago

This stopped working for me. I am using IntelliJ IDEA 2021.3.1 and the current version of the plugin (0.7.14). Anybody else experiencing this?

Instead of opening the documentation in the browser an empty quick documentation popup opens.

frosforever commented 2 years ago

@carlduevel I have the same problem recently. Opened an explicit issue in https://github.com/VladRassokhin/intellij-hcl/issues/372 so that this doesn't get lost.

M1kep commented 2 years ago

I just installed version 0.7.15 and it works, BUT it appends .html to the webpage which breaks the link as the TF Registry docs don't support the .html