Documentation
¶
Overview ¶
Package docs carries the documentation in the binary, so a machine with no source checkout and no network has it: the `harnessly docs` and `harnessly app docs` commands read it for an agent, the runtime's /help page shows it to a person.
Index ¶
- Constants
- Variables
- func LocalDirs(getenv func(string) string, dataDir string) []string
- func Migration(id string) ([]byte, error)
- func PageName(file string) string
- func Read(guide fs.FS, locale, name string) ([]byte, bool, error)
- func Slug(s string) string
- func ValidID(s string) bool
- type Doc
- type Hit
- type Library
- type Page
- type Section
- type Source
Constants ¶
const ( AudiencePeople = "people" AudienceAgents = "agents" AudienceAll = "all" )
Audiences of a section: who it is written for. The page shows them all; an agent's list marks them.
const ( OriginBuiltin = "builtin" OriginLocal = "local" )
Origins of a section or a page.
const ( LocaleEN = "en" LocaleRU = "ru" )
Locales are the languages the guide is written in; English is the source and the fallback of any page.
const ManifestFile = "section.json"
ManifestFile is the file that makes a folder a section.
const MaxPicture = 8 << 20
MaxPicture is the largest picture a page may show.
const TeamSection = "team"
TeamSection is the id of the section made of the Markdown files in the root of a local folder.
Variables ¶
var Guide embed.FS
Guide holds the whole built-in library (library.go): the sections (each folder with a section.json: start, agents, inside, self-host, build-apps), the repository's own pages they list (*.md, hub/, migrations/), their pictures, the example packages of the apps guide, and the Russian translations under ru/ with the same file names. A page with no translation is read in English.
Functions ¶
func LocalDirs ¶ added in v0.16.154
LocalDirs are the machine's own documentation folders: HARNESSLY_DOCS_DIR (several separated like PATH), else <data>/docs. The first one is where `harnessly docs add` writes.
func Migration ¶
Migration is the page of a move of the machines' data (docs/migrations/<id>.md), as this version carries it: `hub doctor` and `harnessly migrate` show it with the version that moves.
func PageName ¶
PageName drops the folder, the reading-order number and the extension: build-apps/03-views.md is views.
func Read ¶
Read is the Markdown of the page called name in the locale; false when there is no such page. The name is matched against the listed pages, so nothing the caller sends reaches the file system.
Types ¶
type Doc ¶ added in v0.16.154
type Doc struct {
Name string `json:"name"`
Title string `json:"title"`
Headings []string `json:"headings"`
// File is the page's path in its source, the English one: links and pictures of the page are relative to it.
File string `json:"file"`
// Read is the file actually read: the translation (ru/...) when the locale has one, else File.
Read string `json:"read"`
Origin string `json:"origin"`
// contains filtered or unexported fields
}
Doc is a page of a section: its name in the section, the file it was read from and its outline.
func (Doc) Markdown ¶ added in v0.16.154
Markdown is the page's text in the locale it was loaded in.
func (Doc) Path ¶ added in v0.16.154
Path is where the page lies on disk, for a local page; empty for a built-in one.
type Hit ¶ added in v0.16.154
type Hit struct {
Section string `json:"section"`
Name string `json:"name"`
Title string `json:"title"`
// Heading is the heading the match is under, if any (its anchor is the page's to make).
Heading string `json:"heading"`
Snippet string `json:"snippet"`
// contains filtered or unexported fields
}
Hit is a page that matched a search, with the line that shows why.
type Library ¶ added in v0.16.154
type Library struct {
Sections []Section
}
Library is the sections in reading order.
func Load ¶ added in v0.16.154
Load reads the library in the locale. A broken local section (a bad section.json) is left out, not the library: the person's folder must never take the built-in documentation down with it.
func (Library) Find ¶ added in v0.16.154
Find is the page of a section; the names are matched against the library, so nothing a caller sends reaches a path.
type Page ¶
Page is a page of the guide: its name (on the command line, in the address of the page), its file in the embedded docs, its title and its headings.
type Section ¶ added in v0.16.154
type Section struct {
ID string `json:"id"`
Title string `json:"title"`
Audience string `json:"audience"`
Order int `json:"order"`
Origin string `json:"origin"`
Pages []Doc `json:"pages"`
// contains filtered or unexported fields
}
Section is a section of the library in one locale.
type Source ¶ added in v0.16.154
type Source struct {
Origin string
FS fs.FS
// Dir is the folder on disk of a local source (empty for the embedded one).
Dir string
}
Source is one place the documentation is read from: the embedded docs or a folder on the machine.