doc

package
v0.0.0-...-4cedf94 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoMatch = errors.New("no match for the path")
View Source
var (
	ErrNoTitleFound = errors.New("no title found in markdown")
)

Functions

This section is empty.

Types

type Doc

type Doc struct {
	Category  string
	UrlPath   string // the URL path
	LocalPath string // local path with .md extension

	Weight         int    // in md front matter, used to sort docs
	Title          string // in md front matter, used to sort docs, render TOC and so on
	HideExtraTitle bool   // when there is no title in the front matter, we get title in content and not add extra title
	Content        []byte
	Headings       toc.Items // if Title is empty, use Headings[0].Title

	Groups   []*Doc
	Pages    []*Doc
	Previous *PageLink
	Next     *PageLink
}

Doc is a node in the documentation hierarchy.

type Manager

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

Manager is a store maintaining documentation hierarchies for multiple languages.

func New

func New(cfg *model.Config) (*Manager, error)

New initializes the documentation store from given config.

func (*Manager) Doc

func (s *Manager) Doc(language string) *Doc

Doc returns the Doc of the given language. It returns the Doc of the default language if the given language is not found.

func (*Manager) FirstDocPath

func (s *Manager) FirstDocPath() string

FirstDocPath returns the URL path of the first doc that has content in the default language.

func (*Manager) Match

func (s *Manager) Match(language, path string) (d *Doc, fallback bool, err error)

Match matches a node with given path in given language. If there is no such node exists or the node content is empty, it falls back to use the node with the same path in default language.

func (*Manager) Reload

func (s *Manager) Reload() error

Reload re-initializes the documentation store.

type PageLink struct {
	Title   string
	UrlPath string
}

PageLink is a link to another page.

Jump to

Keyboard shortcuts

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