Documentation ¶
Index ¶
- Variables
- type CompareOutputOption
- type Document
- type DocumentRevision
- type InitOptions
- type Repository
- func (r *Repository) CompareDocumentRevisions(id, revHashFrom, revHashTo string, typ CompareOutputOption) (string, error)
- func (r *Repository) CreateDocument(id string, body string) (*Document, error)
- func (r *Repository) GetDocument(id string) (*Document, error)
- func (r *Repository) GetDocumentAtRevision(id string, revisionHash string) (*Document, error)
- func (r *Repository) GetDocumentIDs() ([]string, error)
- func (r *Repository) GetDocumentRevisions(id string) ([]DocumentRevision, error)
- func (r *Repository) UpdateDocument(id string, newBody string) (*Document, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrDocumentExists = errors.New("document already exists") ErrDocumentNotExists = errors.New("document not exists") ErrCreateDocument = errors.New("failed to create document") ErrGetDocument = errors.New("failed to open document") ErrInvalidOption = errors.New("invalid option") )
var ( ErrInitNotEmpty = errors.New("path to initialized not empty") ErrInitFailed = errors.New("failed to initialize repository") )
Functions ¶
This section is empty.
Types ¶
type CompareOutputOption ¶
type CompareOutputOption int8
CompareOutputOption is a type for options to select the style of diffs.
const ( // CompareOutputHTML is a option to present diffs as HTML string. CompareOutputHTML CompareOutputOption = iota // CompareOutputText is a option to present diffs as a colored string. // Recommended for terminal uses. CompareOutputText )
type Document ¶
type Document struct { ID string Body string Revision DocumentRevision }
type DocumentRevision ¶
type InitOptions ¶
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func Init ¶
func Init(opt *InitOptions) (*Repository, error)
func (*Repository) CompareDocumentRevisions ¶
func (r *Repository) CompareDocumentRevisions(id, revHashFrom, revHashTo string, typ CompareOutputOption) (string, error)
CompareDocumentRevisions show diffs of two revisions of the document.
func (*Repository) CreateDocument ¶
func (r *Repository) CreateDocument(id string, body string) (*Document, error)
CreateDocument makes new file in the repository. It returns ErrDocumentExists if given ID already exists.
func (*Repository) GetDocument ¶
func (r *Repository) GetDocument(id string) (*Document, error)
GetDocument returns latest revision of the document.
func (*Repository) GetDocumentAtRevision ¶
func (r *Repository) GetDocumentAtRevision(id string, revisionHash string) (*Document, error)
GetDocumentAtRevision returns specific revision of the document.
func (*Repository) GetDocumentIDs ¶
func (r *Repository) GetDocumentIDs() ([]string, error)
GetDocumentIDs returns list of id for all documents. TODO - Implement pagination
func (*Repository) GetDocumentRevisions ¶
func (r *Repository) GetDocumentRevisions(id string) ([]DocumentRevision, error)
GetDocumentRevisions returns all revisions of the document. TODO - Implement pagination
func (*Repository) UpdateDocument ¶
func (r *Repository) UpdateDocument(id string, newBody string) (*Document, error)
UpdateDocument update the body of existing document and create new revision. It returns ErrDocumentNotExists if given ID doesn't exist.