Ignore inputs with terraform-docs-ignore comment

This commit is contained in:
Christian Kampka
2022-11-10 17:49:19 +01:00
committed by Khosrow Moossavi
parent 80c406f95d
commit 943489ca41
2 changed files with 14 additions and 1 deletions

View File

@@ -187,10 +187,17 @@ func loadInputs(tfmodule *tfconfig.Module, config *print.Config) ([]*Input, []*I
var optional = make([]*Input, 0, len(tfmodule.Variables)) var optional = make([]*Input, 0, len(tfmodule.Variables))
for _, input := range tfmodule.Variables { for _, input := range tfmodule.Variables {
comments := loadComments(input.Pos.Filename, input.Pos.Line)
// Skip over inputs that are marked as being ignored
if strings.Contains(comments, "terraform-docs-ignore") {
continue
}
// convert CRLF to LF early on (https://github.com/terraform-docs/terraform-docs/issues/305) // convert CRLF to LF early on (https://github.com/terraform-docs/terraform-docs/issues/305)
inputDescription := strings.ReplaceAll(input.Description, "\r\n", "\n") inputDescription := strings.ReplaceAll(input.Description, "\r\n", "\n")
if inputDescription == "" && config.Settings.ReadComments { if inputDescription == "" && config.Settings.ReadComments {
inputDescription = loadComments(input.Pos.Filename, input.Pos.Line) inputDescription = comments
} }
i := &Input{ i := &Input{

View File

@@ -28,3 +28,9 @@ variable "G" {
description = "G description" description = "G description"
default = null default = null
} }
# terraform-docs-ignore
variable "H" {
description = "H description"
default = null
}