parsers

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractScenarioTitleFromAst

func ExtractScenarioTitleFromAst(node ast.Node, source []byte) (string, error)

Assumes the title of the scenario is the first h1 header in the markdown file.

func ExtractScenarioVariablesFromAst

func ExtractScenarioVariablesFromAst(node ast.Node, source []byte) map[string]string

Extracts the variables from a provided markdown AST.

func ExtractYamlMetadataFromAst added in v0.1.2

func ExtractYamlMetadataFromAst(node ast.Node) map[string]interface{}

Extract the metadata from the AST of a markdown document.

func ParseINIFile

func ParseINIFile(filePath string) (map[string]string, error)

Parses an INI file into a flat map of keys mapped to values. This reduces the complexity of the INI file to a simple key/value store and ignores the sections.

func ParseMarkdownIntoAst

func ParseMarkdownIntoAst(source []byte) ast.Node

Parses a markdown file into an AST representing the markdown document.

Types

type CodeBlock

type CodeBlock struct {
	Language       string              `json:"language"`
	Content        string              `json:"content"`
	Header         string              `json:"header"`
	Description    string              `json:"description"`
	ExpectedOutput ExpectedOutputBlock `json:"resultBlock"`
}

The representation of a code block in a markdown file.

func ExtractCodeBlocksFromAst

func ExtractCodeBlocksFromAst(
	node ast.Node,
	source []byte,
	languagesToExtract []string,
) []CodeBlock

Extracts the code blocks from a provided markdown AST that match the languagesToExtract.

type ExpectedOutputBlock

type ExpectedOutputBlock struct {
	Language           string         `json:"language"`
	Content            string         `json:"content"`
	ExpectedSimilarity float64        `json:"expectedSimilarityScore"`
	ExpectedRegex      *regexp.Regexp `json:"expectedRegexPattern"`
}

The representation of an expected output block in a markdown file. This is for scenarios that have expected output that should be validated against the actual output.

Jump to

Keyboard shortcuts

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