navigadoc

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: MIT Imports: 10 Imported by: 0

README

NavigaDoc Format

The purpose of this package is to define the NavigaDoc format as a Go struct and as a protobuf message, and provide functionality for commonly used operations for this format.

Converter Functions

The navigadoc package has the following components

  • Package github.com/navigacontentlab/navigadoc

    * contains utility functions for the NavigaDoc format
    
  • Package github.com/navigacontentlab/navigadoc/doc

    * contains the golang definition of NavigaDoc
    

Generate /doc and /rpc

  • ./generate.sh

TODO

  • upgrade to go 1.18 (when linters have caught up)
  • add more utility functions
  • specify other formats related to NavigaDoc and Block
  • go through example/test data and filter out what is not being used

Documentation

Overview

Package navigadoc provides utility functions to the Naviga Doc format

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyBlock        = &MalformedDocumentError{"empty block"}
	ErrEmptyDoc          = &MalformedDocumentError{"empty document"}
	ErrEmptyConcept      = &MalformedDocumentError{"empty concept"}
	ErrEmptyNewsItem     = &MalformedDocumentError{"empty newsitem"}
	ErrEmptyAssignment   = &MalformedDocumentError{"empty assignment"}
	ErrEmptyList         = &MalformedDocumentError{"empty list"}
	ErrEmptyPlanningItem = &MalformedDocumentError{"empty planningitem"}
	ErrEmptyPackage      = &MalformedDocumentError{"empty list package"}
	ErrUnsupportedType   = &MalformedDocumentError{"unsuported type"}
)
View Source
var NavigaDocSchema string

NavigaDocSchema embedded schemas

Functions

func CheckForEmptyBlocks

func CheckForEmptyBlocks(document *doc.Document) error

func CheckForEmptyBlocksRecursive

func CheckForEmptyBlocksRecursive(block doc.Block, kind string, idx int, path []string) error
func DeDuplicateLinks(links []doc.Block, linksToDeDuplicate []doc.Block) []doc.Block

func DeleteBlocks

func DeleteBlocks(document doc.Document, blocksToDelete []doc.Block) *doc.Document

func FilterBlocks

func FilterBlocks(blocks []doc.Block, filter func(a doc.Block) bool) []doc.Block

func GetBlocks

func GetBlocks(document doc.Document, patterns []doc.Block) []doc.Block

func GetBlocksToKeep

func GetBlocksToKeep(blocks []doc.Block, patterns []doc.Block) []doc.Block

returns block NOT matching the pattern

func MergeProperties

func MergeProperties(existingProperties []doc.Property, newProperties []doc.Property) []doc.Property

func ReplaceBlocks

func ReplaceBlocks(document doc.Document, blocksToReplace []BlockReplacement) *doc.Document

func ValidateAndLowercaseDocumentUUIDs deprecated

func ValidateAndLowercaseDocumentUUIDs(block doc.Block, args ...interface{}) (doc.Block, error)

Deprecated: UUID handling in OpenContent to be case-insensitive ValidateAndLowercaseDocumentUUIDs Walks each document block to validate and lowercase convert UUIDs

func ValidateDocumentUUIDs

func ValidateDocumentUUIDs(block doc.Block, args ...interface{}) (doc.Block, error)

ValidateDocumentUUIDs Walks each document block to validate and lowercase convert UUIDs

func ValidateNavigadocJSON

func ValidateNavigadocJSON(document string) ([]error, error)

ValidateNavigadocJSON validates the Navigadoc against a JSON Schema The error array contains schema issues A non-nil error indicates an error with the validator

func ValidateUUID added in v0.1.1

func ValidateUUID(theUUID string) error

func WalkBlock

func WalkBlock(block doc.Block, args []interface{}, fns ...BlockVisitor) (doc.Block, error)

WalkBlock For each block in the document call the BlockVisitor functions provided

func WalkBlocks

func WalkBlocks(s []doc.Block, args []interface{}, fns ...BlockVisitor) error

WalkBlocks For each Block in the array call the BlockVisitor functions

func WalkDocument

func WalkDocument(document *doc.Document, args []interface{}, fns ...BlockVisitor) error

WalkDocument For each Block in the Document call the BlockVisitor functions

Types

type BlockReplacement

type BlockReplacement interface {
	GetOldBlock() doc.Block
	GetNewBlock() doc.Block
}

type BlockSorter

type BlockSorter struct {
	Blocks         []doc.Block
	BlockSortOrder map[string]int
}

func NewBlockSorter

func NewBlockSorter(blockSortOrder map[string]int) BlockSorter

func (BlockSorter) Len

func (b BlockSorter) Len() int

func (BlockSorter) Less

func (b BlockSorter) Less(i, j int) bool

func (*BlockSorter) SortBlocks

func (b *BlockSorter) SortBlocks(blocks []doc.Block) []doc.Block

func (BlockSorter) Swap

func (b BlockSorter) Swap(i, j int)

type BlockVisitor

type BlockVisitor func(block doc.Block, args ...interface{}) (doc.Block, error)

type InvalidArgumentError

type InvalidArgumentError struct {
	Msg string
	Err error
}

func (InvalidArgumentError) Error

func (e InvalidArgumentError) Error() string

func (InvalidArgumentError) Is

func (e InvalidArgumentError) Is(target error) bool

func (InvalidArgumentError) Unwrap

func (e InvalidArgumentError) Unwrap() error

type MalformedDocumentError

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

func (*MalformedDocumentError) Error

func (e *MalformedDocumentError) Error() string

type RequiredArgumentError

type RequiredArgumentError struct {
	Msg string
	Err error
}

func (RequiredArgumentError) Error

func (e RequiredArgumentError) Error() string

func (RequiredArgumentError) Is

func (e RequiredArgumentError) Is(target error) bool

func (RequiredArgumentError) Unwrap

func (e RequiredArgumentError) Unwrap() error

Directories

Path Synopsis
cmd
Code generated by doc-generator.
Code generated by doc-generator.
Code generated by doc-generator.
Code generated by doc-generator.

Jump to

Keyboard shortcuts

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