docs

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package docs provides version-aware Markdown retrieval for Atlas tools.

Index

Constants

View Source
const DefaultRef = "main"

DefaultRef is the docs branch Atlas tracks when no explicit ref is configured.

View Source
const DefaultRepo = "https://github.com/goforj/docs.git"

DefaultRepo is the canonical GoForj docs repository Atlas reads from.

View Source
const EnvCacheDir = "GOFORJ_ATLAS_DOCS_CACHE"

EnvCacheDir overrides the local cache used for cloned docs.

View Source
const EnvPath = "GOFORJ_DOCS_PATH"

EnvPath is the development override for live GoForj docs.

View Source
const EnvRef = "GOFORJ_ATLAS_DOCS_REF"

EnvRef selects the branch, tag, or revision used for cached docs.

View Source
const EnvRepo = "GOFORJ_ATLAS_DOCS_REPO"

EnvRepo overrides the hosted docs repository used for cached docs.

Variables

This section is empty.

Functions

This section is empty.

Types

type CachingProvider added in v0.1.1

type CachingProvider struct {
	Provider Provider
	// contains filtered or unexported fields
}

CachingProvider loads docs once and serves them from memory afterward.

func (*CachingProvider) Documents added in v0.1.1

func (p *CachingProvider) Documents(ctx context.Context) ([]Document, error)

Documents returns cached Markdown documents.

func (*CachingProvider) Manifest added in v0.1.1

func (p *CachingProvider) Manifest(ctx context.Context) (Manifest, error)

Manifest returns cached docs metadata.

type Document

type Document struct {
	Path    string            `json:"path"`
	Title   string            `json:"title"`
	Content string            `json:"content"`
	Tags    []string          `json:"tags,omitempty"`
	Meta    map[string]string `json:"meta,omitempty"`
}

Document is one Markdown document in a docs set.

type FSProvider

type FSProvider struct {
	Root     string
	Version  string
	Revision string
}

FSProvider loads Markdown docs from a filesystem directory.

func (FSProvider) Documents

func (p FSProvider) Documents(ctx context.Context) ([]Document, error)

Documents loads Markdown documents from the provider root.

func (FSProvider) Manifest

func (p FSProvider) Manifest(ctx context.Context) (Manifest, error)

Manifest returns a checksum-backed docs manifest.

type FallbackProvider added in v0.1.1

type FallbackProvider struct {
	Providers []Provider
}

FallbackProvider tries docs providers in order until one returns documents.

func (FallbackProvider) Documents added in v0.1.1

func (p FallbackProvider) Documents(ctx context.Context) ([]Document, error)

Documents returns documents from the first available provider.

func (FallbackProvider) Manifest added in v0.1.1

func (p FallbackProvider) Manifest(ctx context.Context) (Manifest, error)

Manifest returns metadata for the first provider that can return documents.

type GitProvider added in v0.1.1

type GitProvider struct {
	CacheDir string
	Repo     string
	Ref      string
	Version  string
	Refresh  bool
	// contains filtered or unexported fields
}

GitProvider loads GoForj docs from a local git cache.

func NewGitProvider added in v0.1.1

func NewGitProvider(version string) *GitProvider

NewGitProvider returns a git-backed docs provider with normal GoForj defaults.

func (*GitProvider) Documents added in v0.1.1

func (p *GitProvider) Documents(ctx context.Context) ([]Document, error)

Documents returns Markdown documents from the cached checkout.

func (*GitProvider) Manifest added in v0.1.1

func (p *GitProvider) Manifest(ctx context.Context) (Manifest, error)

Manifest returns docs metadata from the cached checkout.

type Manifest

type Manifest struct {
	Version       string `json:"version"`
	Revision      string `json:"revision"`
	Ref           string `json:"ref,omitempty"`
	Commit        string `json:"commit,omitempty"`
	GoForjVersion string `json:"goforj_version,omitempty"`
	GeneratedAt   string `json:"generated_at,omitempty"`
}

Manifest describes the docs set exposed by Atlas.

type Provider

type Provider interface {
	// Manifest returns version and revision information for the docs set.
	Manifest(context.Context) (Manifest, error)
	// Documents returns the Markdown documents available to Atlas.
	Documents(context.Context) ([]Document, error)
}

Provider supplies versioned documentation to Atlas.

func DefaultProvider added in v0.1.1

func DefaultProvider(version string) Provider

DefaultProvider returns Atlas docs using a local override or cached git docs.

func ProviderFromEnv

func ProviderFromEnv(version string) (Provider, bool)

ProviderFromEnv returns an FSProvider when GOFORJ_DOCS_PATH is set.

type SearchOptions

type SearchOptions struct {
	Query      string
	Limit      int
	TokenLimit int
}

SearchOptions controls docs search.

type SearchResult

type SearchResult struct {
	Path    string `json:"path"`
	Title   string `json:"title"`
	Heading string `json:"heading"`
	Snippet string `json:"snippet"`
	Score   int    `json:"score"`
}

SearchResult is one ranked docs search hit.

func ExplainAPI

func ExplainAPI(ctx context.Context, provider Provider, query string) ([]SearchResult, error)

ExplainAPI maps common GoForj commands and paths to docs sections.

func Search(ctx context.Context, provider Provider, opts SearchOptions) ([]SearchResult, error)

Search finds relevant docs sections.

type Section

type Section struct {
	Path    string `json:"path"`
	Title   string `json:"title"`
	Heading string `json:"heading"`
	Level   int    `json:"level"`
	Body    string `json:"body"`
}

Section is one Markdown heading section.

func HeadingTree

func HeadingTree(doc Document) []Section

HeadingTree returns the headings for a document.

func ListHeadings

func ListHeadings(ctx context.Context, provider Provider, path string) ([]Section, error)

ListHeadings returns the heading tree for path.

func ParseSections

func ParseSections(doc Document) []Section

ParseSections parses a Markdown document into heading sections.

func ParseSectionsWithoutTitle

func ParseSectionsWithoutTitle(doc Document) []Section

ParseSectionsWithoutTitle exists to avoid recursive title discovery.

func ReadNeighborhood

func ReadNeighborhood(ctx context.Context, provider Provider, path string, heading string, before int, after int, tokenLimit int) ([]Section, error)

ReadNeighborhood returns a section plus nearby heading sections.

func ReadSection

func ReadSection(ctx context.Context, provider Provider, path string, heading string, tokenLimit int) (Section, bool, error)

ReadSection returns one section matching path and heading.

type StaticProvider

type StaticProvider struct {
	Docs     []Document
	DocsMeta Manifest
}

StaticProvider is an in-memory docs provider for fixed or test docs.

func (StaticProvider) Documents

func (p StaticProvider) Documents(context.Context) ([]Document, error)

Documents returns the static docs documents.

func (StaticProvider) Manifest

func (p StaticProvider) Manifest(context.Context) (Manifest, error)

Manifest returns the static docs manifest.

Jump to

Keyboard shortcuts

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