example

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package example provides extraction of code examples from documentation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeBlock

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

CodeBlock represents a code block extracted from documentation.

func NewCodeBlock

func NewCodeBlock(content, language string, lineStart, lineEnd int, context string) CodeBlock

NewCodeBlock creates a new CodeBlock.

func (CodeBlock) Content

func (b CodeBlock) Content() string

Content returns the code content.

func (CodeBlock) Context

func (b CodeBlock) Context() string

Context returns the surrounding context (heading or paragraph).

func (CodeBlock) HasContext

func (b CodeBlock) HasContext() bool

HasContext returns true if context is available.

func (CodeBlock) HasLanguage

func (b CodeBlock) HasLanguage() bool

HasLanguage returns true if a language is specified.

func (CodeBlock) Language

func (b CodeBlock) Language() string

Language returns the programming language.

func (CodeBlock) LineEnd

func (b CodeBlock) LineEnd() int

LineEnd returns the ending line number.

func (CodeBlock) LineStart

func (b CodeBlock) LineStart() int

LineStart returns the starting line number.

type Discovery

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

Discovery detects example files in repositories.

func NewDiscovery

func NewDiscovery() *Discovery

NewDiscovery creates a new Discovery service.

func (*Discovery) IsDocumentationFile

func (d *Discovery) IsDocumentationFile(filePath string) bool

IsDocumentationFile checks if file is a documentation file.

func (*Discovery) IsExampleCandidate

func (d *Discovery) IsExampleCandidate(filePath string) bool

IsExampleCandidate checks if file should be processed for examples.

func (*Discovery) IsExampleDirectoryFile

func (d *Discovery) IsExampleDirectoryFile(filePath string) bool

IsExampleDirectoryFile checks if file is in an example directory.

type MarkdownParser

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

MarkdownParser parses Markdown documentation.

func NewMarkdownParser

func NewMarkdownParser() *MarkdownParser

NewMarkdownParser creates a new MarkdownParser.

func (*MarkdownParser) Parse

func (p *MarkdownParser) Parse(content string) []CodeBlock

Parse extracts code blocks from Markdown content.

type Parser

type Parser interface {
	Parse(content string) []CodeBlock
}

Parser extracts code blocks from documentation content.

func ParserForExtension

func ParserForExtension(extension string) Parser

ParserForExtension returns the appropriate parser for a file extension.

func ParserForFile

func ParserForFile(filePath string) Parser

ParserForFile returns the appropriate parser for a file path.

type RstParser

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

RstParser parses reStructuredText documentation.

func NewRstParser

func NewRstParser() *RstParser

NewRstParser creates a new RstParser.

func (*RstParser) Parse

func (p *RstParser) Parse(content string) []CodeBlock

Parse extracts code blocks from RST content.

Jump to

Keyboard shortcuts

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