mirror of
https://github.com/terraform-docs/terraform-docs.git
synced 2026-03-27 12:58:35 +07:00
Move format package from internal to public
Signed-off-by: Khosrow Moossavi <khos2ow@gmail.com>
This commit is contained in:
@@ -37,7 +37,7 @@ func NewAsciidocDocument(settings *print.Settings) print.Engine {
|
|||||||
tt := template.New(settings, items...)
|
tt := template.New(settings, items...)
|
||||||
tt.CustomFunc(gotemplate.FuncMap{
|
tt.CustomFunc(gotemplate.FuncMap{
|
||||||
"type": func(t string) string {
|
"type": func(t string) string {
|
||||||
result, extraline := printFencedAsciidocCodeBlock(t, "hcl")
|
result, extraline := PrintFencedAsciidocCodeBlock(t, "hcl")
|
||||||
if !extraline {
|
if !extraline {
|
||||||
result += "\n"
|
result += "\n"
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ func NewAsciidocDocument(settings *print.Settings) print.Engine {
|
|||||||
if v == "n/a" {
|
if v == "n/a" {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
result, extraline := printFencedAsciidocCodeBlock(v, "json")
|
result, extraline := PrintFencedAsciidocCodeBlock(v, "json")
|
||||||
if !extraline {
|
if !extraline {
|
||||||
result += "\n"
|
result += "\n"
|
||||||
}
|
}
|
||||||
@@ -37,13 +37,13 @@ func NewAsciidocTable(settings *print.Settings) print.Engine {
|
|||||||
tt := template.New(settings, items...)
|
tt := template.New(settings, items...)
|
||||||
tt.CustomFunc(gotemplate.FuncMap{
|
tt.CustomFunc(gotemplate.FuncMap{
|
||||||
"type": func(t string) string {
|
"type": func(t string) string {
|
||||||
inputType, _ := printFencedCodeBlock(t, "")
|
inputType, _ := PrintFencedCodeBlock(t, "")
|
||||||
return inputType
|
return inputType
|
||||||
},
|
},
|
||||||
"value": func(v string) string {
|
"value": func(v string) string {
|
||||||
var result = "n/a"
|
var result = "n/a"
|
||||||
if v != "" {
|
if v != "" {
|
||||||
result, _ = printFencedCodeBlock(v, "")
|
result, _ = PrintFencedCodeBlock(v, "")
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
},
|
},
|
||||||
47
format/doc.go
Normal file
47
format/doc.go
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2021 The terraform-docs Authors.
|
||||||
|
|
||||||
|
Licensed under the MIT license (the "License"); you may not
|
||||||
|
use this file except in compliance with the License.
|
||||||
|
|
||||||
|
You may obtain a copy of the License at the LICENSE file in
|
||||||
|
the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Package format provides different, out of the box supported, output formats.
|
||||||
|
//
|
||||||
|
// Usage
|
||||||
|
//
|
||||||
|
// A specific format can be instantiated either for `format.Factory()` function or
|
||||||
|
// directly calling its function (e.g. `NewMarkdownTable`, etc)
|
||||||
|
//
|
||||||
|
// formatter, err := format.Factory("markdown table", settings)
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// generator, err := formatter.Generate(tfmodule)
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// output, err := generator.ExecuteTemplate("")
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Supported formats are:
|
||||||
|
//
|
||||||
|
// • `NewAsciidocDocument`
|
||||||
|
// • `NewAsciidocTable`
|
||||||
|
// • `NewJSON`
|
||||||
|
// • `NewMarkdownDocument`
|
||||||
|
// • `NewMarkdownTable`
|
||||||
|
// • `NewPretty`
|
||||||
|
// • `NewTfvarsHCL`
|
||||||
|
// • `NewTfvarsJSON`
|
||||||
|
// • `NewTOML`
|
||||||
|
// • `NewXML`
|
||||||
|
// • `NewYAML`
|
||||||
|
//
|
||||||
|
package format
|
||||||
@@ -35,7 +35,7 @@ func NewMarkdownDocument(settings *print.Settings) print.Engine {
|
|||||||
tt := template.New(settings, items...)
|
tt := template.New(settings, items...)
|
||||||
tt.CustomFunc(gotemplate.FuncMap{
|
tt.CustomFunc(gotemplate.FuncMap{
|
||||||
"type": func(t string) string {
|
"type": func(t string) string {
|
||||||
result, extraline := printFencedCodeBlock(t, "hcl")
|
result, extraline := PrintFencedCodeBlock(t, "hcl")
|
||||||
if !extraline {
|
if !extraline {
|
||||||
result += "\n"
|
result += "\n"
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ func NewMarkdownDocument(settings *print.Settings) print.Engine {
|
|||||||
if v == "n/a" {
|
if v == "n/a" {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
result, extraline := printFencedCodeBlock(v, "json")
|
result, extraline := PrintFencedCodeBlock(v, "json")
|
||||||
if !extraline {
|
if !extraline {
|
||||||
result += "\n"
|
result += "\n"
|
||||||
}
|
}
|
||||||
@@ -35,13 +35,13 @@ func NewMarkdownTable(settings *print.Settings) print.Engine {
|
|||||||
tt := template.New(settings, items...)
|
tt := template.New(settings, items...)
|
||||||
tt.CustomFunc(gotemplate.FuncMap{
|
tt.CustomFunc(gotemplate.FuncMap{
|
||||||
"type": func(t string) string {
|
"type": func(t string) string {
|
||||||
inputType, _ := printFencedCodeBlock(t, "")
|
inputType, _ := PrintFencedCodeBlock(t, "")
|
||||||
return inputType
|
return inputType
|
||||||
},
|
},
|
||||||
"value": func(v string) string {
|
"value": func(v string) string {
|
||||||
var result = "n/a"
|
var result = "n/a"
|
||||||
if v != "" {
|
if v != "" {
|
||||||
result, _ = printFencedCodeBlock(v, "")
|
result, _ = PrintFencedCodeBlock(v, "")
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
},
|
},
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user