docs

package
v1.10.5 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 25 Imported by: 0

README

Docs

Core logic and TUI rendering for the interactive documentation browser.

Includes:

  • Interactive TUI doc viewer
  • Asynchronous documentation search
  • AI-powered Q&A integration

For detailed documentation on the TUI and search capabilities, see the Docs Component Documentation.

Documentation

Overview

Package docs provides a documentation system with two subsystems: a generation engine that parses Cobra command trees into Markdown files with hierarchy-aware index management, and a TUI browser built on Bubbles with split-pane navigation, async search, and AI-powered Q&A via retrieval-augmented generation (RAG).

Documentation is typically embedded in the binary via props.Assets under an assets/docs path, and the feature can be toggled via the DocsCmd feature flag.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AskAI

func AskAI(ctx context.Context, p *props.Props, fsys fs.FS, question string, logFn func(string, logger.Level), deltaFn func(string), providerOverride ...string) (string, error)

AskAI queries the AI about the embedded documentation. If the provider supports streaming, deltas are delivered via deltaFn as they arrive. logFn receives status messages. Either callback may be nil.

func GetAllMarkdownContent

func GetAllMarkdownContent(fsys fs.FS) (string, error)

GetAllMarkdownContent walks the FS and concatenates all .md files.

func ResolveProvider

func ResolveProvider(p *props.Props, providerOverride ...string) chat.Provider

ResolveProvider determines the AI provider to use based on override, config, and defaults.

func Serve

func Serve(ctx context.Context, fsys fs.FS, port int) error

Serve starts a documentation server on the given port serving the provided filesystem.

Types

type AskDeltaMsg added in v1.8.0

type AskDeltaMsg struct {
	Delta string
	Ch    <-chan string
}

AskDeltaMsg is a Bubble Tea message carrying a streamed text fragment from the AI.

type AskFunc

type AskFunc func(question string, logFn func(string, logger.Level), deltaFn func(string)) (string, error)

AskFunc is the callback signature for AI Q&A. logFn receives status messages; deltaFn receives streamed text fragments as they arrive (may be nil).

type AskLogMsg

type AskLogMsg struct {
	Log string
	Ch  <-chan string
}

AskLogMsg is a Bubble Tea message carrying a log line from the AI provider.

type AskResponse

type AskResponse struct {
	Answer string `json:"answer" jsonschema:"description=The comprehensive answer to the user's question based on the documentation provided."`
}

AskResponse is the structured response from an AI Q&A query.

type AskResultMsg

type AskResultMsg struct {
	Response string
	Err      error
}

AskResultMsg is a Bubble Tea message carrying the AI Q&A response.

type ListItem

type ListItem struct {
	Title    string
	Path     string
	IsGroup  bool
	Children []NavNode
}

ListItem represents a navigation entry in the documentation sidebar.

type LogFinishedMsg

type LogFinishedMsg struct{}

LogFinishedMsg is a Bubble Tea message signalling that AI log streaming is complete.

type MkDocsConfig

type MkDocsConfig struct {
	Nav []any `yaml:"nav"`
}

MkDocsConfig is the parsed structure of mkdocs.yml for navigation extraction.

type Model

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

Model is the Bubble Tea model for the interactive documentation browser. It manages navigation, content rendering, search, and AI Q&A.

func NewModel

func NewModel(fsys fs.FS, opts ...Option) *Model

NewModel creates a documentation browser Model backed by the given filesystem.

func (*Model) Init

func (m *Model) Init() tea.Cmd

func (*Model) Update

func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*Model) View

func (m *Model) View() string
type NavNode struct {
	Title    string
	Path     string
	Children []NavNode
}

NavNode represents a node in the documentation navigation tree.

type Option

type Option func(*Model)

Option is a functional option for configuring the documentation Model.

func WithAskFunc

func WithAskFunc(fn AskFunc) Option

WithAskFunc configures the AI Q&A callback for the documentation browser.

func WithTitle

func WithTitle(title string) Option

WithTitle sets the title displayed at the top of the documentation browser.

type SearchResult

type SearchResult struct {
	Title   string
	Path    string
	Excerpt string
}

SearchResult holds a single search match with context excerpt.

type SearchResultMessage

type SearchResultMessage struct {
	Results []SearchResult
	Query   string
}

SearchResultMessage is a Bubble Tea message carrying search results.

Jump to

Keyboard shortcuts

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