store

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoMatch = errors.New("no match for the path")

Functions

This section is empty.

Types

type Node

type Node struct {
	Category  string // The category (name) of the node, for directories and single pages, categories are empty
	Path      string // The URL path
	LocalPath string // Full path with .md extension

	Content  []byte            // The content of the node
	Title    string            // The title of the document in the given language
	Headings goldmarktoc.Items // Headings in the node

	Nodes    []*Node   // The list of sub-nodes
	Previous *PageLink // The previous page
	Next     *PageLink // The next page
}

Node is a node in the documentation hierarchy.

func (*Node) Reload

func (n *Node) Reload(baseURLPath string) error

Reload reloads and converts the content from local disk.

type PageLink struct {
	Title string // The title of the page
	Path  string // the path to the page
}

PageLink is a link to another page.

type Store

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

Store is a store maintaining documentation hierarchies for multiple languages.

func Init

func Init(typ conf.DocType, target, targetDir string, languages []string, baseURLPath string) (*Store, error)

Init initializes the documentation store from given type and target.

func (*Store) FirstDocPath

func (s *Store) FirstDocPath() string

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

func (*Store) Match

func (s *Store) Match(language, path string) (n *Node, fallback bool, err error)

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

func (*Store) Reload

func (s *Store) Reload() error

Reload re-initializes the documentation store.

func (*Store) RootDir

func (s *Store) RootDir() string

RootDir returns the root directory of documentation hierarchies.

func (*Store) TOC

func (s *Store) TOC(language string) *TOC

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

type TOC

type TOC struct {
	Language string  // The language of the documentation
	Nodes    []*Node // Directories of the documentation
	Pages    []*Node // Individuals pages of the documentation
	// contains filtered or unexported fields
}

TOC represents documentation hierarchy for a specific language.

Jump to

Keyboard shortcuts

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