examples

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package examples renders the runnable query examples in examples.yaml into a Markdown doc's marked example blocks (connectors.md), and is the basis for verifying (examples-check) and running (examples-test) those queries. examples.yaml is the single source of truth; the blocks between <!-- BEGIN/END EXAMPLES <name> --> markers are generated from it. See tools/examples for the CLI that drives this package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(readme string, f File) (string, error)

Apply replaces each group's marker region in the doc with its rendered block and returns the updated doc. It errors if a group's markers are missing, so a renamed/typo'd marker fails loudly instead of silently dropping examples.

func RenderBlock

func RenderBlock(g Group) string

RenderBlock renders a group's fenced ```sh example block (without the markers).

Types

type Example

type Example struct {
	Desc  string `yaml:"desc"`
	Query string `yaml:"query"`
	// Run is whether examples-test should execute this query; nil means true.
	// Set false for queries that can't run as-is (e.g. a placeholder value).
	Run *bool `yaml:"run"`
}

Example is one documented query.

func (Example) Runnable

func (e Example) Runnable() bool

Runnable reports whether examples-test should execute this example.

type File

type File struct {
	Groups []Group `yaml:"groups"`
}

File is the parsed examples.yaml.

func Load

func Load(path string) (File, error)

Load reads and parses examples.yaml.

type Group

type Group struct {
	Name string `yaml:"name"`
	// Requires names a prerequisite for running the group's queries in
	// examples-test ("jaeger" → a reachable local Jaeger); empty means none.
	Requires string    `yaml:"requires"`
	Examples []Example `yaml:"examples"`
}

Group is a set of examples that maps to one README marker region.

Jump to

Keyboard shortcuts

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