Skip to main content

Module engine

Module engine 

Source
Expand description

Pure edit engines. They take documents and ops as plain data, never touch the database or the network, and either return the whole new state or reject the whole call.

Re-exports§

pub use error::EditError;
pub use error::EditErrorCode;
pub use error::Warning;
pub use error::WarningCode;
pub use op::PatchTarget;
pub use op::parse_ops;

Modules§

blocks
Block tree navigation by index path ([2, 0] = first child of the third top-level block).
course_settings
patch_course_settings: course and module settings. Publishing switches stay read-only.
course_structure
patch_course_structure: modules, chapters and pages, their order, names, titles, paths and chapter dates. Paths, chapter numbers and redirects are derived once at the end of a call.
error
Errors and warnings of the edit engines.
find_replace
find_replace: literal or regex search, optionally replace, over the raw stored strings of text-bearing block attributes. Matching sees markup: <em>for</em> loops doesn’t match “for loops”.
glossary_references
patch_course_glossary_and_references: glossary terms and BibTeX references.
labels 🔒
$name labels: call-local names for items the call creates.
op
The JSON-Patch-style op shared by every patch tool, and its parsing with teaching errors.
page_content
patch_page_content: block-tree edits on one page, with cross-page move and copy.
path 🔒
The path grammar the engines share: segments with JSON Pointer escapes, ids and $labels, and block paths.
read
Read selectors shared by get_page_content, get_course_structure and read_back.
structural_replace
structural_replace: match blocks by type and text, then wrap, retype, unwrap or remove each.

Structs§

BlockMatch
A block a bulk edit matched.
CreatedIdLog 🔒
Mints the ids a call’s ops create and lists each under the op that created it.
CreatedIds
Ids one op created, in payload order (pre-order for nested items).
Document
A block document the course-wide engines read or changed.
DocumentRef
A block document the course-wide engines read, borrowed.
PageDocument
One page’s block tree with what the engines need to know about the page.
PageRef
A page borrowed from a course state. Engines that scan many pages take these and copy only the pages they change.

Enums§

Anchor 🔒
Where an op puts items: next to a sibling, or at the start or end of a list L.
DocumentKey
Which block document a course-wide engine read: a page or exercise text. Serialized, it is the location reported in results.
PageType
The editor (and validator) context a page’s blocks are checked against. A chapter’s front page takes the same blocks as its other pages.

Functions§

new_item_objects 🔒
The objects an add value creates, each checked to have only fields. noun names an item in errors, e.g. “an audience”, and shape is the error for an item that isn’t an object.
non_empty_string 🔒
The value as a string with more than whitespace in it. Errors with InvalidValue saying that what is one.
reject_unknown_keys 🔒
Fails with UnknownField naming every key of object outside allowed. noun names the object in the message, e.g. “a block”.
value_items 🔒
The items an add value creates: each item of a non-empty list, or the one object. noun names an item in the error, e.g. “a block”.