Commit Graph

49 Commits

Author SHA1 Message Date
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
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
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
25d2ff4e53 Completely remove deprecated '--no-XXX' flags
In v0.10.0 flags '--no-XXX' have been deprecated in favor of their
counterparts in the format of '--X=false' (e.g. --no-header and
--header=false). And they are completely being removed now (two releases
after original announcement)

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-02-23 18:46:02 -05:00
Heiko Neblung
2575a40e78 added output section for modulecalls
Signed-off-by: Heiko Neblung <Heiko.Neblung@t-systems.com>
2021-02-10 05:40:50 +01:00
Khosrow Moossavi
54fc067bf4 Add support for plugin execution
Plugin can be developed on top of terraform-docs/plugin-sdk and made
available to terraform-docs core project in:

- ~/.tfdocs.d/plugins/ or
- ./.tfdocs.d/plugins/ (this takes precedence if exists)

Refer to the following for more details and examples:

- https://github.com/terraform-docs/plugin-sdk
- https://github.com/terraform-docs/tfdocs-format-template

Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-02-02 18:27:04 -05:00
Tim Earle
533a82b900 Add section for Resources
Signed-off-by: Tim Earle <earle.timothy@gmail.com>
2021-01-31 09:59:33 -05:00
Khosrow Moossavi
44b3361b22 Add license header to codebase files
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2021-01-28 12:29:11 -05:00
Khosrow Moossavi
fd97ec5930 feat: Add support for .terraform-docs.yml config file (#272)
* Add support for .terraform-docs.yml config file

* add config reader

* add usage documentation and reference guide

* typo

* update docs
2020-07-13 22:06:30 -04:00
Khosrow Moossavi
dfeaaecdc4 Migrate to github.com/terraform-docs org (#288)
* Migrate to github.com/terraform-docs org

* remove codecov token

* update maintenance notice in README
2020-07-06 19:43:25 -04:00
Khosrow Moossavi
e0404399a7 feat: Add new flags: --show, --show-all, --hide-all (#267)
* Add new flags: --show, --show-all, --hide-all

* add deprecated flags to Config

* update docs

* add implementation for new flags

Examples:

- hide all sections except one (or more): `terraform-docs --hide-all --show <name> ...`
- show all sections except one (or more): `terraform-docs --show-all --hide <name> ...`
2020-05-25 12:08:52 -04:00
Khosrow Moossavi
04a9ef49eb refactor: Refactor cli implemention and configuration (#266)
* Refactor cli implemention and configuration

* cleanup
2020-05-20 22:21:19 -04:00
Khosrow Moossavi
23c50e0ad8 refactor: Deprecate multiple flags in favor of new ones (#265)
BREAKING CHANGE: - Following flags have been deprecated and will be
removed in the following releases:

  - Flag `--no-color` has been deprecated, use `--color=false` instead

  - Flag `--no-escape` has been deprecated, use `--escape=false` instead

  - Flag `--no-header` has been deprecated, use `--hide header` instead

  - Flag `--no-inputs` has been deprecated, use `--hide inputs` instead

  - Flag `--no-outputs` has been deprecated, use `--hide outputs` instead

  - Flag `--no-providers` has been deprecated, use `--hide providers` instead

  - Flag `--no-requirements` has been deprecated, use `--hide requirements` instead

  - Flag `--no-required` has been deprecated, use `--required=false` instead

  - Flag `--no-sensitive` has been deprecated, use `--sensitive=false` instead

  - Flag `--no-sort` has been deprecated, use `--sort=false` instead
2020-05-20 11:49:25 -04:00
Khosrow Moossavi
8de80061fe Put terraform-docs imports after 3rd-party packages (#264) 2020-05-19 18:18:15 -04:00
Khosrow Moossavi
b397b7d46b feat: Add support for TOML renderer (#197)
* Add support for TOML renderer

* Add kind:formatter to toml command

* update docs

* adjust tests after merge

* fix after merge

* adjust tests after merge

* update docs

* remove vendor leftovers

* update doc

* update tests
2020-05-14 12:41:21 -04:00
Khosrow Moossavi
b25909b537 feat: Add new flag to sort inputs by type (#246)
* Add new flag to sort inputs by type

* add more tests

* revert renames
2020-04-13 17:43:21 -04:00
Khosrow Moossavi
b6a6ad1bbf refactor: Remove deprecated flags (#229)
BREAKING CHANGE: - Flags `--with-aggregate-type-defaults` and
`--sort-inputs-by-required` were marked as deprecated in v0.8.2
and now are removed.
2020-04-13 12:54:48 -04:00
Rubén del Campo
37375db283 feat: Add support for AsciiDoc renderer (#241)
* Implement AsciiDoc renderer

* Add missing tests to maintain expected code coverage

* Keep alphabetical order

* Refactor indent function (accept char argument and make homogeneous for both MD and Adoc renderers)

* Force asciidoc syntax in every table column

* Remove extra NL before code blocks and add autowidth tables

* Move char argument after settings in indent function

* Implement new factory function for asciidoc renderer

* Update asciidoc table docs

* Return empty indentation if no indent scpecified

* Prevent adding a trailing whitespace in table rows

* Change asciidoc alias to match file extension

* Update docs
2020-04-12 15:22:53 -04:00
Khosrow Moossavi
c196c7cc49 refactor: Add factory function to return format types (#243) 2020-04-10 19:08:37 -04:00
Khosrow Moossavi
80172d77f4 fix: Don't crash when reading header if 'main.tf' not found (#235)
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
2020-04-02 16:17:30 -04:00
Khosrow Moossavi
40bd96be44 docs: Enhance automatic document generation (#227)
* Enhance automatic document generation

* update contribuor guide

* fix broken link
2020-03-29 18:17:55 -04:00
Khosrow Moossavi
9043f268ad feat: Add support for tfvars hcl and json commands (#226)
* Add support for tfvars hcl and json commands

* fix docs generation header issue

* align padding of hcl tfvars items

* add more tests

* update docs

* wording
2020-03-27 15:02:09 -04:00
Julien Duchesne
4365b4997b fix: --no-header should not attempt reading main.tf file (#224)
* --no-header should stop terraform-docs from reading the main.tf file

Our projects do not have that file. Even with `--no-header`, terraform-docs crashes

* Add tests for empty configs in every format
+ Add a ShowHeader attribute in Options
+ Check for that option in loadHeader
2020-03-25 15:25:16 -04:00
Julien Duchesne
2caf4af15d feat: Allow hiding the "Sensitive" column in markdown (#223)
* Allow hiding the "Sensitive" column in markdown

Use case: for projects where all outputs are expected to not be sensitive, it adds noise

* Document the new --no-sensitive option

* Fixed tests, they were written on a previous branch

* Fix tests following merge with master

* Update internal/format/document.go

Co-Authored-By: Khosrow Moossavi <khos2ow@gmail.com>

Co-authored-by: Khosrow Moossavi <khos2ow@gmail.com>
2020-03-25 11:56:23 -04:00
Khosrow Moossavi
b6241751d9 feat: Add section for module requirements (#222)
* Add section for module requirements

* cleanup

* reorder items logically
2020-03-24 14:20:13 -04:00
Khosrow Moossavi
01c8fa1c61 feat: Add support for fetching the module header from any file (#217)
* Add support for fetching the module header from any file

* fix the failing test because of lines reader
2020-03-12 13:58:35 -04:00
Khosrow Moossavi
79e926ee43 enhance: Add extensive tests coverage for all the packages (#208)
* Add more test coverage

* add format/util test

* add tfconf/input test

* add line reader test

* cleanup

* add tfconf/output test

* improve internal/module/input coverage

* improve internal/module/options coverage

* improve internal/reader coverage

* improve internal/types coverage

* appease lint

* improve pkg/tfconf/output coverage

* add coverage to test target in makefile

* improve pkg/tmpl/sanitizer coverage

* use 'test' target on action

* always prepare codecov report, even if tests are failing

* fix double-space new line issue

* extensive tests for escaping characters

* enhance nad fix escape characters failing tests

* improve internal/module/module coverage

* improve pkg/tmpl/template coverage

* cleanup
2020-03-09 20:56:29 -04:00
Khosrow Moossavi
b716a25811 feat: Add support for XML renderer (#198)
* Add support for XML renderer

* formatting

* update docs
2020-02-26 14:44:50 -05:00
Khosrow Moossavi
4ff4582dff feat: Show sensitivity of the output value in rendered result (#207) 2020-02-26 12:08:24 -05:00
Khosrow Moossavi
38e18970ed refactor: Introduce Format interface and expose to public pkg (#195)
* Introduce format interface and expose to public pkg

* fix issues after merge

* don't panic

* Rename TFString back to String
2020-02-19 14:07:10 -05:00
Gretchen Shelby-Dormer
31cdef0f67 feat: Extract and render output values from Terraform (#191)
* Allow users to pass '--output-values'

Pass empty string to CreateModule.outputValuePath

* Fix bug causing 'pretty' tests to fail

* Link formats documentation in README (#181)

Co-authored-by: Khosrow Moossavi <khos2ow@gmail.com>

* docs: Auto generate formats document from examples (#192)

* Auto generate formats document from examples

* fix lint issues

* refactor: Add tfconf.Options to load Module with (#193)

* Update Changelog

* Allow users to pass '--output-values'

Read the outputValuesPath from an env variable

Use an env var with a path for '--output-values'

Update Changelog

Use an env var with a path for '--output-values'

Update Changelog

properly write output values for evrythng but yaml

* Fix failing json+yaml tests

* Remove unneeded code block from output.go

* Remove unused import statement from output.go

* Fix some noob mistakes

* Create two flags to use for output value injection

* Fix bug vanilla commands+build test to fail

* Modify all tests and add new for outputvalues

* Modify to include many output types

* Optimize imports to appease checkfmt

* Create loadOutputValues function

* Fix linter issue

* Code review fixes. Hopefully the final commit!

* appease linter

* Not allow sensitive output values to be injected

* Remove trailing slash from tests

* Remove default values from `--output-values-from`

Co-authored-by: Martyn Ranyard <iMartyn@users.noreply.github.com>
Co-authored-by: Khosrow Moossavi <khos2ow@gmail.com>
2020-02-19 11:46:43 -05:00
Khosrow Moossavi
d4a0663909 refactor: Add tfconf.Options to load Module with (#193) 2020-02-11 14:56:02 -05:00
Khosrow Moossavi
54ab7f9bbb docs: Auto generate formats document from examples (#192)
* Auto generate formats document from examples

* fix lint issues
2020-02-10 20:53:57 -05:00
Khosrow Moossavi
42ad476a37 feat: Add support for YAML renderer (#189) 2020-02-03 20:13:10 -05:00
Khosrow Moossavi
1dd45537d3 docs: Deprecate accepting files as commands param (#163)
BREAKING CHANGE: - With Terraform 0.12 ability to generate
output from file has been deprecated in favor of from folder
which contains one or more `.tf` files.
2020-01-15 18:57:33 -05:00
Khosrow Moossavi
b3112d135a fix: Read leading module header from main.tf (#154)
Supported comment formats is:
- jsdoc, c or java-like multi-line comment `/** **/`

BREAKING CHANGE: - In the JSON format respone, module "Comment" has been renamed to module `header`.
2020-01-10 16:40:48 -05:00
Khosrow Moossavi
2b64098529 Cleanup flags description wording 2020-01-06 20:55:38 -05:00
Khosrow Moossavi
0e50fa933d enhance: Rename flag to '--sort-by-required' (#150)
BREAKING CHANGE: - For simplicity we've decided to
deprecated the old `--sort-inputs-by-required` flag
to the simpler and more generic `--sort--by-required`.
The deprecated flags will get removed second release
from now.
2020-01-06 20:43:18 -05:00
Khosrow Moossavi
ff80da288f enhance: Mark '--with-aggregate-type-defaults' as deprecated (#148)
BREAKING CHANGE: - As of Terraform 0.12, the default value of
input variables are shown in full JSON format (if available)
and `--with-aggregate-type-defaults` is not needed anymore.
The flag is marked as soft deprecated and will get removed in
the second release from now.
2020-01-06 19:55:23 -05:00
Khosrow Moossavi
453c7da2d4 feat: Add '--no-escape' flag to 'json' command (#147) 2020-01-06 16:51:45 -05:00
Khosrow Moossavi
61554b9763 feat: Add flags to not show different sections (#144) 2020-01-05 14:50:25 -05:00
Khosrow Moossavi
96565f8bcc feat: Add '--no-color' flag to 'pretty' command (#143) 2020-01-04 16:18:12 -05:00
Khosrow Moossavi
ea1f442647 refactor: Move doc.Doc to tfconf.Module (#136) 2019-12-20 21:10:28 -05:00
Thomas Alton
b8da8c5020 feat: Support Terraform 0.12.x configuration (#113)
* Support 0.12 configuration

* Move code out of GOPATH for CircleCI

* cleanup

* Rename 'variables' back to 'input' just for now

* Normalizing 'print.s.Settings' usage

* Normalize settings continued

* Remove '--providers' functionality for now

* Adjust 'commands' based on moarta's changes

* Adjust 'pkg/doc' based on moarta's changes

* Adjust 'pkg/print/json' based on moarta's changes

* Fix json tests

* don't trim whitespaces from .tf files

* Adjust 'pkg/print/pretty' based on moarta's changes

* Fix pretty tests

* don't trim whitespaces from .golden files

* Show 'n/a' for empty description for 'pretty'

* Show 'any' if type of input variable is missing

* Adjust 'pkg/print/markdown/document' based on moarta's changes

* Fix document tests

* move back vendor files

* Adjust 'pkg/print/markdown/table' based on moarta's changes

* fix lint issue

* Fix table tests

* figure out input type based on default value if tpye not explicitly defined

* don't escape ( ) [ ] { }, as they don't cause any issue

Authored-by: Thomas Alton <thomas.alton@gmail.com>
Co-authored-by: Khosrow Moossavi <khos2ow@gmail.com>
2019-12-20 15:07:29 -05:00
Khosrow Moossavi
ffeb72c34b Add support for controlling the indentation of Markdown headers (#120) 2019-09-23 08:14:59 +02:00
Khosrow Moossavi
1c0d7b5fa9 Refactor Settings for better performance (#119) 2019-08-22 13:44:22 +02:00
Khosrow Moossavi
737bc8dc18 Add --no-escape flag for Markdown printer (#117) 2019-07-17 17:44:37 +02:00
Khosrow Moossavi
5faf591544 Use Cobra CLI instead of docopt (#116) 2019-07-05 16:16:11 +02:00