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: PathBufImplementations§
Source§impl Project
impl Project
Sourcepub fn load(path: &Path) -> DdResult<Self>
pub fn load(path: &Path) -> DdResult<Self>
Given the path to a ddoc project root,
load its configuration and pages into a Project struct.
Sourcepub fn build(&self) -> DdResult<()>
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.
Sourcepub fn update(&mut self, change: FileChange, base_url: &str) -> DdResult<bool>
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.
Sourcepub fn clean_build_dir(&self) -> DdResult<()>
pub fn clean_build_dir(&self) -> DdResult<()>
remove the ‘build’ directory and its content
pub fn load_and_build(path: &Path) -> DdResult<()>
Sourcepub fn page_path_of(&self, path: &Path) -> Option<&PagePath>
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.
pub fn list_js(&self) -> DdResult<Vec<StaticEntry>>
pub fn list_css(&self) -> DdResult<Vec<StaticEntry>>
pub fn copy_static(&self, dir: &str) -> DdResult<()>
pub fn build_page(&self, page_path: &PagePath) -> DdResult<()>
pub fn check_img_path(&self, img_path: &str, page_path: &PagePath)
pub fn maybe_rewrite_img_url( &self, src: &str, page_path: &PagePath, ) -> Option<String>
pub fn img_url<'s>(&self, src: &'s str, page_path: &PagePath) -> Cow<'s, str>
Sourcepub fn check_page_path(&self, page_path: &PagePath)
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.
Sourcepub fn maybe_rewrite_link_url(
&self,
src: &str,
page_path: &PagePath,
) -> Option<String>
pub fn maybe_rewrite_link_url( &self, src: &str, page_path: &PagePath, ) -> Option<String>
Return a modified link URL if it needs to be rewritten,
return None if no rewriting is needed.
Sourcepub fn link_url<'s>(&self, src: &'s str, page_path: &PagePath) -> Cow<'s, str>
pub fn link_url<'s>(&self, src: &'s str, page_path: &PagePath) -> Cow<'s, str>
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.