Files
terraform-docs/docs/reference/tfvars-hcl.md
Poojitha Bikki 045707beee feat: Add new flag 'read-comments' to optionally process comments as description
fixes issue #552

- process description from comments

Signed-off-by: Poojitha Bikki <50849668+poojitha-bikki@users.noreply.github.com>

- fix module tests

Signed-off-by: Poojitha Bikki <50849668+poojitha-bikki@users.noreply.github.com>

- optionally read comments for output vars description

Signed-off-by: Poojitha Bikki <50849668+poojitha-bikki@users.noreply.github.com>

- set default to true

Signed-off-by: Poojitha Bikki <50849668+poojitha-bikki@users.noreply.github.com>

- run make docs

Signed-off-by: Poojitha Bikki <50849668+poojitha-bikki@users.noreply.github.com>

- change option name

Signed-off-by: Poojitha Bikki <50849668+poojitha-bikki@users.noreply.github.com>

- add option in doc generator; make docs

Signed-off-by: Poojitha Bikki <50849668+poojitha-bikki@users.noreply.github.com>

- add config 'ReadComments'

Signed-off-by: Poojitha Bikki <50849668+poojitha-bikki@users.noreply.github.com>

- Fix alphabetic order for 'ReadComments' setting

Signed-off-by: Poojitha Bikki <50849668+poojitha-bikki@users.noreply.github.com>

- add read-comments in docs

Signed-off-by: Poojitha Bikki <50849668+poojitha-bikki@users.noreply.github.com>

- add test for readcomments option

Signed-off-by: Poojitha Bikki <50849668+poojitha-bikki@users.noreply.github.com>

- update 'read-comments' flag description

Co-authored-by: Khosrow Moossavi <khos2ow@gmail.com>
Signed-off-by: Poojitha Bikki <50849668+poojitha-bikki@users.noreply.github.com>
2021-09-24 18:04:39 -05:00

3.6 KiB

title, description, menu, weight, toc
title description menu weight toc
tfvars hcl Generate HCL format of terraform.tfvars of inputs
docs
parent
tfvars
960 true

Synopsis

Generate HCL format of terraform.tfvars of inputs.

terraform-docs tfvars hcl [PATH] [flags]

Options

      --description   show Descriptions on variables
  -h, --help          help for hcl

Inherited Options

  -c, --config string               config file name (default ".terraform-docs.yml")
      --footer-from string          relative path of a file to read footer from (default "")
      --header-from string          relative path of a file to read header from (default "main.tf")
      --hide strings                hide section [all, data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
      --lockfile                    read .terraform.lock.hcl if exist (default true)
      --output-check                check if content of output file is up to date (default false)
      --output-file string          file path to insert output into (default "")
      --output-mode string          output to file method [inject, replace] (default "inject")
      --output-template string      output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
      --output-values               inject output values into outputs (default false)
      --output-values-from string   inject output values from file into outputs (default "")
      --read-comments               use comments as description when description is empty (default true)
      --recursive                   update submodules recursively (default false)
      --recursive-path string       submodules path to recursively update (default "modules")
      --show strings                show section [all, data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]
      --sort                        sort items (default true)
      --sort-by string              sort items by criteria [name, required, type] (default "name")

Example

Given the examples module:

terraform-docs tfvars hcl --footer-from footer.md ./examples/

generates the following output:

bool-1             = true
bool-2             = false
bool-3             = true
bool_default_false = false
input-with-code-block = [
  "name rack:location"
]
input-with-pipe        = "v1"
input_with_underscores = ""
list-1 = [
  "a",
  "b",
  "c"
]
list-2             = ""
list-3             = []
list_default_empty = []
long_type = {
  "bar": {
    "bar": "bar",
    "foo": "bar"
  },
  "buzz": [
    "fizz",
    "buzz"
  ],
  "fizz": [],
  "foo": {
    "bar": "foo",
    "foo": "foo"
  },
  "name": "hello"
}
map-1 = {
  "a": 1,
  "b": 2,
  "c": 3
}
map-2                   = ""
map-3                   = {}
no-escape-default-value = "VALUE_WITH_UNDERSCORE"
number-1                = 42
number-2                = ""
number-3                = "19"
number-4                = 15.75
number_default_zero     = 0
object_default_empty    = {}
string-1                = "bar"
string-2                = ""
string-3                = ""
string-special-chars    = "\\.<>[]{}_-"
string_default_empty    = ""
string_default_null     = ""
string_no_default       = ""
unquoted                = ""
with-url                = ""