Commit Graph

20 Commits

Author SHA1 Message Date
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
930bfbaf30 Merge pull request #466 from mikiya771/feature/tfvars-hcl/add-description-flag
Feature/lssue461/add description flag
2021-04-14 12:57:44 -04:00
mikiya771
d914ca71e6 Add a flag for showing description with hcl formatted tfvars
Signed-off-by: mikiya771 <22876341+mikiya771@users.noreply.github.com>

add: cli flag of show description

Signed-off-by: mikiya771 <22876341+mikiya771@users.noreply.github.com>

add: test for tfvars-hcl description flag

Signed-off-by: mikiya771 <22876341+mikiya771@users.noreply.github.com>

docs: add tfvars-hcl flag

Signed-off-by: mikiya771 <22876341+mikiya771@users.noreply.github.com>

fix: inser new lines around value with description

Signed-off-by: mikiya771 <22876341+mikiya771@users.noreply.github.com>

fix: replace with -1 to replaceall for linter

Signed-off-by: mikiya771 <22876341+mikiya771@users.noreply.github.com>

fix: use simple format for linter

Signed-off-by: mikiya771 <22876341+mikiya771@users.noreply.github.com>

fix: padding format as terraform-fmt-way

Signed-off-by: mikiya771 <22876341+mikiya771@users.noreply.github.com>
2021-04-14 21:21:37 +09: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
eeee58ceda Update reference documentation
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-03-16 09:54:45 -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
780242b506 Add user-guide documentation
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-03-04 18:17:49 -05: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