pub struct Document {Show 14 fields
pub extensions: Vec<Binding>,
pub title: String,
pub base: PathBuf,
pub kind: Kind,
pub file_name: String,
pub served: ServedFolder,
pub widgets: Option<PathBuf>,
pub places: Places,
pub structure: Option<PathBuf>,
pub requirements: Option<Requirements>,
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§
§extensions: Vec<Binding>The extensions the document file configures, bound to it, and the live session where it is on.
title: StringThe title it shows: as written, or a Markdown file’s first heading — its file name when it has none — or a design’s file name.
base: PathBufThe folder of the document file, which its paths are relative to.
kind: KindWhat it is — a site, a doc, slides or a design — with its parts resolved.
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.
places: PlacesThe widgets it shows outside its pages’ text: its own and, after them, the live session’s where that is bound to it.
structure: Option<PathBuf>A site’s structure folder — its type files — if it names one.
requirements: Option<Requirements>A site’s requirements — its test suites — if it configures them.
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: &ServedFolder) -> Result<Self>
pub fn load(path: &Path, served: &ServedFolder) -> 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 part_url(&self, part: &Path) -> String
pub fn part_url(&self, part: &Path) -> String
The address of one of the document’s parts — its file, a site’s root, a chapter or a slide.
Panics on any other file outside the served folder: Document::load
refuses a document whose part lies outside it, so a part always has
an address. Any other file’s is Document::url.
Sourcepub fn part_name(&self, part: &Path) -> String
pub fn part_name(&self, part: &Path) -> String
The name of one of the document’s parts, as its problems show it;
panics as Document::part_url does.
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) -> Option<String>
pub fn url(&self, file: &Path) -> Option<String>
A file’s address: its path from the top of the served folder;
None for a file outside it, which has none.
Sourcepub fn name(&self, file: &Path) -> Option<String>
pub fn name(&self, file: &Path) -> Option<String>
A file’s name from the top of the served folder, for labels; None
for a file outside it, which is never named.
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 Forget for Document
impl Freeze for Documentwhere
*const u8 is !null: Freeze,
PhantomData<Binding>: Freeze,
PhantomData<u8>: Freeze,
PhantomData<PathBuf>: Freeze,
PhantomData<Slide>: Freeze,
PhantomData<String>: Freeze,
PhantomData<GlobSetMatchStrategy>: Freeze,
PhantomData<Suite>: Freeze,
PhantomData<NavItem>: Freeze,
impl Move for Document
impl RefUnwindSafe for Documentwhere
Atomic<usize>: RefUnwindSafe,
Mutex<State>: RefUnwindSafe,
Pool<Cache, Box<dyn Fn() -> Cache + Sync + RefUnwindSafe + UnwindSafe + Send>>: RefUnwindSafe,
Pool<PatternSet, Box<dyn Fn() -> PatternSet + Sync + RefUnwindSafe + UnwindSafe + Send>>: RefUnwindSafe,
impl Send for Documentwhere
RawVecInner: Send,
Arc<Mutex<State>>: Send,
RawTable<(Vec<u8>, Vec<usize>)>: Send,
Arc<dyn AcAutomaton>: Send,
RawTable<(Vec<u8>, Vec<(usize, Regex)>)>: Send,
Arc<RegexI>: Send,
BoxRaw<Pool<Cache, Box<dyn Fn() -> Cache + Sync + RefUnwindSafe + UnwindSafe + Send>>>: Send,
Arc<Pool<PatternSet, Box<dyn Fn() -> PatternSet + Sync + RefUnwindSafe + UnwindSafe + Send>>>: Send,
Arc<str>: Send,
impl Sync for Documentwhere
RawVecInner: Sync,
Arc<Mutex<State>>: Sync,
RawTable<(Vec<u8>, Vec<usize>)>: Sync,
Arc<dyn AcAutomaton>: Sync,
RawTable<(Vec<u8>, Vec<(usize, Regex)>)>: Sync,
Arc<RegexI>: Sync,
BoxRaw<Pool<Cache, Box<dyn Fn() -> Cache + Sync + RefUnwindSafe + UnwindSafe + Send>>>: Sync,
Arc<Pool<PatternSet, Box<dyn Fn() -> PatternSet + Sync + RefUnwindSafe + UnwindSafe + Send>>>: Sync,
Arc<str>: Sync,
impl Unpin for Documentwhere
*const u8 is !null: Unpin,
Arc<Mutex<State>>: Unpin,
Arc<dyn AcAutomaton>: Unpin,
Arc<RegexI>: Unpin,
Box<Pool<Cache, Box<dyn Fn() -> Cache + Sync + RefUnwindSafe + UnwindSafe + Send>>>: Unpin,
Arc<Pool<PatternSet, Box<dyn Fn() -> PatternSet + Sync + RefUnwindSafe + UnwindSafe + Send>>>: Unpin,
Arc<str>: Unpin,
impl UnsafeUnpin for Documentwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<Binding>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<PathBuf>: UnsafeUnpin,
PhantomData<Slide>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<GlobSetMatchStrategy>: UnsafeUnpin,
PhantomData<Suite>: UnsafeUnpin,
PhantomData<NavItem>: UnsafeUnpin,
impl UnwindSafe for Documentwhere
RawVecInner: UnwindSafe,
Arc<Mutex<State>>: UnwindSafe,
HashMap<Vec<u8>, Vec<usize>, BuildHasherDefault<Hasher>>: UnwindSafe,
Arc<dyn AcAutomaton>: UnwindSafe,
HashMap<Vec<u8>, Vec<(usize, Regex)>, BuildHasherDefault<Hasher>>: UnwindSafe,
Arc<RegexI>: UnwindSafe,
BoxRaw<Pool<Cache, Box<dyn Fn() -> Cache + Sync + RefUnwindSafe + UnwindSafe + Send>>>: UnwindSafe,
Arc<Pool<PatternSet, Box<dyn Fn() -> PatternSet + Sync + RefUnwindSafe + UnwindSafe + Send>>>: UnwindSafe,
Arc<str>: UnwindSafe,
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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