From 82e87aa264924a8f0db35483a0b00eaf5153582f Mon Sep 17 00:00:00 2001 From: Khosrow Moossavi Date: Sun, 12 Jan 2020 15:20:12 -0500 Subject: [PATCH] fix: Do not escape strings inside code blocks (#155) --- examples/main.tf | 6 +- examples/variables.tf | 5 + .../testdata/json-EscapeCharacters.golden | 8 +- .../print/json/testdata/json-NoHeader.golden | 6 + .../print/json/testdata/json-NoInputs.golden | 2 +- .../print/json/testdata/json-NoOutputs.golden | 8 +- .../json/testdata/json-NoProviders.golden | 8 +- .../json/testdata/json-OnlyHeader.golden | 2 +- .../json/testdata/json-OnlyInputs.golden | 6 + .../json/testdata/json-SortByName.golden | 8 +- .../json/testdata/json-SortByRequired.golden | 8 +- internal/pkg/print/json/testdata/json.golden | 8 +- .../testdata/document-EscapeCharacters.golden | 15 ++- .../document-IndentationAboveAllowed.golden | 15 ++- .../document-IndentationBellowAllowed.golden | 15 ++- .../document-IndentationOfFour.golden | 15 ++- .../testdata/document-NoHeader.golden | 9 ++ .../testdata/document-NoInputs.golden | 6 +- .../testdata/document-NoOutputs.golden | 15 ++- .../testdata/document-NoProviders.golden | 15 ++- .../testdata/document-OnlyHeader.golden | 6 +- .../testdata/document-OnlyInputs.golden | 9 ++ .../testdata/document-SortByName.golden | 15 ++- .../testdata/document-SortByRequired.golden | 15 ++- .../testdata/document-WithRequired.golden | 15 ++- .../document/testdata/document.golden | 15 ++- internal/pkg/print/markdown/markdown.go | 105 ++++++++++-------- .../testdata/table-EscapeCharacters.golden | 7 +- .../table-IndentationAboveAllowed.golden | 7 +- .../table-IndentationBellowAllowed.golden | 7 +- .../testdata/table-IndentationOfFour.golden | 7 +- .../table/testdata/table-NoHeader.golden | 1 + .../table/testdata/table-NoInputs.golden | 6 +- .../table/testdata/table-NoOutputs.golden | 7 +- .../table/testdata/table-NoProviders.golden | 7 +- .../table/testdata/table-OnlyHeader.golden | 6 +- .../table/testdata/table-OnlyInputs.golden | 1 + .../table/testdata/table-SortByName.golden | 7 +- .../testdata/table-SortByRequired.golden | 7 +- .../table/testdata/table-WithRequired.golden | 7 +- .../markdown/table/testdata/table.golden | 7 +- .../pretty/testdata/pretty-NoColor.golden | 9 +- .../pretty/testdata/pretty-NoHeader.golden | 3 + .../pretty/testdata/pretty-NoInputs.golden | 6 +- .../pretty/testdata/pretty-NoOutputs.golden | 9 +- .../pretty/testdata/pretty-NoProviders.golden | 9 +- .../pretty/testdata/pretty-OnlyHeader.golden | 6 +- .../pretty/testdata/pretty-OnlyInputs.golden | 3 + .../pretty/testdata/pretty-SortByName.golden | 9 +- .../testdata/pretty-SortByRequired.golden | 9 +- .../pkg/print/pretty/testdata/pretty.golden | 9 +- 51 files changed, 431 insertions(+), 85 deletions(-) diff --git a/examples/main.tf b/examples/main.tf index 3144ddd..f91af75 100644 --- a/examples/main.tf +++ b/examples/main.tf @@ -1,7 +1,10 @@ /** * Usage: * - * module "foo" { + * Example of 'foo_bar' module in `foo_bar.tf`. + * + * ```hcl + * module "foo_bar" { * source = "github.com/foo/bar" * * id = "1234567890" @@ -15,6 +18,7 @@ * Date-Created = "20180101" * } * } + * ``` */ resource "tls_private_key" "baz" {} diff --git a/examples/variables.tf b/examples/variables.tf index a6485fb..a0d3ce1 100644 --- a/examples/variables.tf +++ b/examples/variables.tf @@ -100,3 +100,8 @@ This description is itself markdown. It spans over multiple lines. EOF } + +variable "no-escape-default-value" { + description = "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'." + default = "VALUE_WITH_UNDERSCORE" +} diff --git a/internal/pkg/print/json/testdata/json-EscapeCharacters.golden b/internal/pkg/print/json/testdata/json-EscapeCharacters.golden index 24f1bb0..dac908d 100644 --- a/internal/pkg/print/json/testdata/json-EscapeCharacters.golden +++ b/internal/pkg/print/json/testdata/json-EscapeCharacters.golden @@ -1,5 +1,5 @@ { - "header": "Usage:\n\nmodule \"foo\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}", + "header": "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```", "inputs": [ { "name": "unquoted", @@ -75,6 +75,12 @@ "type": "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })", "description": "This description is itself markdown.\n\nIt spans over multiple lines.\n", "default": "{\n \"bar\": {\n \"bar\": \"bar\",\n \"foo\": \"bar\"\n },\n \"buzz\": [\n \"fizz\",\n \"buzz\"\n ],\n \"fizz\": [],\n \"foo\": {\n \"bar\": \"foo\",\n \"foo\": \"foo\"\n },\n \"name\": \"hello\"\n}" + }, + { + "name": "no-escape-default-value", + "type": "string", + "description": "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'.", + "default": "\"VALUE_WITH_UNDERSCORE\"" } ], "outputs": [ diff --git a/internal/pkg/print/json/testdata/json-NoHeader.golden b/internal/pkg/print/json/testdata/json-NoHeader.golden index 67a0eba..6dd06e0 100644 --- a/internal/pkg/print/json/testdata/json-NoHeader.golden +++ b/internal/pkg/print/json/testdata/json-NoHeader.golden @@ -75,6 +75,12 @@ "type": "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })", "description": "This description is itself markdown.\n\nIt spans over multiple lines.\n", "default": "{\n \"bar\": {\n \"bar\": \"bar\",\n \"foo\": \"bar\"\n },\n \"buzz\": [\n \"fizz\",\n \"buzz\"\n ],\n \"fizz\": [],\n \"foo\": {\n \"bar\": \"foo\",\n \"foo\": \"foo\"\n },\n \"name\": \"hello\"\n}" + }, + { + "name": "no-escape-default-value", + "type": "string", + "description": "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'.", + "default": "\"VALUE_WITH_UNDERSCORE\"" } ], "outputs": [ diff --git a/internal/pkg/print/json/testdata/json-NoInputs.golden b/internal/pkg/print/json/testdata/json-NoInputs.golden index 4ad3a14..2ea338a 100644 --- a/internal/pkg/print/json/testdata/json-NoInputs.golden +++ b/internal/pkg/print/json/testdata/json-NoInputs.golden @@ -1,5 +1,5 @@ { - "header": "Usage:\n\nmodule \"foo\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}", + "header": "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```", "inputs": [], "outputs": [ { diff --git a/internal/pkg/print/json/testdata/json-NoOutputs.golden b/internal/pkg/print/json/testdata/json-NoOutputs.golden index 251e417..b50b2b7 100644 --- a/internal/pkg/print/json/testdata/json-NoOutputs.golden +++ b/internal/pkg/print/json/testdata/json-NoOutputs.golden @@ -1,5 +1,5 @@ { - "header": "Usage:\n\nmodule \"foo\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}", + "header": "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```", "inputs": [ { "name": "unquoted", @@ -75,6 +75,12 @@ "type": "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })", "description": "This description is itself markdown.\n\nIt spans over multiple lines.\n", "default": "{\n \"bar\": {\n \"bar\": \"bar\",\n \"foo\": \"bar\"\n },\n \"buzz\": [\n \"fizz\",\n \"buzz\"\n ],\n \"fizz\": [],\n \"foo\": {\n \"bar\": \"foo\",\n \"foo\": \"foo\"\n },\n \"name\": \"hello\"\n}" + }, + { + "name": "no-escape-default-value", + "type": "string", + "description": "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'.", + "default": "\"VALUE_WITH_UNDERSCORE\"" } ], "outputs": [], diff --git a/internal/pkg/print/json/testdata/json-NoProviders.golden b/internal/pkg/print/json/testdata/json-NoProviders.golden index ddc4e90..135056e 100644 --- a/internal/pkg/print/json/testdata/json-NoProviders.golden +++ b/internal/pkg/print/json/testdata/json-NoProviders.golden @@ -1,5 +1,5 @@ { - "header": "Usage:\n\nmodule \"foo\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}", + "header": "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```", "inputs": [ { "name": "unquoted", @@ -75,6 +75,12 @@ "type": "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })", "description": "This description is itself markdown.\n\nIt spans over multiple lines.\n", "default": "{\n \"bar\": {\n \"bar\": \"bar\",\n \"foo\": \"bar\"\n },\n \"buzz\": [\n \"fizz\",\n \"buzz\"\n ],\n \"fizz\": [],\n \"foo\": {\n \"bar\": \"foo\",\n \"foo\": \"foo\"\n },\n \"name\": \"hello\"\n}" + }, + { + "name": "no-escape-default-value", + "type": "string", + "description": "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'.", + "default": "\"VALUE_WITH_UNDERSCORE\"" } ], "outputs": [ diff --git a/internal/pkg/print/json/testdata/json-OnlyHeader.golden b/internal/pkg/print/json/testdata/json-OnlyHeader.golden index f4a2326..0d02077 100644 --- a/internal/pkg/print/json/testdata/json-OnlyHeader.golden +++ b/internal/pkg/print/json/testdata/json-OnlyHeader.golden @@ -1,5 +1,5 @@ { - "header": "Usage:\n\nmodule \"foo\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}", + "header": "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```", "inputs": [], "outputs": [], "providers": [] diff --git a/internal/pkg/print/json/testdata/json-OnlyInputs.golden b/internal/pkg/print/json/testdata/json-OnlyInputs.golden index eec75c6..c4f8a71 100644 --- a/internal/pkg/print/json/testdata/json-OnlyInputs.golden +++ b/internal/pkg/print/json/testdata/json-OnlyInputs.golden @@ -75,6 +75,12 @@ "type": "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })", "description": "This description is itself markdown.\n\nIt spans over multiple lines.\n", "default": "{\n \"bar\": {\n \"bar\": \"bar\",\n \"foo\": \"bar\"\n },\n \"buzz\": [\n \"fizz\",\n \"buzz\"\n ],\n \"fizz\": [],\n \"foo\": {\n \"bar\": \"foo\",\n \"foo\": \"foo\"\n },\n \"name\": \"hello\"\n}" + }, + { + "name": "no-escape-default-value", + "type": "string", + "description": "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'.", + "default": "\"VALUE_WITH_UNDERSCORE\"" } ], "outputs": [], diff --git a/internal/pkg/print/json/testdata/json-SortByName.golden b/internal/pkg/print/json/testdata/json-SortByName.golden index 503cb50..b003e0d 100644 --- a/internal/pkg/print/json/testdata/json-SortByName.golden +++ b/internal/pkg/print/json/testdata/json-SortByName.golden @@ -1,5 +1,5 @@ { - "header": "Usage:\n\nmodule \"foo\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}", + "header": "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```", "inputs": [ { "name": "input-with-code-block", @@ -56,6 +56,12 @@ "type": "map", "default": "{}" }, + { + "name": "no-escape-default-value", + "type": "string", + "description": "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'.", + "default": "\"VALUE_WITH_UNDERSCORE\"" + }, { "name": "string-1", "type": "string", diff --git a/internal/pkg/print/json/testdata/json-SortByRequired.golden b/internal/pkg/print/json/testdata/json-SortByRequired.golden index 394e550..7c04301 100644 --- a/internal/pkg/print/json/testdata/json-SortByRequired.golden +++ b/internal/pkg/print/json/testdata/json-SortByRequired.golden @@ -1,5 +1,5 @@ { - "header": "Usage:\n\nmodule \"foo\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}", + "header": "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```", "inputs": [ { "name": "input_with_underscores", @@ -65,6 +65,12 @@ "type": "map", "default": "{}" }, + { + "name": "no-escape-default-value", + "type": "string", + "description": "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'.", + "default": "\"VALUE_WITH_UNDERSCORE\"" + }, { "name": "string-1", "type": "string", diff --git a/internal/pkg/print/json/testdata/json.golden b/internal/pkg/print/json/testdata/json.golden index 364f5b1..2d15043 100644 --- a/internal/pkg/print/json/testdata/json.golden +++ b/internal/pkg/print/json/testdata/json.golden @@ -1,5 +1,5 @@ { - "header": "Usage:\n\nmodule \"foo\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}", + "header": "Usage:\n\nExample of 'foo_bar' module in `foo_bar.tf`.\n\n```hcl\nmodule \"foo_bar\" {\n source = \"github.com/foo/bar\"\n\n id = \"1234567890\"\n name = \"baz\"\n\n zones = [\"us-east-1\", \"us-west-1\"]\n\n tags = {\n Name = \"baz\"\n Created-By = \"first.last@email.com\"\n Date-Created = \"20180101\"\n }\n}\n```", "inputs": [ { "name": "unquoted", @@ -75,6 +75,12 @@ "type": "object({\n name = string,\n foo = object({ foo = string, bar = string }),\n bar = object({ foo = string, bar = string }),\n fizz = list(string),\n buzz = list(string)\n })", "description": "This description is itself markdown.\n\nIt spans over multiple lines.\n", "default": "{\n \"bar\": {\n \"bar\": \"bar\",\n \"foo\": \"bar\"\n },\n \"buzz\": [\n \"fizz\",\n \"buzz\"\n ],\n \"fizz\": [],\n \"foo\": {\n \"bar\": \"foo\",\n \"foo\": \"foo\"\n },\n \"name\": \"hello\"\n}" + }, + { + "name": "no-escape-default-value", + "type": "string", + "description": "The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'.", + "default": "\"VALUE_WITH_UNDERSCORE\"" } ], "outputs": [ diff --git a/internal/pkg/print/markdown/document/testdata/document-EscapeCharacters.golden b/internal/pkg/print/markdown/document/testdata/document-EscapeCharacters.golden index 94caea1..b76d9be 100644 --- a/internal/pkg/print/markdown/document/testdata/document-EscapeCharacters.golden +++ b/internal/pkg/print/markdown/document/testdata/document-EscapeCharacters.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo\_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers @@ -147,6 +151,7 @@ Default: `"v1"` Description: This is a complicated one. We need a newline. And an example in a code block + ``` default = [ "machine rack01:neptune" @@ -202,6 +207,14 @@ Default: } ``` +### no-escape-default-value + +Description: The description contains `something_with_underscore`. Defaults to 'VALUE\_WITH\_UNDERSCORE'. + +Type: `string` + +Default: `"VALUE_WITH_UNDERSCORE"` + ## Outputs The following outputs are exported: diff --git a/internal/pkg/print/markdown/document/testdata/document-IndentationAboveAllowed.golden b/internal/pkg/print/markdown/document/testdata/document-IndentationAboveAllowed.golden index 4af66b0..42fb399 100644 --- a/internal/pkg/print/markdown/document/testdata/document-IndentationAboveAllowed.golden +++ b/internal/pkg/print/markdown/document/testdata/document-IndentationAboveAllowed.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers @@ -147,6 +151,7 @@ Default: `"v1"` Description: This is a complicated one. We need a newline. And an example in a code block + ``` default = [ "machine rack01:neptune" @@ -202,6 +207,14 @@ Default: } ``` +### no-escape-default-value + +Description: The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + +Type: `string` + +Default: `"VALUE_WITH_UNDERSCORE"` + ## Outputs The following outputs are exported: diff --git a/internal/pkg/print/markdown/document/testdata/document-IndentationBellowAllowed.golden b/internal/pkg/print/markdown/document/testdata/document-IndentationBellowAllowed.golden index 4af66b0..42fb399 100644 --- a/internal/pkg/print/markdown/document/testdata/document-IndentationBellowAllowed.golden +++ b/internal/pkg/print/markdown/document/testdata/document-IndentationBellowAllowed.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers @@ -147,6 +151,7 @@ Default: `"v1"` Description: This is a complicated one. We need a newline. And an example in a code block + ``` default = [ "machine rack01:neptune" @@ -202,6 +207,14 @@ Default: } ``` +### no-escape-default-value + +Description: The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + +Type: `string` + +Default: `"VALUE_WITH_UNDERSCORE"` + ## Outputs The following outputs are exported: diff --git a/internal/pkg/print/markdown/document/testdata/document-IndentationOfFour.golden b/internal/pkg/print/markdown/document/testdata/document-IndentationOfFour.golden index 63784c0..7c9bf39 100644 --- a/internal/pkg/print/markdown/document/testdata/document-IndentationOfFour.golden +++ b/internal/pkg/print/markdown/document/testdata/document-IndentationOfFour.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` #### Providers @@ -147,6 +151,7 @@ Default: `"v1"` Description: This is a complicated one. We need a newline. And an example in a code block + ``` default = [ "machine rack01:neptune" @@ -202,6 +207,14 @@ Default: } ``` +##### no-escape-default-value + +Description: The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + +Type: `string` + +Default: `"VALUE_WITH_UNDERSCORE"` + #### Outputs The following outputs are exported: diff --git a/internal/pkg/print/markdown/document/testdata/document-NoHeader.golden b/internal/pkg/print/markdown/document/testdata/document-NoHeader.golden index 6cfb29a..96e1b79 100644 --- a/internal/pkg/print/markdown/document/testdata/document-NoHeader.golden +++ b/internal/pkg/print/markdown/document/testdata/document-NoHeader.golden @@ -130,6 +130,7 @@ Default: `"v1"` Description: This is a complicated one. We need a newline. And an example in a code block + ``` default = [ "machine rack01:neptune" @@ -185,6 +186,14 @@ Default: } ``` +### no-escape-default-value + +Description: The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + +Type: `string` + +Default: `"VALUE_WITH_UNDERSCORE"` + ## Outputs The following outputs are exported: diff --git a/internal/pkg/print/markdown/document/testdata/document-NoInputs.golden b/internal/pkg/print/markdown/document/testdata/document-NoInputs.golden index d23f3ef..322c085 100644 --- a/internal/pkg/print/markdown/document/testdata/document-NoInputs.golden +++ b/internal/pkg/print/markdown/document/testdata/document-NoInputs.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers diff --git a/internal/pkg/print/markdown/document/testdata/document-NoOutputs.golden b/internal/pkg/print/markdown/document/testdata/document-NoOutputs.golden index 1f9d0ba..8096730 100644 --- a/internal/pkg/print/markdown/document/testdata/document-NoOutputs.golden +++ b/internal/pkg/print/markdown/document/testdata/document-NoOutputs.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers @@ -147,6 +151,7 @@ Default: `"v1"` Description: This is a complicated one. We need a newline. And an example in a code block + ``` default = [ "machine rack01:neptune" @@ -201,3 +206,11 @@ Default: "name": "hello" } ``` + +### no-escape-default-value + +Description: The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + +Type: `string` + +Default: `"VALUE_WITH_UNDERSCORE"` diff --git a/internal/pkg/print/markdown/document/testdata/document-NoProviders.golden b/internal/pkg/print/markdown/document/testdata/document-NoProviders.golden index ca58033..bff68ba 100644 --- a/internal/pkg/print/markdown/document/testdata/document-NoProviders.golden +++ b/internal/pkg/print/markdown/document/testdata/document-NoProviders.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Inputs @@ -135,6 +139,7 @@ Default: `"v1"` Description: This is a complicated one. We need a newline. And an example in a code block + ``` default = [ "machine rack01:neptune" @@ -190,6 +195,14 @@ Default: } ``` +### no-escape-default-value + +Description: The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + +Type: `string` + +Default: `"VALUE_WITH_UNDERSCORE"` + ## Outputs The following outputs are exported: diff --git a/internal/pkg/print/markdown/document/testdata/document-OnlyHeader.golden b/internal/pkg/print/markdown/document/testdata/document-OnlyHeader.golden index ebf2d9d..99f8552 100644 --- a/internal/pkg/print/markdown/document/testdata/document-OnlyHeader.golden +++ b/internal/pkg/print/markdown/document/testdata/document-OnlyHeader.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,3 +17,4 @@ module "foo" { Date-Created = "20180101" } } +``` diff --git a/internal/pkg/print/markdown/document/testdata/document-OnlyInputs.golden b/internal/pkg/print/markdown/document/testdata/document-OnlyInputs.golden index b9cad50..05cfec7 100644 --- a/internal/pkg/print/markdown/document/testdata/document-OnlyInputs.golden +++ b/internal/pkg/print/markdown/document/testdata/document-OnlyInputs.golden @@ -118,6 +118,7 @@ Default: `"v1"` Description: This is a complicated one. We need a newline. And an example in a code block + ``` default = [ "machine rack01:neptune" @@ -172,3 +173,11 @@ Default: "name": "hello" } ``` + +### no-escape-default-value + +Description: The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + +Type: `string` + +Default: `"VALUE_WITH_UNDERSCORE"` diff --git a/internal/pkg/print/markdown/document/testdata/document-SortByName.golden b/internal/pkg/print/markdown/document/testdata/document-SortByName.golden index 0a18a88..a0c980d 100644 --- a/internal/pkg/print/markdown/document/testdata/document-SortByName.golden +++ b/internal/pkg/print/markdown/document/testdata/document-SortByName.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers @@ -35,6 +39,7 @@ The following input variables are supported: Description: This is a complicated one. We need a newline. And an example in a code block + ``` default = [ "machine rack01:neptune" @@ -170,6 +175,14 @@ Type: `map` Default: `{}` +### no-escape-default-value + +Description: The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + +Type: `string` + +Default: `"VALUE_WITH_UNDERSCORE"` + ### string-1 Description: It's string number one. diff --git a/internal/pkg/print/markdown/document/testdata/document-SortByRequired.golden b/internal/pkg/print/markdown/document/testdata/document-SortByRequired.golden index 8252213..ba6ae26 100644 --- a/internal/pkg/print/markdown/document/testdata/document-SortByRequired.golden +++ b/internal/pkg/print/markdown/document/testdata/document-SortByRequired.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers @@ -75,6 +79,7 @@ Default: n/a Description: This is a complicated one. We need a newline. And an example in a code block + ``` default = [ "machine rack01:neptune" @@ -186,6 +191,14 @@ Type: `map` Default: `{}` +### no-escape-default-value + +Description: The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + +Type: `string` + +Default: `"VALUE_WITH_UNDERSCORE"` + ### string-1 Description: It's string number one. diff --git a/internal/pkg/print/markdown/document/testdata/document-WithRequired.golden b/internal/pkg/print/markdown/document/testdata/document-WithRequired.golden index 35debe3..71862be 100644 --- a/internal/pkg/print/markdown/document/testdata/document-WithRequired.golden +++ b/internal/pkg/print/markdown/document/testdata/document-WithRequired.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers @@ -141,6 +145,7 @@ Default: `"v1"` Description: This is a complicated one. We need a newline. And an example in a code block + ``` default = [ "machine rack01:neptune" @@ -196,6 +201,14 @@ Default: } ``` +### no-escape-default-value + +Description: The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + +Type: `string` + +Default: `"VALUE_WITH_UNDERSCORE"` + ## Outputs The following outputs are exported: diff --git a/internal/pkg/print/markdown/document/testdata/document.golden b/internal/pkg/print/markdown/document/testdata/document.golden index 4af66b0..42fb399 100644 --- a/internal/pkg/print/markdown/document/testdata/document.golden +++ b/internal/pkg/print/markdown/document/testdata/document.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers @@ -147,6 +151,7 @@ Default: `"v1"` Description: This is a complicated one. We need a newline. And an example in a code block + ``` default = [ "machine rack01:neptune" @@ -202,6 +207,14 @@ Default: } ``` +### no-escape-default-value + +Description: The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + +Type: `string` + +Default: `"VALUE_WITH_UNDERSCORE"` + ## Outputs The following outputs are exported: diff --git a/internal/pkg/print/markdown/markdown.go b/internal/pkg/print/markdown/markdown.go index dc7128b..a07349f 100644 --- a/internal/pkg/print/markdown/markdown.go +++ b/internal/pkg/print/markdown/markdown.go @@ -36,37 +36,30 @@ func SanitizeName(name string, settings *print.Settings) string { // Escape underscore name = strings.Replace(name, "_", "\\_", -1) } - return name } -// SanitizeItemForDocument converts passed 'string to suitable Markdown representation +// SanitizeItemForDocument converts passed 'string' to suitable Markdown representation // for a document. (including line-break, illegal characters, code blocks etc) func SanitizeItemForDocument(s string, settings *print.Settings) string { if s == "" { return "n/a" } - // Isolate blocks of code. Dont escape anything inside them - nextIsInCodeBlock := strings.HasPrefix(s, "```\n") - segments := strings.Split(s, "\n```\n") - buf := bytes.NewBufferString("") - for i, segment := range segments { - if !nextIsInCodeBlock { + result := processSegments( + s, + "\n```", + func(segment string) string { segment = ConvertMultiLineText(segment, false) segment = EscapeIllegalCharacters(segment, settings) - if i > 0 && len(segment) > 0 { - buf.WriteString("\n```\n") - } - buf.WriteString(segment) - nextIsInCodeBlock = true - } else { - buf.WriteString("\n```\n") - buf.WriteString(segment) - buf.WriteString("\n```") - nextIsInCodeBlock = false - } - } - return strings.Replace(buf.String(), "
", "\n", -1) + segment = fmt.Sprintf("%s\n", segment) + return segment + }, + func(segment string) string { + segment = fmt.Sprintf("\n```%s\n```", segment) + return segment + }, + ) + return strings.Replace(result, "
", "\n", -1) } // SanitizeItemForTable converts passed 'string' to suitable Markdown representation @@ -75,30 +68,24 @@ func SanitizeItemForTable(s string, settings *print.Settings) string { if s == "" { return "n/a" } - // Isolate blocks of code. Dont escape anything inside them - nextIsInCodeBlock := strings.HasPrefix(s, "```\n") - segments := strings.Split(s, "```\n") - buf := bytes.NewBufferString("") - for _, segment := range segments { - if !nextIsInCodeBlock { + result := processSegments( + s, + "```\n", + func(segment string) string { segment = ConvertMultiLineText(segment, true) segment = EscapeIllegalCharacters(segment, settings) - buf.WriteString(segment) - nextIsInCodeBlock = true - } else { - buf.WriteString("
")
-			buf.WriteString(strings.Replace(strings.Replace(segment, "\n", "
", -1), "\r", "", -1)) - buf.WriteString("
") - nextIsInCodeBlock = false - } - } - - return buf.String() + return segment + }, + func(segment string) string { + segment = fmt.Sprintf("
%s
", strings.Replace(strings.Replace(segment, "\n", "
", -1), "\r", "", -1)) + return segment + }, + ) + return result } // ConvertMultiLineText converts a multi-line text into a suitable Markdown representation. func ConvertMultiLineText(s string, convertDoubleSpaces bool) string { - // Convert double newlines to

. s = strings.Replace( strings.TrimSpace(s), @@ -124,11 +111,21 @@ func EscapeIllegalCharacters(s string, settings *print.Settings) string { s = strings.Replace(s, "|", "\\|", -1) if settings.EscapeCharacters { - // Escape underscore - s = strings.Replace(s, "_", "\\_", -1) - - // Escape asterisk - s = strings.Replace(s, "*", "\\*", -1) + s = processSegments( + s, + "`", + func(segment string) string { + // Escape underscore + segment = strings.Replace(segment, "_", "\\_", -1) + // Escape asterisk + segment = strings.Replace(segment, "*", "\\*", -1) + return segment + }, + func(segment string) string { + segment = fmt.Sprintf("`%s`", segment) + return segment + }, + ) } return s @@ -161,3 +158,23 @@ func PrintFencedCodeBlock(code string, language string) (string, bool) { } return fmt.Sprintf("`%s`", code), false } + +func processSegments(s string, prefix string, normalFn func(segment string) string, codeFn func(segment string) string) string { + // Isolate blocks of code. Dont escape anything inside them + nextIsInCodeBlock := strings.HasPrefix(s, prefix) + segments := strings.Split(s, prefix) + buffer := bytes.NewBufferString("") + for _, segment := range segments { + if len(segment) == 0 { + continue + } + if !nextIsInCodeBlock { + segment = normalFn(segment) + } else { + segment = codeFn(segment) + } + buffer.WriteString(segment) + nextIsInCodeBlock = !nextIsInCodeBlock + } + return buffer.String() +} diff --git a/internal/pkg/print/markdown/table/testdata/table-EscapeCharacters.golden b/internal/pkg/print/markdown/table/testdata/table-EscapeCharacters.golden index 5bcd480..10feec5 100644 --- a/internal/pkg/print/markdown/table/testdata/table-EscapeCharacters.golden +++ b/internal/pkg/print/markdown/table/testdata/table-EscapeCharacters.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo\_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers @@ -42,6 +46,7 @@ module "foo" { | input-with-pipe | It includes v1 \| v2 \| v3 | `string` | `"v1"` | | input-with-code-block | This is a complicated one. We need a newline.
And an example in a code block
default     = [
"machine rack01:neptune"
]
| `list` |
[
"name rack:location"
]
| | long\_type | This description is itself markdown.

It spans over multiple lines. |
object({
name = string,
foo = object({ foo = string, bar = string }),
bar = object({ foo = string, bar = string }),
fizz = list(string),
buzz = list(string)
})
|
{
"bar": {
"bar": "bar",
"foo": "bar"
},
"buzz": [
"fizz",
"buzz"
],
"fizz": [],
"foo": {
"bar": "foo",
"foo": "foo"
},
"name": "hello"
}
| +| no-escape-default-value | The description contains `something_with_underscore`. Defaults to 'VALUE\_WITH\_UNDERSCORE'. | `string` | `"VALUE_WITH_UNDERSCORE"` | ## Outputs diff --git a/internal/pkg/print/markdown/table/testdata/table-IndentationAboveAllowed.golden b/internal/pkg/print/markdown/table/testdata/table-IndentationAboveAllowed.golden index 3305262..28d1238 100644 --- a/internal/pkg/print/markdown/table/testdata/table-IndentationAboveAllowed.golden +++ b/internal/pkg/print/markdown/table/testdata/table-IndentationAboveAllowed.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers @@ -42,6 +46,7 @@ module "foo" { | input-with-pipe | It includes v1 \| v2 \| v3 | `string` | `"v1"` | | input-with-code-block | This is a complicated one. We need a newline.
And an example in a code block
default     = [
"machine rack01:neptune"
]
| `list` |
[
"name rack:location"
]
| | long_type | This description is itself markdown.

It spans over multiple lines. |
object({
name = string,
foo = object({ foo = string, bar = string }),
bar = object({ foo = string, bar = string }),
fizz = list(string),
buzz = list(string)
})
|
{
"bar": {
"bar": "bar",
"foo": "bar"
},
"buzz": [
"fizz",
"buzz"
],
"fizz": [],
"foo": {
"bar": "foo",
"foo": "foo"
},
"name": "hello"
}
| +| no-escape-default-value | The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. | `string` | `"VALUE_WITH_UNDERSCORE"` | ## Outputs diff --git a/internal/pkg/print/markdown/table/testdata/table-IndentationBellowAllowed.golden b/internal/pkg/print/markdown/table/testdata/table-IndentationBellowAllowed.golden index 3305262..28d1238 100644 --- a/internal/pkg/print/markdown/table/testdata/table-IndentationBellowAllowed.golden +++ b/internal/pkg/print/markdown/table/testdata/table-IndentationBellowAllowed.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers @@ -42,6 +46,7 @@ module "foo" { | input-with-pipe | It includes v1 \| v2 \| v3 | `string` | `"v1"` | | input-with-code-block | This is a complicated one. We need a newline.
And an example in a code block
default     = [
"machine rack01:neptune"
]
| `list` |
[
"name rack:location"
]
| | long_type | This description is itself markdown.

It spans over multiple lines. |
object({
name = string,
foo = object({ foo = string, bar = string }),
bar = object({ foo = string, bar = string }),
fizz = list(string),
buzz = list(string)
})
|
{
"bar": {
"bar": "bar",
"foo": "bar"
},
"buzz": [
"fizz",
"buzz"
],
"fizz": [],
"foo": {
"bar": "foo",
"foo": "foo"
},
"name": "hello"
}
| +| no-escape-default-value | The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. | `string` | `"VALUE_WITH_UNDERSCORE"` | ## Outputs diff --git a/internal/pkg/print/markdown/table/testdata/table-IndentationOfFour.golden b/internal/pkg/print/markdown/table/testdata/table-IndentationOfFour.golden index 2e792eb..aeedd84 100644 --- a/internal/pkg/print/markdown/table/testdata/table-IndentationOfFour.golden +++ b/internal/pkg/print/markdown/table/testdata/table-IndentationOfFour.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` #### Providers @@ -42,6 +46,7 @@ module "foo" { | input-with-pipe | It includes v1 \| v2 \| v3 | `string` | `"v1"` | | input-with-code-block | This is a complicated one. We need a newline.
And an example in a code block
default     = [
"machine rack01:neptune"
]
| `list` |
[
"name rack:location"
]
| | long_type | This description is itself markdown.

It spans over multiple lines. |
object({
name = string,
foo = object({ foo = string, bar = string }),
bar = object({ foo = string, bar = string }),
fizz = list(string),
buzz = list(string)
})
|
{
"bar": {
"bar": "bar",
"foo": "bar"
},
"buzz": [
"fizz",
"buzz"
],
"fizz": [],
"foo": {
"bar": "foo",
"foo": "foo"
},
"name": "hello"
}
| +| no-escape-default-value | The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. | `string` | `"VALUE_WITH_UNDERSCORE"` | #### Outputs diff --git a/internal/pkg/print/markdown/table/testdata/table-NoHeader.golden b/internal/pkg/print/markdown/table/testdata/table-NoHeader.golden index 302a56c..3f3e970 100644 --- a/internal/pkg/print/markdown/table/testdata/table-NoHeader.golden +++ b/internal/pkg/print/markdown/table/testdata/table-NoHeader.golden @@ -25,6 +25,7 @@ | input-with-pipe | It includes v1 \| v2 \| v3 | `string` | `"v1"` | | input-with-code-block | This is a complicated one. We need a newline.
And an example in a code block
default     = [
"machine rack01:neptune"
]
| `list` |
[
"name rack:location"
]
| | long_type | This description is itself markdown.

It spans over multiple lines. |
object({
name = string,
foo = object({ foo = string, bar = string }),
bar = object({ foo = string, bar = string }),
fizz = list(string),
buzz = list(string)
})
|
{
"bar": {
"bar": "bar",
"foo": "bar"
},
"buzz": [
"fizz",
"buzz"
],
"fizz": [],
"foo": {
"bar": "foo",
"foo": "foo"
},
"name": "hello"
}
| +| no-escape-default-value | The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. | `string` | `"VALUE_WITH_UNDERSCORE"` | ## Outputs diff --git a/internal/pkg/print/markdown/table/testdata/table-NoInputs.golden b/internal/pkg/print/markdown/table/testdata/table-NoInputs.golden index 56f4d65..10fca77 100644 --- a/internal/pkg/print/markdown/table/testdata/table-NoInputs.golden +++ b/internal/pkg/print/markdown/table/testdata/table-NoInputs.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers diff --git a/internal/pkg/print/markdown/table/testdata/table-NoOutputs.golden b/internal/pkg/print/markdown/table/testdata/table-NoOutputs.golden index bb26b73..fb7d534 100644 --- a/internal/pkg/print/markdown/table/testdata/table-NoOutputs.golden +++ b/internal/pkg/print/markdown/table/testdata/table-NoOutputs.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers @@ -42,3 +46,4 @@ module "foo" { | input-with-pipe | It includes v1 \| v2 \| v3 | `string` | `"v1"` | | input-with-code-block | This is a complicated one. We need a newline.
And an example in a code block
default     = [
"machine rack01:neptune"
]
| `list` |
[
"name rack:location"
]
| | long_type | This description is itself markdown.

It spans over multiple lines. |
object({
name = string,
foo = object({ foo = string, bar = string }),
bar = object({ foo = string, bar = string }),
fizz = list(string),
buzz = list(string)
})
|
{
"bar": {
"bar": "bar",
"foo": "bar"
},
"buzz": [
"fizz",
"buzz"
],
"fizz": [],
"foo": {
"bar": "foo",
"foo": "foo"
},
"name": "hello"
}
| +| no-escape-default-value | The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. | `string` | `"VALUE_WITH_UNDERSCORE"` | diff --git a/internal/pkg/print/markdown/table/testdata/table-NoProviders.golden b/internal/pkg/print/markdown/table/testdata/table-NoProviders.golden index 68b0e33..b68dad8 100644 --- a/internal/pkg/print/markdown/table/testdata/table-NoProviders.golden +++ b/internal/pkg/print/markdown/table/testdata/table-NoProviders.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Inputs @@ -33,6 +37,7 @@ module "foo" { | input-with-pipe | It includes v1 \| v2 \| v3 | `string` | `"v1"` | | input-with-code-block | This is a complicated one. We need a newline.
And an example in a code block
default     = [
"machine rack01:neptune"
]
| `list` |
[
"name rack:location"
]
| | long_type | This description is itself markdown.

It spans over multiple lines. |
object({
name = string,
foo = object({ foo = string, bar = string }),
bar = object({ foo = string, bar = string }),
fizz = list(string),
buzz = list(string)
})
|
{
"bar": {
"bar": "bar",
"foo": "bar"
},
"buzz": [
"fizz",
"buzz"
],
"fizz": [],
"foo": {
"bar": "foo",
"foo": "foo"
},
"name": "hello"
}
| +| no-escape-default-value | The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. | `string` | `"VALUE_WITH_UNDERSCORE"` | ## Outputs diff --git a/internal/pkg/print/markdown/table/testdata/table-OnlyHeader.golden b/internal/pkg/print/markdown/table/testdata/table-OnlyHeader.golden index ebf2d9d..99f8552 100644 --- a/internal/pkg/print/markdown/table/testdata/table-OnlyHeader.golden +++ b/internal/pkg/print/markdown/table/testdata/table-OnlyHeader.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,3 +17,4 @@ module "foo" { Date-Created = "20180101" } } +``` diff --git a/internal/pkg/print/markdown/table/testdata/table-OnlyInputs.golden b/internal/pkg/print/markdown/table/testdata/table-OnlyInputs.golden index 5d9fb65..ada972a 100644 --- a/internal/pkg/print/markdown/table/testdata/table-OnlyInputs.golden +++ b/internal/pkg/print/markdown/table/testdata/table-OnlyInputs.golden @@ -16,3 +16,4 @@ | input-with-pipe | It includes v1 \| v2 \| v3 | `string` | `"v1"` | | input-with-code-block | This is a complicated one. We need a newline.
And an example in a code block
default     = [
"machine rack01:neptune"
]
| `list` |
[
"name rack:location"
]
| | long_type | This description is itself markdown.

It spans over multiple lines. |
object({
name = string,
foo = object({ foo = string, bar = string }),
bar = object({ foo = string, bar = string }),
fizz = list(string),
buzz = list(string)
})
|
{
"bar": {
"bar": "bar",
"foo": "bar"
},
"buzz": [
"fizz",
"buzz"
],
"fizz": [],
"foo": {
"bar": "foo",
"foo": "foo"
},
"name": "hello"
}
| +| no-escape-default-value | The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. | `string` | `"VALUE_WITH_UNDERSCORE"` | diff --git a/internal/pkg/print/markdown/table/testdata/table-SortByName.golden b/internal/pkg/print/markdown/table/testdata/table-SortByName.golden index 2e8a7b9..7677753 100644 --- a/internal/pkg/print/markdown/table/testdata/table-SortByName.golden +++ b/internal/pkg/print/markdown/table/testdata/table-SortByName.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers @@ -38,6 +42,7 @@ module "foo" { | map-1 | It's map number one. | `map` |
{
"a": 1,
"b": 2,
"c": 3
}
| | map-2 | It's map number two. | `map` | n/a | | map-3 | n/a | `map` | `{}` | +| no-escape-default-value | The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. | `string` | `"VALUE_WITH_UNDERSCORE"` | | string-1 | It's string number one. | `string` | `"bar"` | | string-2 | It's string number two. | `string` | n/a | | string-3 | n/a | `string` | `""` | diff --git a/internal/pkg/print/markdown/table/testdata/table-SortByRequired.golden b/internal/pkg/print/markdown/table/testdata/table-SortByRequired.golden index 198a03f..2d2c876 100644 --- a/internal/pkg/print/markdown/table/testdata/table-SortByRequired.golden +++ b/internal/pkg/print/markdown/table/testdata/table-SortByRequired.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers @@ -40,6 +44,7 @@ module "foo" { | long_type | This description is itself markdown.

It spans over multiple lines. |
object({
name = string,
foo = object({ foo = string, bar = string }),
bar = object({ foo = string, bar = string }),
fizz = list(string),
buzz = list(string)
})
|
{
"bar": {
"bar": "bar",
"foo": "bar"
},
"buzz": [
"fizz",
"buzz"
],
"fizz": [],
"foo": {
"bar": "foo",
"foo": "foo"
},
"name": "hello"
}
| | map-1 | It's map number one. | `map` |
{
"a": 1,
"b": 2,
"c": 3
}
| | map-3 | n/a | `map` | `{}` | +| no-escape-default-value | The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. | `string` | `"VALUE_WITH_UNDERSCORE"` | | string-1 | It's string number one. | `string` | `"bar"` | | string-3 | n/a | `string` | `""` | diff --git a/internal/pkg/print/markdown/table/testdata/table-WithRequired.golden b/internal/pkg/print/markdown/table/testdata/table-WithRequired.golden index 3cccc63..d541421 100644 --- a/internal/pkg/print/markdown/table/testdata/table-WithRequired.golden +++ b/internal/pkg/print/markdown/table/testdata/table-WithRequired.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers @@ -42,6 +46,7 @@ module "foo" { | input-with-pipe | It includes v1 \| v2 \| v3 | `string` | `"v1"` | no | | input-with-code-block | This is a complicated one. We need a newline.
And an example in a code block
default     = [
"machine rack01:neptune"
]
| `list` |
[
"name rack:location"
]
| no | | long_type | This description is itself markdown.

It spans over multiple lines. |
object({
name = string,
foo = object({ foo = string, bar = string }),
bar = object({ foo = string, bar = string }),
fizz = list(string),
buzz = list(string)
})
|
{
"bar": {
"bar": "bar",
"foo": "bar"
},
"buzz": [
"fizz",
"buzz"
],
"fizz": [],
"foo": {
"bar": "foo",
"foo": "foo"
},
"name": "hello"
}
| no | +| no-escape-default-value | The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. | `string` | `"VALUE_WITH_UNDERSCORE"` | no | ## Outputs diff --git a/internal/pkg/print/markdown/table/testdata/table.golden b/internal/pkg/print/markdown/table/testdata/table.golden index 3305262..28d1238 100644 --- a/internal/pkg/print/markdown/table/testdata/table.golden +++ b/internal/pkg/print/markdown/table/testdata/table.golden @@ -1,6 +1,9 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -14,6 +17,7 @@ module "foo" { Date-Created = "20180101" } } +``` ## Providers @@ -42,6 +46,7 @@ module "foo" { | input-with-pipe | It includes v1 \| v2 \| v3 | `string` | `"v1"` | | input-with-code-block | This is a complicated one. We need a newline.
And an example in a code block
default     = [
"machine rack01:neptune"
]
| `list` |
[
"name rack:location"
]
| | long_type | This description is itself markdown.

It spans over multiple lines. |
object({
name = string,
foo = object({ foo = string, bar = string }),
bar = object({ foo = string, bar = string }),
fizz = list(string),
buzz = list(string)
})
|
{
"bar": {
"bar": "bar",
"foo": "bar"
},
"buzz": [
"fizz",
"buzz"
],
"fizz": [],
"foo": {
"bar": "foo",
"foo": "foo"
},
"name": "hello"
}
| +| no-escape-default-value | The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. | `string` | `"VALUE_WITH_UNDERSCORE"` | ## Outputs diff --git a/internal/pkg/print/pretty/testdata/pretty-NoColor.golden b/internal/pkg/print/pretty/testdata/pretty-NoColor.golden index f88c54d..47c6857 100644 --- a/internal/pkg/print/pretty/testdata/pretty-NoColor.golden +++ b/internal/pkg/print/pretty/testdata/pretty-NoColor.golden @@ -2,7 +2,10 @@ Usage: -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" { source = "github.com/foo/bar" id = "1234567890" @@ -16,6 +19,7 @@ module "foo" { Date-Created = "20180101" } } +``` @@ -104,6 +108,9 @@ This description is itself markdown. It spans over multiple lines. +input.no-escape-default-value ("VALUE_WITH_UNDERSCORE") +The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + output.unquoted diff --git a/internal/pkg/print/pretty/testdata/pretty-NoHeader.golden b/internal/pkg/print/pretty/testdata/pretty-NoHeader.golden index 77a3ac9..b956293 100644 --- a/internal/pkg/print/pretty/testdata/pretty-NoHeader.golden +++ b/internal/pkg/print/pretty/testdata/pretty-NoHeader.golden @@ -75,6 +75,9 @@ default = [ It spans over multiple lines. +input.no-escape-default-value ("VALUE_WITH_UNDERSCORE") +The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + output.unquoted diff --git a/internal/pkg/print/pretty/testdata/pretty-NoInputs.golden b/internal/pkg/print/pretty/testdata/pretty-NoInputs.golden index 9f5090c..6ef99d7 100644 --- a/internal/pkg/print/pretty/testdata/pretty-NoInputs.golden +++ b/internal/pkg/print/pretty/testdata/pretty-NoInputs.golden @@ -2,7 +2,10 @@ Usage:  -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" {  source = "github.com/foo/bar"   id = "1234567890" @@ -16,6 +19,7 @@  Date-Created = "20180101"  } } +``` diff --git a/internal/pkg/print/pretty/testdata/pretty-NoOutputs.golden b/internal/pkg/print/pretty/testdata/pretty-NoOutputs.golden index f8cc7d7..53095cf 100644 --- a/internal/pkg/print/pretty/testdata/pretty-NoOutputs.golden +++ b/internal/pkg/print/pretty/testdata/pretty-NoOutputs.golden @@ -2,7 +2,10 @@ Usage:  -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" {  source = "github.com/foo/bar"   id = "1234567890" @@ -16,6 +19,7 @@  Date-Created = "20180101"  } } +``` @@ -104,3 +108,6 @@ default = [ It spans over multiple lines. +input.no-escape-default-value ("VALUE_WITH_UNDERSCORE") +The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + diff --git a/internal/pkg/print/pretty/testdata/pretty-NoProviders.golden b/internal/pkg/print/pretty/testdata/pretty-NoProviders.golden index 3cb1c0c..b895806 100644 --- a/internal/pkg/print/pretty/testdata/pretty-NoProviders.golden +++ b/internal/pkg/print/pretty/testdata/pretty-NoProviders.golden @@ -2,7 +2,10 @@ Usage:  -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" {  source = "github.com/foo/bar"   id = "1234567890" @@ -16,6 +19,7 @@  Date-Created = "20180101"  } } +``` @@ -94,6 +98,9 @@ default = [ It spans over multiple lines. +input.no-escape-default-value ("VALUE_WITH_UNDERSCORE") +The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + output.unquoted diff --git a/internal/pkg/print/pretty/testdata/pretty-OnlyHeader.golden b/internal/pkg/print/pretty/testdata/pretty-OnlyHeader.golden index 06d79b0..f1263be 100644 --- a/internal/pkg/print/pretty/testdata/pretty-OnlyHeader.golden +++ b/internal/pkg/print/pretty/testdata/pretty-OnlyHeader.golden @@ -2,7 +2,10 @@ Usage:  -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" {  source = "github.com/foo/bar"   id = "1234567890" @@ -16,4 +19,5 @@  Date-Created = "20180101"  } } +``` diff --git a/internal/pkg/print/pretty/testdata/pretty-OnlyInputs.golden b/internal/pkg/print/pretty/testdata/pretty-OnlyInputs.golden index c252a1e..6bfef1f 100644 --- a/internal/pkg/print/pretty/testdata/pretty-OnlyInputs.golden +++ b/internal/pkg/print/pretty/testdata/pretty-OnlyInputs.golden @@ -75,3 +75,6 @@ default = [ It spans over multiple lines. +input.no-escape-default-value ("VALUE_WITH_UNDERSCORE") +The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + diff --git a/internal/pkg/print/pretty/testdata/pretty-SortByName.golden b/internal/pkg/print/pretty/testdata/pretty-SortByName.golden index 8d06400..00e8659 100644 --- a/internal/pkg/print/pretty/testdata/pretty-SortByName.golden +++ b/internal/pkg/print/pretty/testdata/pretty-SortByName.golden @@ -2,7 +2,10 @@ Usage:  -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" {  source = "github.com/foo/bar"   id = "1234567890" @@ -16,6 +19,7 @@  Date-Created = "20180101"  } } +``` @@ -92,6 +96,9 @@ It spans over multiple lines. input.map-3 ({}) n/a +input.no-escape-default-value ("VALUE_WITH_UNDERSCORE") +The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + input.string-1 ("bar") It's string number one. diff --git a/internal/pkg/print/pretty/testdata/pretty-SortByRequired.golden b/internal/pkg/print/pretty/testdata/pretty-SortByRequired.golden index 9d4892a..0b2fd08 100644 --- a/internal/pkg/print/pretty/testdata/pretty-SortByRequired.golden +++ b/internal/pkg/print/pretty/testdata/pretty-SortByRequired.golden @@ -2,7 +2,10 @@ Usage:  -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" {  source = "github.com/foo/bar"   id = "1234567890" @@ -16,6 +19,7 @@  Date-Created = "20180101"  } } +``` @@ -98,6 +102,9 @@ It spans over multiple lines. input.map-3 ({}) n/a +input.no-escape-default-value ("VALUE_WITH_UNDERSCORE") +The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + input.string-1 ("bar") It's string number one. diff --git a/internal/pkg/print/pretty/testdata/pretty.golden b/internal/pkg/print/pretty/testdata/pretty.golden index 7eaa587..3314b17 100644 --- a/internal/pkg/print/pretty/testdata/pretty.golden +++ b/internal/pkg/print/pretty/testdata/pretty.golden @@ -2,7 +2,10 @@ Usage:  -module "foo" { +Example of 'foo_bar' module in `foo_bar.tf`. + +```hcl +module "foo_bar" {  source = "github.com/foo/bar"   id = "1234567890" @@ -16,6 +19,7 @@  Date-Created = "20180101"  } } +``` @@ -104,6 +108,9 @@ default = [ It spans over multiple lines. +input.no-escape-default-value ("VALUE_WITH_UNDERSCORE") +The description contains `something_with_underscore`. Defaults to 'VALUE_WITH_UNDERSCORE'. + output.unquoted