doltdocs

package
v0.40.4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReadmeFile  = "../README.md"
	LicenseFile = "../LICENSE.md"

	// LicenseDoc is the key for accessing the license within the docs table
	LicenseDoc = "LICENSE.md"
	// ReadmeDoc is the key for accessing the readme within the docs table
	ReadmeDoc = "README.md"
)

Variables

View Source
var DocsSchema = schema.MustSchemaFromCols(doltDocsColumns)
View Source
var ErrDocsUpdate = errors.New("error updating local docs")
View Source
var ErrEmptyDocsTable = errors.New("error: All docs removed. Removing Docs Table")
View Source
var ErrMarshallingSchema = errors.New("error marshalling schema")
View Source
var SupportedDocs = Docs{
	{DocPk: ReadmeDoc, File: ReadmeFile},
	{DocPk: LicenseDoc, File: LicenseFile},
}

Functions

func CreateOrUpdateDocsTable

func CreateOrUpdateDocsTable(ctx context.Context, root *doltdb.RootValue, docs Docs) (*doltdb.Table, error)

CreateOrUpdateDocsTable takes a root value and a set of docs and either creates the docs table or updates it with docs.

func DeleteDoc

func DeleteDoc(fs filesys.ReadWriteFS, docName string) error

DeleteDoc takes in a filesytem object and deletes the file with docName, if it's a SupportedDoc.

func DocFileExists

func DocFileExists(fs filesys.ReadWriteFS, file string) bool

func GetDocFilePath

func GetDocFilePath(filename string) string

GetDocFilePath takes in a filename and appends it to the DoltDir filepath.

func GetDocNamesFromDocs

func GetDocNamesFromDocs(docs Docs) []string

func GetLocalFileText

func GetLocalFileText(fs filesys.Filesys, file string) ([]byte, error)

GetLocalFileText returns a byte slice representing the contents of the provided file, if it exists

func UpdateRootWithDocs

func UpdateRootWithDocs(ctx context.Context, root *doltdb.RootValue, docs Docs) (*doltdb.RootValue, error)

UpdateRootWithDocs takes in a root value, and some docs and writes those docs to the dolt_docs table (perhaps creating it in the process). The table might not necessarily need to be created if there are no docs in the repo yet.

Types

type Doc

type Doc struct {
	Text  []byte
	DocPk string
	File  string
}

func GetDoc

func GetDoc(fs filesys.Filesys, docName string) (doc Doc, err error)

GetDoc takes in a filesystem and a docName and returns the doc's contents.

func IsSupportedDoc

func IsSupportedDoc(docName string) (Doc, bool)

type Docs

type Docs []Doc

func GetAllDocs

func GetAllDocs(ctx context.Context, root *doltdb.RootValue) (Docs, bool, error)

GetAllDocs takes a root value and returns all the docs available in the root.

func GetDocsFromRoot

func GetDocsFromRoot(ctx context.Context, root *doltdb.RootValue, docNames ...string) (Docs, error)

GetDocsFromRoot takes in a root value and returns the docs stored in its dolt_docs table.

func GetSupportedDocs

func GetSupportedDocs(fs filesys.Filesys) (docs Docs, err error)

GetSupportedDocs takes in a filesystem and returns the contents of all docs on disk.

func LoadDocs

func LoadDocs(fs filesys.ReadWriteFS) (Docs, error)

LoadDocs takes in a fs object and reads all the docs (ex. README.md) defined in SupportedDocs.

func (Docs) Save

func (docs Docs) Save(fs filesys.ReadWriteFS) error

Save takes in a fs object and saves all the docs to the filesystem, overwriting any existing files.

Jump to

Keyboard shortcuts

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