docs

package
v0.0.1-testing Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 17 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package docs searches and reads the Re:Earth documentation through the site's llms-full.txt: every page of docs.reearth.io in one Markdown file.

Index

Constants

View Source
const DefaultSite = "https://docs.reearth.io"

DefaultSite is the documentation site. REEARTH_DOCS_URL overrides it.

Variables

View Source
var ErrNoPages = errors.New("llms-full.txt contains no pages")

ErrNoPages means that the site served an llms-full.txt with no pages in it, such as an empty body or an HTML error page.

View Source
var ErrNotFound = errors.New("no such page")

ErrNotFound is returned by Find when no page matches.

Functions

This section is empty.

Types

type AmbiguousError

type AmbiguousError struct {
	Ref string
	IDs []string
}

AmbiguousError is returned by Find when several pages share the title.

func (*AmbiguousError) Error

func (e *AmbiguousError) Error() string

type CacheError

type CacheError struct{ Err error }

CacheError is the warning Load returns when it could not save a fresh copy. The fresh pages are returned anyway.

func (*CacheError) Error

func (e *CacheError) Error() string

func (*CacheError) Unwrap

func (e *CacheError) Unwrap() error

type Match

type Match struct {
	ID      string `json:"id"`
	Title   string `json:"title"`
	URL     string `json:"url,omitempty"`
	Summary string `json:"summary"`
}

Match is one search result.

func Search(pages []Page, query string, limit int) []Match

Search ranks pages against a query with BM25F and returns at most limit matches, best first.

type Page

type Page struct {
	// ID names the page for `docs read`: the URL path when the file carries
	// page URLs, otherwise the title. When several pages would share an ID,
	// each of them is numbered. Numbers follow file order, so they can change
	// when pages are added to the site.
	ID          string `json:"id"`
	Title       string `json:"title"`
	URL         string `json:"url,omitempty"`
	Description string `json:"description"`
	Body        string `json:"-"`
}

Page is one page of the documentation.

func Find

func Find(pages []Page, ref string) (Page, error)

Find returns the page named by ref: an ID, a title, or a page URL or URL path. IDs are unique and never a shared title, so an ID always resolves; a title that several pages share is an *AmbiguousError listing their IDs. The ref is tried verbatim first, so titles with slashes or that look like URLs resolve too.

func Parse

func Parse(text string) []Page

Parse splits llms-full.txt into pages. The generator writes each page as

# Title

Source: https://docs.reearth.io/ja/cms/   (only on newer builds)

> Description

Body...

A heading followed by anything other than a description is a heading inside a page, not a new page. Text before the first page, such as the <SYSTEM> line, is dropped.

func (Page) Markdown

func (p Page) Markdown(site string) string

Markdown renders a page with its header. Site-relative links outside code (fenced, indented or inline) are made absolute against site so that they can be followed.

type Source

type Source struct {
	Site   string
	Dir    string
	Client *http.Client
	// MaxAge is how long a copy is used without asking the site for changes.
	MaxAge time.Duration
	Now    func() time.Time
}

Source downloads llms-full.txt and keeps a copy in a directory under Dir that is named after Site, so that switching sites never mixes their copies.

func (*Source) Load

func (s *Source) Load(ctx context.Context) (pages []Page, warn, err error)

Load returns at least one page, or an error. A fresh copy is used as is. An older one is revalidated with a conditional request; when the site cannot be reached, answers with an error status or serves no pages, the copy is used anyway and warn is a *StaleError. When a fresh download cannot be saved, warn is a *CacheError.

type StaleError

type StaleError struct{ Err error }

StaleError is the warning Load returns when it falls back to the cached copy because the site could not be used.

func (*StaleError) Error

func (e *StaleError) Error() string

func (*StaleError) Unwrap

func (e *StaleError) Unwrap() error

type StatusError

type StatusError struct {
	URL    string
	Status string
}

StatusError is a response other than 200 or 304.

func (*StatusError) Error

func (e *StatusError) Error() string

Jump to

Keyboard shortcuts

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