pub struct Library { /* private fields */ }Expand description
Documents and categories, sorted by path.
Implementations§
Source§impl Library
impl Library
pub fn new() -> Self
Sourcepub fn from_files<'a>(
files: impl IntoIterator<Item = (&'a str, &'a str)>,
) -> Self
pub fn from_files<'a>( files: impl IntoIterator<Item = (&'a str, &'a str)>, ) -> Self
A library of built-in files ((path, text), as embed writes them).
Sourcepub fn insert(&mut self, path: &str, text: &str, source: Source)
pub fn insert(&mut self, path: &str, text: &str, source: Source)
Add or replace one file: _category.md describes its folder, any other .md is a document.
Sourcepub fn overlay_dir(self, dir: &Path) -> Self
pub fn overlay_dir(self, dir: &Path) -> Self
Add the markdown files under dir on top (source Source::User; the same path replaces
a page). Symbolic links, dotfiles and non-markdown files are skipped, as are files over
MAX_FILE_BYTES, folders deeper than MAX_DEPTH and files past MAX_FILES. A
missing folder adds nothing.
Sourcepub fn built_in_only(&self) -> Self
pub fn built_in_only(&self) -> Self
Only the pages and categories built into the program (what a user folder overlays).
pub fn is_empty(&self) -> bool
Sourcepub fn described(&self) -> &[Category]
pub fn described(&self) -> &[Category]
The categories that have a _category.md, sorted by path.
Sourcepub fn category(&self, path: &str) -> Option<Category>
pub fn category(&self, path: &str) -> Option<Category>
A category by path ("" is the root): described by its _category.md, or implied by the
documents under it.
Sourcepub fn tree(&self, path: &str) -> Option<Node>
pub fn tree(&self, path: &str) -> Option<Node>
The category tree under path ("" for all of it); None for an unknown category.
Sourcepub fn list(
&self,
category: Option<&str>,
query: Option<&str>,
recursive: bool,
) -> Vec<&Doc>
pub fn list( &self, category: Option<&str>, query: Option<&str>, recursive: bool, ) -> Vec<&Doc>
Documents in category (all when None; with recursive, also those in its
subcategories) that contain query (case-insensitive, in path, title, description, tags
or text), ordered by category, then order, then path.
Sourcepub fn read(&self, path: &str) -> Result<&str, String>
pub fn read(&self, path: &str) -> Result<&str, String>
The document at exactly path (or a category’s _category.md); an unknown path is an
error that names the closest pages.
Sourcepub fn close_matches(&self, path: &str) -> Vec<&str>
pub fn close_matches(&self, path: &str) -> Vec<&str>
Up to five document paths that share the file name or contain the name’s stem.