Documentation
¶
Index ¶
- type ActionRenderOption
- type ActionWithRenderOption
- type DataSourceRenderOption
- type DataSourceWithRenderOption
- type EphemeralResourceRenderOption
- type EphemeralResourceWithRenderOption
- type Example
- type FunctionRenderOption
- type FunctionWithRenderOption
- type Generator
- func (gen Generator) RenderAction(ctx context.Context, w io.Writer, actionType string, ...) error
- func (gen Generator) RenderDataSource(ctx context.Context, w io.Writer, dataSourceType string, ...) error
- func (gen Generator) RenderEphemeralResource(ctx context.Context, w io.Writer, ephemeralResourceType string, ...) error
- func (gen Generator) RenderFunction(ctx context.Context, w io.Writer, functionName string, ...) error
- func (gen Generator) RenderListResource(ctx context.Context, w io.Writer, listResourceType string, ...) error
- func (gen Generator) RenderProvider(ctx context.Context, w io.Writer, option *ProviderRenderOption) error
- func (gen Generator) RenderResource(ctx context.Context, w io.Writer, resourceType string, ...) error
- func (gen Generator) WriteAll(ctx context.Context, docDir string, opts *RenderOptions) error
- type ImportId
- type ListResourceRenderOption
- type ListResourceWithRenderOption
- type ProviderRenderOption
- type ProviderWithRenderOption
- type RenderOptions
- type ResourceRenderOption
- type ResourceWithRenderOption
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionRenderOption ¶
type ActionRenderOption = metadata.ActionRenderOption
type ActionWithRenderOption ¶
type ActionWithRenderOption interface {
action.Action
RenderOption() ActionRenderOption
}
type DataSourceRenderOption ¶
type DataSourceRenderOption = metadata.DataSourceRenderOption
type DataSourceWithRenderOption ¶
type DataSourceWithRenderOption interface {
datasource.DataSource
RenderOption() DataSourceRenderOption
}
type EphemeralResourceRenderOption ¶
type EphemeralResourceRenderOption = metadata.EphemeralRenderOption
type EphemeralResourceWithRenderOption ¶
type EphemeralResourceWithRenderOption interface {
ephemeral.EphemeralResource
RenderOption() EphemeralResourceRenderOption
}
type FunctionRenderOption ¶
type FunctionRenderOption = metadata.FunctionRenderOption
type FunctionWithRenderOption ¶
type FunctionWithRenderOption interface {
function.Function
RenderOption() FunctionRenderOption
}
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
func NewGenerator ¶
Create a Generator by analyzing the schema of the provider and all the registered resources to the provider.
func (Generator) RenderAction ¶
func (gen Generator) RenderAction(ctx context.Context, w io.Writer, actionType string, option *ActionRenderOption) error
RenderAction renders the action document. If option is specified, it will override the ActionWithRenderOption.RenderOption() if is implemented.
func (Generator) RenderDataSource ¶
func (gen Generator) RenderDataSource(ctx context.Context, w io.Writer, dataSourceType string, option *DataSourceRenderOption) error
RenderDataSource renders the data source document. If option is specified, it will override the DataSourceWithRenderOption.RenderOption() if is implemented.
func (Generator) RenderEphemeralResource ¶
func (gen Generator) RenderEphemeralResource(ctx context.Context, w io.Writer, ephemeralResourceType string, option *EphemeralResourceRenderOption) error
RenderEphemeralResource renders the ephemeral resource document. If option is specified, it will override the EphemeralResourceWithRenderOption.RenderOption() if is implemented.
func (Generator) RenderFunction ¶
func (gen Generator) RenderFunction(ctx context.Context, w io.Writer, functionName string, option *FunctionRenderOption) error
RenderFunction renders the function document. If option is specified, it will override the FunctionWithRenderOption.RenderOption() if is implemented.
func (Generator) RenderListResource ¶
func (gen Generator) RenderListResource(ctx context.Context, w io.Writer, listResourceType string, option *ListResourceRenderOption) error
RenderListResource renders the list resource document. If option is specified, it will override the ListResourceWithRenderOption.RenderOption() if is implemented.
func (Generator) RenderProvider ¶
func (gen Generator) RenderProvider(ctx context.Context, w io.Writer, option *ProviderRenderOption) error
RenderProvider renders the provider document. If option is specified, it will override the ProviderWithRenderOption.RenderOption() if is implemented.
func (Generator) RenderResource ¶
func (gen Generator) RenderResource(ctx context.Context, w io.Writer, resourceType string, option *ResourceRenderOption) error
RenderResource renders the resource document. If option is specified, it will override the ResourceWithRenderOption.RenderOption() if is implemented.
func (Generator) WriteAll ¶
WriteAll generates the documents for the provider and all registered resources, actions, functions, etc. and write to the specified document directory, which should be existing.
Example ¶
package main
import (
"context"
"log"
tffwdocs "github.com/magodo/terraform-plugin-framework-docs"
"github.com/magodo/terraform-plugin-framework-docs/internal/metadata"
"github.com/magodo/terraform-plugin-framework-docs/internal/testprovider"
)
func main() {
ctx := context.Background()
gen, err := tffwdocs.NewGenerator(ctx, &testprovider.ExampleCloudProvider{})
if err != nil {
log.Fatal(err)
}
if err := gen.WriteAll(ctx, "./internal/testprovider/docs", &tffwdocs.RenderOptions{
Provider: &metadata.ProviderRenderOption{
Examples: []tffwdocs.Example{
{
Header: "Basic",
Description: "The basic configuration.",
HCL: `
provider "examplecloud" {
name = "foo"
}
`,
},
{
Header: "Complete",
Description: "The complete configuration.",
HCL: `
provider "examplecloud" {
name = "foo"
address = "bar"
age = 123
role = "Software Engineer"
}
`,
},
},
},
Resources: map[string]tffwdocs.ResourceRenderOption{
"examplecloud_resource": metadata.ResourceRenderOption{
Subcategory: "abc",
Examples: []tffwdocs.Example{
{
Header: "Basic",
Description: "The basic configuration.",
HCL: `
resource "examplecloud_resource" "example" {
name = "foo"
}
`,
},
{
Header: "Complete",
Description: "The complete configuration.",
HCL: `
resource "examplecloud_resource" "example" {
name = "foo"
address = "bar"
age = 123
role = "Software Engineer"
}
`,
},
},
ImportId: &tffwdocs.ImportId{
Format: "<parent_id>/<id>[/<version>]",
ExampleId: "123/456",
ExampleBlk: `
import {
to = examplecloud_resource.example
id = "123/456"
}
`,
},
IdentityExamples: []tffwdocs.Example{
{
Header: "Without Version",
Description: "Import without version.",
HCL: `
import {
to = examplecloud_resource.example
identity = {
parent_id = "123"
id = "456"
}
}
`,
},
{
Header: "With Version",
Description: "Import with version.",
HCL: `
import {
to = examplecloud_resource.example
identity = {
parent_id = "123"
id = "456"
version = "v2"
}
}
`,
},
},
},
},
}); err != nil {
log.Fatal(err)
}
}
Output:
type ListResourceRenderOption ¶
type ListResourceRenderOption = metadata.ListRenderOption
type ListResourceWithRenderOption ¶
type ListResourceWithRenderOption interface {
list.ListResource
RenderOption() ListResourceRenderOption
}
type ProviderRenderOption ¶
type ProviderRenderOption = metadata.ProviderRenderOption
type ProviderWithRenderOption ¶
type ProviderWithRenderOption interface {
provider.Provider
RenderOption() ProviderRenderOption
}
type RenderOptions ¶
type RenderOptions struct {
Provider *ProviderRenderOption
Resources map[string]ResourceRenderOption
DataSources map[string]DataSourceRenderOption
EphemeralResources map[string]EphemeralResourceRenderOption
ListResources map[string]ListResourceRenderOption
Actions map[string]ActionRenderOption
Functions map[string]FunctionRenderOption
}
type ResourceRenderOption ¶
type ResourceRenderOption = metadata.ResourceRenderOption
type ResourceWithRenderOption ¶
type ResourceWithRenderOption interface {
resource.Resource
RenderOption() ResourceRenderOption
}