pub struct Document {
pub title: String,
pub base: PathBuf,
pub kind: Kind,
pub file_name: String,
pub served: ServedFolder,
pub widgets: Option<PathBuf>,
pub navbar: Vec<NavItem>,
pub sidebar: bool,
pub theme_selector: bool,
pub logo: Option<String>,
/* private fields */
}Expand description
A loaded document: its title, its folder, what it is, and where it is served.
Fields§
§title: String§base: PathBuf§kind: Kind§file_name: StringThe document file’s name inside base.
served: ServedFolderThe served folder: where devpage was started, or --root. Addresses
are paths in it, and nothing outside it is served.
widgets: Option<PathBuf>The folder of the document’s project widgets, if it has one.
A site’s navbar, in order; empty when it has none.
Whether a site shows its Topics sidebar.
theme_selector: boolWhether the page shows the light/dark selector.
logo: Option<String>The logo field as written: an image relative to the document file,
shown before the title and used as the browser tab’s icon.
Implementations§
Source§impl Document
impl Document
Sourcepub fn load(path: &Path, served: impl Served) -> Result<Self>
pub fn load(path: &Path, served: impl Served) -> Result<Self>
Loads a document file, devpage.yml in a folder, a Markdown file or a
design, which must lie inside the served folder served.
Sourcepub fn logo_url(&self) -> Option<String>
pub fn logo_url(&self) -> Option<String>
The logo’s address, when the document has one and the file exists in the served folder. A logo that doesn’t is a problem, not an error: the page shows without it.
Sourcepub fn url(&self, file: &Path) -> String
pub fn url(&self, file: &Path) -> String
A file’s address: its path from the top of the served folder.
Sourcepub fn name(&self, file: &Path) -> String
pub fn name(&self, file: &Path) -> String
A file’s name from the top of the served folder, for labels.
Sourcepub fn file(&self, url_path: &str) -> Option<PathBuf>
pub fn file(&self, url_path: &str) -> Option<PathBuf>
The file a URL path names, if it lies inside the served folder.
Sourcepub fn watches(&self, file: &Path) -> bool
pub fn watches(&self, file: &Path) -> bool
Whether a change to file refreshes open pages: always, unless this
is a site whose watch list matches none of it, relative to its folder.
Sourcepub fn names(&self, file: &Path) -> bool
pub fn names(&self, file: &Path) -> bool
Whether this is a site whose watch list names file, relative to
its folder.
Sourcepub fn watch_roots(&self) -> &[PathBuf]
pub fn watch_roots(&self) -> &[PathBuf]
The folders a site’s watch patterns can name files in: each
pattern’s literal prefix in the site’s folder. Empty without a list.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnsafeUnpin for Document
impl UnwindSafe for Document
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> Fruit for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more