Project

Struct Project 

Source
pub struct Project {
    pub root: PathBuf,
    pub config: Config,
    pub config_path: PathBuf,
    pub pages: FxHashMap<PagePath, Page>,
    pub src_path: PathBuf,
    pub build_path: PathBuf,
}
Expand description

A ddoc project, with its configuration, pages, and location which allows building it.

Fields§

§root: PathBuf§config: Config§config_path: PathBuf§pages: FxHashMap<PagePath, Page>§src_path: PathBuf§build_path: PathBuf

Implementations§

Source§

impl Project

Source

pub fn load(path: &Path) -> DdResult<Self>

Given the path to a ddoc project root, load its configuration and pages into a Project struct.

Source

pub fn build(&self) -> DdResult<()>

Fills the ‘site’ directory with the generated HTML files and static files

Don’t do any prealable cleaning, call clean_build_dir first if needed.

Source

pub fn update(&mut self, change: FileChange, base_url: &str) -> DdResult<bool>

Try to update the project. Return true when some real work was done.

#Errors Doesn’t return error on user/data problems. A missing file, or an invalid config file will only trigger printed messages, not errors.

Source

pub fn clean_build_dir(&self) -> DdResult<()>

remove the ‘build’ directory and its content

Source

pub fn load_and_build(path: &Path) -> DdResult<()>

Source

pub fn page_path_of(&self, path: &Path) -> Option<&PagePath>

If the provided path corresponds to a page in the project, return its PagePath, else return None.

Source

pub fn list_js(&self) -> DdResult<Vec<StaticEntry>>

Source

pub fn list_css(&self) -> DdResult<Vec<StaticEntry>>

Source

pub fn copy_static(&self, dir: &str) -> DdResult<()>

Source

pub fn build_page(&self, page_path: &PagePath) -> DdResult<()>

Source

pub fn check_img_path(&self, img_path: &str, page_path: &PagePath)

Source

pub fn maybe_rewrite_img_url( &self, src: &str, page_path: &PagePath, ) -> Option<String>

Source

pub fn img_url<'s>(&self, src: &'s str, page_path: &PagePath) -> Cow<'s, str>

Source

pub fn load_file(&self, path: &str) -> DdResult<Option<String>>

Source

pub fn check_page_path(&self, page_path: &PagePath)

Check if the given PagePath exists in the project, write an error if it does not.

Source

pub fn previous_page(&self, current_page: &PagePath) -> Option<&Page>

Source

pub fn next_page(&self, current_page: &PagePath) -> Option<&Page>

Return a modified link URL if it needs to be rewritten, return None if no rewriting is needed.

Return a modified link URL if it needs to be rewritten.

If the src is an expansion and cannot be resolved, return the src unchanged.

Source

pub fn static_url( &self, dir: &str, filename: &str, page_path: &PagePath, ) -> String

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V