Commit Graph

129 Commits

Author SHA1 Message Date
christophe.vandekerchove
78e94da786 fix: Replace <br> with <br /> for markdown syntax
<br /> provides additional support for XHTML without breaking
compatibility with HTML. This can be useful when trying to publish
documentation generated by terraform-docs to XHTML based solutions

Signed-off-by: christophe.vandekerchove <christophe.vandekerchove@scalepad.com>
2024-07-05 14:30:50 -04:00
terraform-docs-bot
228c7a7284 Release version v0.18.0 2024-05-30 23:09:16 +00:00
Khosrow Moossavi
5e48777535 Update docs
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2024-05-30 18:36:36 -04:00
Blake Gong
e4af9978f4 Run make docs
Signed-off-by: Blake Gong <blakegong@gmail.com>
2024-05-30 18:22:37 -04:00
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
8f74fd4453 feat: ignore outputs, providers, resources with comments
Prepend any type of resource, including `resource`, `data`, `module`,
`variable`, and `output` with a comment including "terraform-docs-ignore"
to exclude it from the generated output.

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2024-05-30 12:33:14 -04:00
Khosrow Moossavi
d5a55ae76e more fixes of binary name with missing s
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2024-03-23 14:31:59 -04:00
caerulescens
3f4630c0be docs: document terraform-docs + ohmyzsh usage
Signed-off-by: caerulescens <caerulescens.github@proton.me>
2023-12-29 10:51:36 -05:00
Khosrow Moossavi
795d369fdc Release version v0.17.0 2023-12-19 13:31:44 -05:00
Khosrow Moossavi
4b29c00a52 Merge pull request #690 from yutaro1985/add_fish_completion
Add fish shell completion
2023-12-18 18:13:01 -05:00
Khosrow Moossavi
bde22e5b77 Merge pull request #639 from levinotik/levinotik/fix-recursive-submodules-spelling
Fix spelling
2023-12-18 13:20:19 -05:00
Thomas Briot
5d3966130f docs: fix two typos in the 'configuration' section of the documentation
Signed-off-by: Thomas Briot <thomas.briot82@gmail.com>
2023-11-05 19:56:32 -05:00
Yutaro Suzuki
eb2e3b77ea fix completion installing command
Signed-off-by: Yutaro Suzuki <yutaro.suzuki@cloudys.dev>
2023-06-30 06:10:10 +09:00
Levi Notik
b4d62c8d93 Fix spelling
Signed-off-by: Levi Notik <levinotik@gmail.com>
2022-09-22 02:47:18 -04:00
Khosrow Moossavi
ac2f98717b Update actions/checkout to v3
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2022-07-26 17:34:17 -04:00
Khosrow Moossavi
5727f8b412 Preserve whitespaces of provided content and template
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2022-01-07 18:14:21 -05:00
Khosrow Moossavi
1f686b1bb3 Release version v0.16.0
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-10-05 19:16:17 -04:00
Khosrow Moossavi
4a9ffe7c33 Move plugin-sdk to in-tree in core repository
Moving terraform-docs/plugin-sdk standalone module to in-tree, because
maintaining both of them, specifically if anything needs to be added to
Config, or terraform will required dual effort on both repository. As
such now everything is consolidated under one repository. Example usage
for plugin developer after this move is as follow:

```go
package main

import (
	_ "embed" //nolint

	"github.com/terraform-docs/terraform-docs/plugin"
	"github.com/terraform-docs/terraform-docs/print"
	"github.com/terraform-docs/terraform-docs/template"
	"github.com/terraform-docs/terraform-docs/terraform"
)

func main() {
	plugin.Serve(&plugin.ServeOpts{
		Name:    "template",
		Version: "0.1.0",
		Printer: printer,
	})
}

//go:embed sections.tmpl
var tplCustom []byte

// Print the custom format template. You have all the flexibility to generate
// the output however you choose to.
func printer(config *print.Config, module *terraform.Module) (string, error) {
	tpl := template.New(config,
		&template.Item{Name: "custom", Text: string(tplCustom)},
	)

	rendered, err := tpl.Render("custom", module)
	if err != nil {
		return "", err
	}

	return rendered, nil
}
```

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-10-05 18:54:49 -04: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
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
f3c92384a1 Extract leading comments for resources and modules
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-09-29 13:55:50 -04:00
Khosrow Moossavi
4f698fb177 Merge pull request #565 from poojitha-bikki/issue-552-dev
optionally process comments from tf files as description
2021-09-27 11:55:46 -04:00
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
Bryan Dady
519f25ee01 docs: fix typo in README and update configuration guide
* docs: typo in README

Adjust typo, and suggest possible readability improvement, in README.

* Fix typo in Examples

replace 2 instances of providrs with providers

Signed-off-by: Bryan Dady <bryan@subsplash.com>

* docs: 📝 Update README and user-guide/configuration.md

Incorporate suggestions from PR https://github.com/terraform-docs/terraform-docs/pull/564

Signed-off-by: Bryan Dady <bryan@subsplash.com>

* docs: 📝 Update guide/configuration.md

Incorporate suggestions from PR https://github.com/terraform-docs/terraform-docs/pull/564

Signed-off-by: Bryan Dady <bryan@dady.us>
Signed-off-by: Bryan Dady <bryan@subsplash.com>
2021-09-23 15:58:18 -04:00
Khosrow Moossavi
3d2b8788d6 Overhaul README and docs improvements
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-09-16 13:49:38 -04:00
Khosrow Moossavi
f33826c5df Cleanup documentations
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-09-13 18:07:57 -04:00
Khosrow Moossavi
0ad14a3120 Restructure how-tos docs
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-09-13 18:07:46 -04:00
Khosrow Moossavi
1ae5fd95ca Restructure configurations docs
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-09-13 18:07:21 -04:00
Nassos Kat
f61375077e Add 'HideEmpy' section bool flag
* Add 'HideEmpy' section to Settings

Signed-off-by: akatsadimas <nkatsadim@gmail.com>

* Address review comments

fixed linting and docs, moved HideEmpty to Settings struct

Signed-off-by: akatsadimas <nkatsadim@gmail.com>

* Address review comment

document hideempty configuration option

Signed-off-by: akatsadimas <nkatsadim@gmail.com>

* Address review comments - improve docs

Signed-off-by: akatsadimas <nkatsadim@gmail.com>
2021-08-31 17:17:16 -04:00
Khosrow Moossavi
f3b6eab8a8 Release version v0.15.0
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-08-10 18:55:29 -04:00
Khosrow Moossavi
1450ee9a10 Generate submodules documents with '--resurcive' flag
Considering the file strucutre below of main module and its submodules,
now it is possible to generate documentation for them main and all its
submodules in one execution, with `--recursive` flag.

Note that generating documentation recursively is allowed only with
`--output-file` set.

Path to find submodules can be configured with `--recursive-path`
(defaults to `modules`).

Each submodule can also have their own `.terraform-docs.yml` confi file,
to override configuration from root module.

```
.
├── README.md
├── main.tf
├── modules
│   └── my-sub-module
│       ├── README.md
│       ├── main.tf
│       ├── variables.tf
│       └── versions.tf
├── outputs.tf
├── variables.tf
└── versions.tf
```

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-08-10 18:22:40 -04:00
Khosrow Moossavi
f46a48b46b Attempt looking up config file in .config folder
The updated order of trying to look up for .terraform-docs.yml config
file, now, is:

1. root of module directory
2. `.config/` folder at root of module directory
3. current directory
4. `.config/` folder at current directory
5. `$HOME/.tfdocs.d/`

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-07-26 20:22:39 -04:00
Daman
a4f8aca1b4 Undo changes made by the editor
Signed-off-by: Damans227 <Damans227@gmail.com>
2021-07-26 19:38:52 -04:00
Damans227
af68ca2f46 Add new example for MacOs Install docs
Signed-off-by: Damans227 <Damans227@gmail.com>
2021-07-26 18:56:13 -04:00
Khosrow Moossavi
5256426650 Ignore extracting versions from terraform.lock.hcl
New flag, `--lockfile`, is added to control whether ignore reading
.terraform.lock.hcl file in an attempt to extract the exact version of
provider being used or not. Default is true.

If set to true, exact version of provider available in lock file at the
time of execution will be extracted. If set to false, the version in .tf
file will be used (either exact, or a constrained version: >=, ~>, ...)

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-07-22 19:48:39 -04:00
Ricardo Herrera
21eaab4fc7 add output-check option for outputs
adding option to compare outputted file with generated
terraform-doc and fail if different

Signed-off-by: Ricardo Herrera <rickhl@outlook.com>
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-07-22 17:21:11 -04:00
Khosrow Moossavi
bb1e21acf7 Cosmetic cleanup asciidoc module table
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-06-17 18:18:17 -04:00
Khosrow Moossavi
61cc005548 Render resources without URL correctly in Markdown and Asciidoc
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-06-17 18:17:43 -04:00
Khosrow Moossavi
8577ee60ab Merge pull request #516 from khos2ow/remove-deprecated
Remove deprecated `--sort-by-XXX`, `--show-all`, and `--hide-all` flags
2021-06-02 13:03:29 -04:00
Khosrow Moossavi
d77324cc02 Add new '--show all' and '--hide all' sections
New psuedo section `all` is added and can be used to show or hide _all_
sections. This can be used as a replacement for, now, deprecated and
removed `--show-all` and `--hide-all` flags.

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-06-02 13:01:25 -04:00
Khosrow Moossavi
25f03b4cf4 Remove deprecated '--show-all' and '--hide-all' flags
In v0.13.0 flags `--show-all` and `--hide-all` have been deprecated. And
they are completely being removed now (two releases after original
announcement)

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-06-02 13:01:13 -04:00
frugecn
567cfcce27 updating how-to doc for correct Include Examples syntax
Signed-off-by: frugecn <christopher.fruge@churchofjesuschrist.org>
2021-06-01 16:04:40 -06:00
Khosrow Moossavi
52f0ea072b Release version v0.14.1
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-06-01 16:51:54 -04:00
Khosrow Moossavi
69823736d5 Release version v0.14.0
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-05-31 13:37:43 -04:00
Khosrow Moossavi
2f088f2544 Add '--html bool' flag and config to Markdown
This is to control the generated HTML tags inside markdown output. If
set to false no html tags (e.g. `<br>`, `<pre>`) will be generated. And
as a workaround the multi-line codeblock will be converted to single
line with linebreak converted to `<SPACE>`.

For example:

```
{
  "bar": {
    "bar": "bar",
    "foo": "bar"
  },
  "buzz": [
    "fizz",
    "buzz"
  ],
  "fizz": []
}
```

will be converted to:

```
{ "bar": { "bar": "bar", "foo": "bar" }, "buzz": [ "fizz", "buzz" ], "fizz": [] }
```

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-05-25 13:23:28 -04:00
Edgar R. Sandi
0284283bd1 Separate the module version from module source when using ?ref=
Signed-off-by: Edgar R. Sandi <edgar.r.sandi@gmail.com>
2021-05-18 20:51:50 -03:00
Khosrow Moossavi
ea34bce326 Include relative files into generated content
Local relative files can be included automatically in the generated
content with `{{ include "..." }} function. This can be very useful
for:

- inject arbitrary markdown files in between sections
- automatically include example usage

````yaml
content: |-
  include any relative files

  {{ include "relative/path/to/file" }}

  or examples

  ```hcl
  {{ include "examples/foo/main.tf" }}
  ```
````

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-05-13 12:53:25 -04:00
Khosrow Moossavi
6777364257 Customize content with individual sections output
Generated content can be customized further away with `content` in configuration.
If the `content` is empty the default orders of section is used. `content` is a
Go template with following additional variables:

- `{{ .Header }}`
- `{{ .Footer }}`
- `{{ .Inputs }}`
- `{{ .Modules }}`
- `{{ .Outputs }}`
- `{{ .Providers }}`
- `{{ .Requirements }}`
- `{{ .Resources }}`

```yaml
content: |-
  Any arbitrary text can be placed anywhere in the content

  {{ .Header }}

  and even in between sections

  {{ .Providers }}

  and they don't even need to be in the default order

  {{ .Outputs }}

  {{ .Inputs }}
```

These variables are the generated output of individual sections in the selected
formatter. For example `{{ .Inputs }}` is Markdown Table representation of inputs
when formatter is set to `markdown table` and AsciiDoc Document representation
when formatter is set to `asciidoc document` and so on.

Compatible formats for customized content are:

- `asciidoc document`
- `asciidoc table`
- `markdown document`
- `markdown table`

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-05-12 16:12:38 -04:00
Khosrow Moossavi
7327de17ca Clarify deprecated settings in the docs (#499)
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-05-06 12:51:45 -04:00
Khosrow Moossavi
d79abf0447 Documentation cosmetic cleanup
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-05-02 15:12:56 -04:00