Movatterモバイル変換


[0]ホーム

URL:


format

package
v0.20.0Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2025 License:MITImports:19Imported by:1

Details

Repository

github.com/terraform-docs/terraform-docs

Links

Documentation

Overview

Package format provides different, out of the box supported, output format types.

Usage

A specific format can be instantiated either with `format.New()` function ordirectly calling its function (e.g. `NewMarkdownTable`, etc)

config := print.DefaultConfig()config.Formatter = "markdown table"formatter, err := format.New(config)if err != nil {    return err}err := formatter.Generate(tfmodule)if err != nil {    return err}output, err := formatter.Render"")if err != nil {    return err}

Note: if you don't intend to provide additional template for the generatedcontent, or the target format doesn't provide templating (e.g. json, yaml,xml, or toml) you can use `Content()` function instead of `Render)`. Notethat `Content()` returns all the sections combined with predefined order.

output := formatter.Content()

Supported formats are:

• `NewAsciidocDocument`• `NewAsciidocTable`• `NewJSON`• `NewMarkdownDocument`• `NewMarkdownTable`• `NewPretty`• `NewTfvarsHCL`• `NewTfvarsJSON`• `NewTOML`• `NewXML`• `NewYAML`

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcPrintFencedAsciidocCodeBlock

func PrintFencedAsciidocCodeBlock(codestring, languagestring) (string,bool)

PrintFencedAsciidocCodeBlock prints codes in fences, it automatically detects ifthe input 'code' contains '\n' it will use multi line fence, otherwise itwraps the 'code' inside single-tick block.If the fenced is multi-line it also appens an extra '\n` at the end andreturns true accordingly, otherwise returns false for non-carriage return.

funcPrintFencedCodeBlock

func PrintFencedCodeBlock(codestring, languagestring) (string,bool)

PrintFencedCodeBlock prints codes in fences, it automatically detects ifthe input 'code' contains '\n' it will use multi line fence, otherwise itwraps the 'code' inside single-tick block.If the fenced is multi-line it also appens an extra '\n` at the end andreturns true accordingly, otherwise returns false for non-carriage return.

Types

typeType

type Type interface {Generate(*terraform.Module)error// generate the Terraform moduleContent()string// all the sections combined based on the underlying formatHeader()string// header section based on the underlying formatFooter()string// footer section based on the underlying formatInputs()string// inputs section based on the underlying formatModules()string// modules section based on the underlying formatOutputs()string// outputs section based on the underlying formatProviders()string// providers section based on the underlying formatRequirements()string// requirements section based on the underlying formatResources()string// resources section based on the underlying formatRender(tmplstring) (string,error)}

Type represents an output format type (e.g. json, markdown table, yaml, etc).

funcNew

func New(config *print.Config) (Type,error)

New initializes and returns the concrete implementation offormat.Engine based on the provided 'name', for example for nameof 'json' it will return '*format.JSON' through 'format.NewJSON'function.

funcNewAsciidocDocument

func NewAsciidocDocument(config *print.Config)Type

NewAsciidocDocument returns new instance of Asciidoc Document.

funcNewAsciidocTable

func NewAsciidocTable(config *print.Config)Type

NewAsciidocTable returns new instance of Asciidoc Table.

funcNewJSON

func NewJSON(config *print.Config)Type

NewJSON returns new instance of JSON.

funcNewMarkdownDocument

func NewMarkdownDocument(config *print.Config)Type

NewMarkdownDocument returns new instance of Markdown Document.

funcNewMarkdownTable

func NewMarkdownTable(config *print.Config)Type

NewMarkdownTable returns new instance of Markdown Table.

funcNewPretty

func NewPretty(config *print.Config)Type

NewPretty returns new instance of Pretty.

funcNewTOML

func NewTOML(config *print.Config)Type

NewTOML returns new instance of TOML.

funcNewTfvarsHCL

func NewTfvarsHCL(config *print.Config)Type

NewTfvarsHCL returns new instance of TfvarsHCL.

funcNewTfvarsJSON

func NewTfvarsJSON(config *print.Config)Type

NewTfvarsJSON returns new instance of TfvarsJSON.

funcNewXML

func NewXML(config *print.Config)Type

NewXML returns new instance of XML.

funcNewYAML

func NewYAML(config *print.Config)Type

NewYAML returns new instance of YAML.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp