Skip to content

data.doctree.collection #

fn new #

fn new(args_ CollectionNewArgs) !Collection

get a new collection

enum CollectionErrorCat #

enum CollectionErrorCat {
	unknown
	image_double
	file_double
	file_not_found
	image_not_found
	page_double
	page_not_found
	sidebar
	circular_import
	def
	summary
	include
}

struct Collection #

@[heap]
struct Collection {
pub mut:
	name          string @[required]
	path          Path   @[required]
	fail_on_error bool
	heal          bool = true
	pages         map[string]&data.Page
	files         map[string]&data.File
	images        map[string]&data.File
	errors        []CollectionError
}

fn (Collection) add_file #

fn (mut collection Collection) add_file(mut p Path) !

add a file to the collection, specify existing path

fn (Collection) add_image #

fn (mut collection Collection) add_image(mut p Path) !

add a image to the collection, specify existing path

fn (Collection) add_page #

fn (mut collection Collection) add_page(mut p Path) !

add a page to the collection, specify existing path the page will be parsed as markdown

fn (Collection) error #

fn (mut collection Collection) error(args CollectionError) !

fn (Collection) errors_report #

fn (collection Collection) errors_report(dest_ string, errors []CollectionError) !

write errors.md in the collection, this allows us to see what the errors are

fn (Collection) export #

fn (c Collection) export(args CollectionExportArgs) !

fn (Collection) file_exists #

fn (collection Collection) file_exists(name string) bool

fn (Collection) get_file #

fn (collection Collection) get_file(name string) !&data.File

gets file with specified name form collection

fn (Collection) get_image #

fn (collection Collection) get_image(name string) !&data.File

gets image with specified name from collection

fn (Collection) image_exists #

fn (collection Collection) image_exists(name string) bool

fn (Collection) page_exists #

fn (collection Collection) page_exists(name string) bool

fn (Collection) page_get #

fn (collection Collection) page_get(name string) !&data.Page

gets page with specified name from collection

fn (Collection) scan #

fn (mut collection Collection) scan() !

walk over one specific collection, find all files and pages

struct CollectionError #

struct CollectionError {
	Error
pub mut:
	path Path
	msg  string
	cat  CollectionErrorCat
}

fn (CollectionError) msg #

fn (e CollectionError) msg() string

struct CollectionExportArgs #

@[params]
struct CollectionExportArgs {
pub mut:
	destination    pathlib.Path @[required]
	file_paths     map[string]string
	reset          bool = true
	keep_structure bool // wether the structure of the src collection will be preserved or not
	exclude_errors bool // wether error reporting should be exported as well
	replacer       ?regext.ReplaceInstructions
}

struct CollectionNewArgs #

@[params]
struct CollectionNewArgs {
pub mut:
	name          string @[required]
	path          string @[required]
	heal          bool = true // healing means we fix images, if selected will automatically load, remove stale links
	load          bool = true
	fail_on_error bool
}

struct ExportPagesArgs #

@[params]
struct ExportPagesArgs {
pub mut:
	dir_src        pathlib.Path
	file_paths     map[string]string
	keep_structure bool // wether the structure of the src collection will be preserved or not
	replacer       ?regext.ReplaceInstructions
}

struct ObjNotFound #

struct ObjNotFound {
	Error
pub:
	name       string
	collection string
	info       string
}

fn (ObjNotFound) msg #

fn (err ObjNotFound) msg() string