frontmatter

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

package frontmatter includes types and functions that provide resource plan modifiers for using Markdown front matter for attribute values. Front matter is an alternative way to specify parameters for changelogs, custom pages, and docs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBool

func GetBool(fieldName string) planmodifier.Bool

GetBool is a plan modifier function for use on a schema bool attribute to set a value from front matter.

func GetInt64

func GetInt64(fieldName string) planmodifier.Int64

GetInt64 is a plan modifier function for use on a schema int64 attribute to set a value from front matter.

func GetString

func GetString(fieldName string) planmodifier.String

GetString is a plan modifier function for use on a schema string attribute to set a value from front matter.

func GetValue

func GetValue(ctx context.Context, body, attribute string) (reflect.Value, string)

GetValue parses the 'body' attribute value for Markdown front matter and returns a specified key's value if it's present in the front matter.

The `attribute` parameter is the struct field name representing the YAML front matter key.

This returns a `reflect.Value` to be evaluated as needed based on the type and other conditions.

A string value is provided in place of an error for use with the plugin framework's diagnostics package.

Types

type FrontMatterModifier

type FrontMatterModifier struct {
	// contains filtered or unexported fields
}

FrontMatterModifier provides plan modifiers that parses Markdown front matter for attribute values.

func (FrontMatterModifier) Description

func (m FrontMatterModifier) Description(ctx context.Context) string

Description returns a plain text description of the modifier's behavior.

func (FrontMatterModifier) MarkdownDescription

func (m FrontMatterModifier) MarkdownDescription(ctx context.Context) string

MarkdownDescription returns a markdown formatted description of the modifier's behavior.

func (FrontMatterModifier) PlanModifyBool

PlanModifyBool sets a bool attribute's value from the body Markdown front matter if the attribute is not set and a matching attribute is set in front matter.

func (FrontMatterModifier) PlanModifyInt64

PlanModifyInt64 sets an int64 attribute's value from the body Markdown front matter if the attribute is not set and a matching attribute is set in front matter.

func (FrontMatterModifier) PlanModifyString

PlanModifyString sets a string attribute's value from the body Markdown front matter if the attribute is not set and a matching attribute is set in front matter.

type ReadmeFrontMatter

type ReadmeFrontMatter struct {
	Body          string                `yaml:"body,omitempty"`          // changelogs, custom pages, docs
	Category      string                `yaml:"category,omitempty"`      // docs
	CategorySlug  string                `yaml:"categorySlug,omitempty"`  // docs
	Error         readme.DocErrorObject `yaml:"error,omitempty"`         // docs
	Hidden        *bool                 `yaml:"hidden"`                  // changelogs, custom pages, docs
	HTML          string                `yaml:"html,omitempty"`          // custom page
	HTMLMode      *bool                 `yaml:"htmlmode"`                // custom page
	Order         int64                 `yaml:"order,omitempty"`         // docs
	ParentDoc     string                `yaml:"parentDoc,omitempty"`     // docs
	ParentDocSlug string                `yaml:"parentDocSlug,omitempty"` // docs
	Slug          string                `yaml:"slug,omitempty"`          // docs
	Title         string                `yaml:"title,omitempty"`         // changelogs, custom pages, docs
	Type          string                `yaml:"type,omitempty"`          // changelogs, docs
}

ReadmeFrontMatter represents the front matter keys available to ReadMe changelogs, custom pages, and docs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL