Skip to content

Commit 943489c

Browse files
kampkakhos2ow
authored andcommitted
Ignore inputs with terraform-docs-ignore comment
1 parent 80c406f commit 943489c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

terraform/load.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,17 @@ func loadInputs(tfmodule *tfconfig.Module, config *print.Config) ([]*Input, []*I
187187
var optional = make([]*Input, 0, len(tfmodule.Variables))
188188

189189
for _, input := range tfmodule.Variables {
190+
comments := loadComments(input.Pos.Filename, input.Pos.Line)
191+
192+
// Skip over inputs that are marked as being ignored
193+
if strings.Contains(comments, "terraform-docs-ignore") {
194+
continue
195+
}
196+
190197
// convert CRLF to LF early on (https://github.com/terraform-docs/terraform-docs/issues/305)
191198
inputDescription := strings.ReplaceAll(input.Description, "\r\n", "\n")
192199
if inputDescription == "" && config.Settings.ReadComments {
193-
inputDescription = loadComments(input.Pos.Filename, input.Pos.Line)
200+
inputDescription = comments
194201
}
195202

196203
i := &Input{

terraform/testdata/full-example/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,9 @@ variable "G" {
2828
description = "G description"
2929
default = null
3030
}
31+
32+
# terraform-docs-ignore
33+
variable "H" {
34+
description = "H description"
35+
default = null
36+
}

0 commit comments

Comments
 (0)