Skip to content

Commit 045707b

Browse files
pbikkikhos2ow
andcommitted
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>
1 parent 5cd2b8f commit 045707b

25 files changed

+129
-39
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ settings:
213213
html: true
214214
indent: 2
215215
lockfile: true
216+
read-comments: true
216217
required: true
217218
sensitive: true
218219
type: true

cmd/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ func NewCommand() *cobra.Command {
8181
cmd.PersistentFlags().BoolVar(&config.OutputValues.Enabled, "output-values", false, "inject output values into outputs (default false)")
8282
cmd.PersistentFlags().StringVar(&config.OutputValues.From, "output-values-from", "", "inject output values from file into outputs (default \"\")")
8383

84+
cmd.PersistentFlags().BoolVar(&config.Settings.ReadComments, "read-comments", true, "use comments as description when description is empty")
85+
8486
// formatter subcommands
8587
cmd.AddCommand(asciidoc.NewCommand(runtime, config))
8688
cmd.AddCommand(json.NewCommand(runtime, config))

docs/reference/asciidoc-document.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ terraform-docs asciidoc document [PATH] [flags]
4040
--output-template string output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
4141
--output-values inject output values into outputs (default false)
4242
--output-values-from string inject output values from file into outputs (default "")
43+
--read-comments use comments as description when description is empty (default true)
4344
--recursive update submodules recursively (default false)
4445
--recursive-path string submodules path to recursively update (default "modules")
4546
--required show Required column or section (default true)

docs/reference/asciidoc-table.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ terraform-docs asciidoc table [PATH] [flags]
4040
--output-template string output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
4141
--output-values inject output values into outputs (default false)
4242
--output-values-from string inject output values from file into outputs (default "")
43+
--read-comments use comments as description when description is empty (default true)
4344
--recursive update submodules recursively (default false)
4445
--recursive-path string submodules path to recursively update (default "modules")
4546
--required show Required column or section (default true)

docs/reference/asciidoc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ terraform-docs asciidoc [PATH] [flags]
4343
--output-template string output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
4444
--output-values inject output values into outputs (default false)
4545
--output-values-from string inject output values from file into outputs (default "")
46+
--read-comments use comments as description when description is empty (default true)
4647
--recursive update submodules recursively (default false)
4748
--recursive-path string submodules path to recursively update (default "modules")
4849
--show strings show section [all, data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]

docs/reference/json.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ terraform-docs json [PATH] [flags]
3737
--output-template string output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
3838
--output-values inject output values into outputs (default false)
3939
--output-values-from string inject output values from file into outputs (default "")
40+
--read-comments use comments as description when description is empty (default true)
4041
--recursive update submodules recursively (default false)
4142
--recursive-path string submodules path to recursively update (default "modules")
4243
--show strings show section [all, data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]

docs/reference/markdown-document.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ terraform-docs markdown document [PATH] [flags]
4242
--output-template string output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
4343
--output-values inject output values into outputs (default false)
4444
--output-values-from string inject output values from file into outputs (default "")
45+
--read-comments use comments as description when description is empty (default true)
4546
--recursive update submodules recursively (default false)
4647
--recursive-path string submodules path to recursively update (default "modules")
4748
--required show Required column or section (default true)

docs/reference/markdown-table.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ terraform-docs markdown table [PATH] [flags]
4242
--output-template string output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
4343
--output-values inject output values into outputs (default false)
4444
--output-values-from string inject output values from file into outputs (default "")
45+
--read-comments use comments as description when description is empty (default true)
4546
--recursive update submodules recursively (default false)
4647
--recursive-path string submodules path to recursively update (default "modules")
4748
--required show Required column or section (default true)

docs/reference/markdown.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ terraform-docs markdown [PATH] [flags]
4545
--output-template string output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
4646
--output-values inject output values into outputs (default false)
4747
--output-values-from string inject output values from file into outputs (default "")
48+
--read-comments use comments as description when description is empty (default true)
4849
--recursive update submodules recursively (default false)
4950
--recursive-path string submodules path to recursively update (default "modules")
5051
--show strings show section [all, data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]

docs/reference/pretty.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ terraform-docs pretty [PATH] [flags]
3737
--output-template string output template (default "<!-- BEGIN_TF_DOCS -->\n{{ .Content }}\n<!-- END_TF_DOCS -->")
3838
--output-values inject output values into outputs (default false)
3939
--output-values-from string inject output values from file into outputs (default "")
40+
--read-comments use comments as description when description is empty (default true)
4041
--recursive update submodules recursively (default false)
4142
--recursive-path string submodules path to recursively update (default "modules")
4243
--show strings show section [all, data-sources, footer, header, inputs, modules, outputs, providers, requirements, resources]

0 commit comments

Comments
 (0)