26 Commits

Author SHA1 Message Date
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
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
Khosrow Moossavi
f33826c5df Cleanup documentations
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-09-13 18:07:57 -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
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
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
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
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
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
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
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
Edgar R. Sandi
c8fc7ab4f2 add ability to show or hide data-sources
Signed-off-by: Edgar R. Sandi <edgar.r.sandi@gmail.com>
2021-04-14 17:36:55 -03: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
2109520db0 Merge pull request #383 from si-c613/368-Add-Footer-Option
feat: Add support for footer docs (#368)
2021-03-15 14:56:10 -04:00
Simon Clifford
aa1e6bbf59 Add support for footer docs
Enables a footer to be appended to the end of a generated document
sourced from tf files or documents in the same way as the header

Adds the `footer-from` field to the config yml
Adds the `--footer-from` flag to the cli

Signed-off-by: Simon Clifford <siclifford@gmail.com>
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-03-15 14:51:00 -04:00
Edgar R. Sandi
243fb27ca5 add mode resource or data source to generated docs
Signed-off-by: Edgar R. Sandi <edgar.r.sandi@gmail.com>
2021-03-15 12:40:31 -03:00
Khosrow Moossavi
7e489d2bbb Do not modify header lines and trailing whitespaces
This is going to preserve line-ending of extracted header text as they
are provided by users. In other words we are going to always assume the
header text is formatted in the "intended" way by users. So we're never
going to modify line-endings and won't append `<SPACE><SPACE>` at the
end of paragraph lines.

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-03-13 13:43:03 -05:00
Khosrow Moossavi
a3bafd6018 Save generated content directly into a file
There are two modes for saving into file:

- inject: partially replace the target file with generated output
- replace: completely replace the target file with generated output

The output generated by formatters (markdown, asciidoc, etc) will be
inserted into a template before getting saved into the file. This
template can be customized with '--output-template' CLI flag or
corresponding item in '.terraform-docs.yml' config file. Its default
value is:

```
<!-- BEGIN_TF_DOCS -->
{{ .Content }}
<!-- END_TF_DOCS -->
```

This consists of three items, all of them are mandatory:

- begin comment
- content variable
- end comment

You may change the wording of comment as you wish, but the comment must
be present in the template.

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-03-09 16:40:22 -05:00
Edgar R. Sandi
8c05cb9b17 Add resource 'Name' to generated docs
Signed-off-by: Edgar R. Sandi <edgar.r.sandi@gmail.com>
2021-03-09 15:11:39 -03:00
Khosrow Moossavi
3d39a94e39 Add option to hide Type and Default columns
Two new flags are added: '--default bool' and '--type bool' to
control the visibility of Default and Type columns and section
respectively in Markdown and AsciiDoc.

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-03-02 14:17:03 -05:00
nitrocode
02f490dc65 --anchor to add anchors for markdown, asciidocs
Signed-off-by: nitrocode <nitrocode@users.noreply.github.com>
2021-03-02 12:47:44 -05:00
Khosrow Moossavi
152928007f Update reference documentation and guide
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-03-01 16:42:59 -05:00
Khosrow Moossavi
304bce9bb0 Refactor docs to be published on website
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-02-23 17:28:12 -05:00