Commit Graph

21 Commits

Author SHA1 Message Date
Blake Gong
59eb90fc86 Make main module doc optional when in recursive generation
Signed-off-by: Blake Gong <blakegong@gmail.com>
2024-05-30 18:22:37 -04:00
Khosrow Moossavi
5cfb2f2615 Bump golangci-lint to 1.55.2 and fix issues
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2023-12-19 12:51:04 -05:00
Khosrow Moossavi
465dd14cff Make terraform.Module available in content
Add one extra special variable the `content`:

- `{{ .Module }}`

As opposed to the other variables, which are generated sections based on
a selected formatter, the `{{ .Module }}` variable is just a `struct`
representing a Terraform module.

It can be used to build highly complex and highly customized content:

```yaml
content: |-
  ## Resources

  {{ range .Module.Resources }}
  - {{ .GetMode }}.{{ .Spec }} ({{ .Position.Filename }}#{{ .Position.Line }})
  {{- end }}
```

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-10-04 20:01:44 -04:00
Khosrow Moossavi
de684ce48c Add public ReadConfig function
If terraform-docs is being used as a library, `print.ReadConfig()` can
be used to dynamically read and load .terraform-docs.yml config file.

Example:

```go
config, err := print.ReadConfig(".", ".terraform-docs.yml")
if err != nil {
    ...
}
```

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-10-04 15:14:50 -04:00
Khosrow Moossavi
54dc0f5a7c Add recursive config to .terraform-docs.yml file
Up to now there was only one way to enable recursive execution and that
was with `--recursive` CLI flag. This enables the same behavior but
within config file (i.e. `.terraform-docs.yml`)

Example:

```yaml
recursive:
  enabled: false
  path: modules
```

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-09-30 15:53:22 -04:00
Khosrow Moossavi
bb109711a1 Deprecate Settings and Options in favor of Config
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-09-28 15:47:27 -04:00
Khosrow Moossavi
d2fe2b1b29 Move print package from internal to public
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-09-28 15:04:07 -04:00
Martin Etmajer
988d897a9e Move packages 'doc' and 'print' to internal/pkg. 2018-09-21 08:49:52 +02:00
Martin Etmajer
7c67f1bea0 Add automated tests for package 'print'. 2018-09-21 08:49:52 +02:00
Bill Wang
fb92153a12 bugfix/#38 2017-09-17 08:32:53 +00:00
Sergiusz Urbaniak
d59d8261fd *: add --no-required option
Terraform implies a variable being required if you don't specify a default value, see [1].
Only if you leave out a default value the above "Required" column becomes a meaning.

The reality is, we specify a lot of default values for variables that are indeed required
but for whom we provide a sane default.

Furthermore we also specify quite some default empty string values "" for variables
which indeed are required, but we still cannot leave them out to mark them as required,
because of limitations in terraform where those values are being used in ternary operators.

Therefore the "Required" markdown column is meaningless in a lot of use
cases. This fixes it by introducing a `--no-required` option for markdown
generation which simply does not print it. It defaults to
false to retain current functionality.

[1] https://www.terraform.io/intro/getting-started/variables.html#defining-variables
2017-04-28 15:00:55 +02:00
Gavin Williams
b1660443df Add support for printing the variable 'type' in Markdown.
Currently only markdown supported, but trivial to add to other outputs.
2017-04-06 16:17:05 +01:00
Chris Marchesi
1ed94e57df print/markdown: Better markdown description normalizations
Converting all line breaks into HTML doesn't make for good looking
tables. :P

This now converts all double line breaks into double break tags, but
then converts any remaining line breaks to spaces.
2016-11-20 16:28:57 -08:00
Chris Marchesi
6fb15b1909 print/markdown: Added line break conversion for outputs
Missed this when doing the initial commit.
2016-11-20 12:41:47 -08:00
Chris Marchesi
1089829ed8 print/markdown: Replace table cell newlines with HTML line breaks
Tables in Markdown don't render line breaks properly, causing broken
table rendering when there are newlines in descriptions. This ensures
that the Markdown renderer replaces all newlines in descriptions with
HTML line breaks.
2016-11-20 11:50:01 -08:00
Joshua Bussdieker
1829d7b7fe Trim whitespace on markdown description too 2016-08-09 17:16:20 -07:00
Amir Abushareb
7616408eac print: wrap default values
also match last version output
2016-06-29 16:06:33 +03:00
Amir Abushareb
65e2192fa1 doc: fix map type 2016-06-29 15:32:33 +03:00
Amir Abushareb
ba2b4831ca print: actually print head comment 2016-06-14 17:47:22 +02:00
Amir Abushareb
5f7c0bee31 fix view 2016-06-14 17:36:20 +02:00
Amir Abushareb
ec5d2d7533 cleanup 2016-06-14 01:14:16 +02:00