Commit Graph

58 Commits

Author SHA1 Message Date
Khosrow Moossavi
4b29c00a52 Merge pull request #690 from yutaro1985/add_fish_completion
Add fish shell completion
2023-12-18 18:13:01 -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
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
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
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
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
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
Khosrow Moossavi
43546028ad Release version v0.13.0
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-04-30 16:24:04 -04:00
Khosrow Moossavi
1415ac92a0 Add Terraform compatibility matrix documentation
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-04-30 16:07:34 -04:00
Khosrow Moossavi
fcd314b13b Read config from relative path, absolute, or $HOME
Configuration can be loaded with `-c, --config string` which accepts
both relative and absolute paths.

    $ pwd
    /path/to/parent/folder

    $ tree
    .
    ├── module-a
    │   └── main.tf
    ├── module-b
    │   └── main.tf
    ├── ...
    └── .terraform-docs.yml

    # executing from parent
    $ terraform-docs -c .terraform-docs.yml module-a/

    # executing from child
    $ cd module-a/
    $ terraform-docs -c ../.terraform-docs.yml .

    # or an absolute path
    $ terraform-docs -c /path/to/parent/folder/.terraform-docs.yml .

The order for looking for config file is:

1. root of module directory
2. current directory
3. `$HOME/.tfdocs.d/`

if `.terraform-docs.yml` is found in any of the folders above, that will
take precedence and will override the other ones. Note that values passed
directly as CLI flags will override all of the above.

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-04-30 13:59:44 -04:00
Khosrow Moossavi
4be22230e7 In output-mode inject do not fail if file not found
The following scenarios can happen for --output-mode inject:

- file exists, comments exist: inject output between comments
- file exists, comments not found: append output at the end of file
- file exists, but empty: save the whole output into the file
- file not found: create the target file and save the ooutput into it

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-04-27 20:50:30 -04:00
Khosrow Moossavi
845469c45f Support outputing to file for absolute path
`--output-file` or corresponding `output.file` config can now support
absolute path as well as relative path to root of module foler. For
example all of the followings are valid:

    $ cd /path/to/module
    $ tree .
    .
    ├── docs
    │   └── README.md
    ├── ...
    └── main.tf

    # this works, relative path
    $ terraform-docs markdown table --output-file ../docs/README.md .

    # so does this, absolute path
    $ terraform-docs markdown table --output-file /path/to/module/docs/README.md .

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-04-27 13:06:55 -04:00
Khosrow Moossavi
b4981a16a9 Add 'since version' to docs for clarity
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-04-26 20:20:31 -04:00
Khosrow Moossavi
dabf54f29f Version constraints configuration
terraform-docs version constraints is almost identical to the syntax
used by Terraform. A version constraint is a string literal containing
one or more condition, which are separated by commas.

```yaml
version: ">= 0.13.0, < 1.0.0"
```

Each condition consists of an operator and a version number. A version
number is a series of numbers separated by dots (e.g. `0.13.0`). Note
that version number should not have leading `v` in it.

Valid operators are as follow:

- `=` (or no operator): allows for exact version number.
- `!=`: exclude an exact version number.
- `>`, `>=`, `<`, and `<=`: comparisons against a specific version.
- `~>`: only the rightmost version component to increment.

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-04-26 19:45:34 -04:00
Khosrow Moossavi
2784920341 Update doc to indicate minimum go1.16 is needed
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-04-22 13:24:55 -04:00
Khosrow Moossavi
01fdd012b3 Merge pull request #475 from khos2ow/show-hide
Deprecate --show-all and --hide-all flags
2021-04-20 12:06:53 -04:00
Khosrow Moossavi
8c531b6544 Deprecate --show-all and --hide-all flags
As of `v0.13.0` flags `--show-all` and `--hide-all` are deprecated in
favor of explicit use of `--show` and `--hide`. In other words when
`--show <section>` is used, only `<section>` will be shown. If you want
to show multiple sections and hide the rest you can specify multiple
`--show` flags. The same logic is also applied to `--hide`.

    # show 'inputs' and hide everything else
    $ terraform-docs --show inputs <formatter>

    # show 'inputs' and show 'outputs' and hide everything else
    $ terraform-docs --show inputs --show outputs <formatter>

    # hide 'header' and show everything else
    $ terraform-docs --hide header <formatter>

    # hide 'header' and hide 'providers' and show everything else
    $ terraform-docs --hide header --hide providers <formatter>

Note: Using `--show` or `--hide` CLI flag will completely override the
values from `.terraform-docs.yml`. Example:

    $ cat .terraform-docs.yml
    sections:
      show:
        - inputs
        - outputs

    # example 1: this will only show 'providers'
    $ terraform-docs --show providers .

    # example 2: this will hide 'inputs' and hide 'providers' and show everything else
    $ terraform-docs --hide inputs --hide providers .

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-04-20 11:50:58 -04:00
Khosrow Moossavi
1dbebafc84 Merge pull request #470 from khos2ow/template-comment
Support inline comments variation for Markdown and AsciiDoc
2021-04-17 19:58:12 -04:00
Khosrow Moossavi
e2e7a61ad7 Add ShowDescription to Settings
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-04-16 11:29:45 -04:00
Khosrow Moossavi
0eea133cae Support inline comments variation for Markdown and AsciiDoc
Some of the Markdown engines (e.g. Bitbucket Cloud) are not able to
process HTML comment but as a workaround they support variation of
inline comments as follow:

- `<!-- This is a comment -->`
- `[]: # (This is a comment)`
- `[]: # "This is a comment"`
- `[]: # 'This is a comment'`
- `[//]: # (This is a comment)`
- `[comment]: # (This is a comment)`

The following is also supported for AsciiDoc format:

- `// This is a comment`

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-04-13 14:59:36 -04:00
Khosrow Moossavi
4031c661be Merge pull request #467 from khos2ow/sort-flag
Deprecate '--sort-by-XX' in favor of '--sort-by XX'
2021-04-12 18:44:01 -04:00
Khosrow Moossavi
557d53dd1e Deprecate '--sort-by-XX' in favor of '--sort-by XX'
This deprecates sort by flags in favor of their corresponding dynamic
valued ones. Affected flags are:

- `--sort-by-required`
- `--sort-by-type`

In return new `--sort-by string` is added with following values:

- `name` (default)
- `required`
- `type`

Note that the behavior of `--sort bool` was not changed and to disable
sorting altogether you can run `--sort false`.

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-04-12 18:34:42 -04:00
Khosrow Moossavi
6b0cf547a7 Add document for 'false' value for CLI flag
Boolean flags can only take arguments via '--flag=[true|false]' or for
short names (if available) '-f=[true|false]'. You cannot use
'--flag [true|false]' nor can you use the shorthand '-f [true|false]'.

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-04-05 14:34:24 -04:00
Khosrow Moossavi
4714dd3ef9 Release version v0.12.1
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-03-29 13:06:13 -04:00
Khosrow Moossavi
9c738b97c1 Release version v0.12.0
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-03-22 14:45:26 -04:00