pub struct Project {
pub root: PathBuf,
pub src_path: PathBuf,
pub build_path: PathBuf,
pub config: Config,
pub pages: FxHashMap<PagePath, Page>,
/* private fields */
}Expand description
A ddoc project, with its configuration, pages, and location which allows building it.
Fields§
§root: PathBuf§src_path: PathBuf§build_path: PathBuf§config: Config§pages: FxHashMap<PagePath, Page>Implementations§
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 watch_targets(&self) -> Vec<WatchTarget>
pub fn watch_targets(&self) -> Vec<WatchTarget>
List the files and directories that should be watched for changes to trigger a partial or total rebuild of the project.
pub fn plugin_names(&self) -> impl Iterator<Item = &str>
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.
pub fn add_js_to_build(&self, filename: &str, bytes: &[u8]) -> DdResult<()>
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 img_url(&self, src: &str, page_path: &PagePath) -> String
pub fn load_file(&self, path: &str) -> DdResult<Option<String>>
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.
pub fn previous_page(&self, current_page: &PagePath) -> Option<&Page>
pub fn next_page(&self, current_page: &PagePath) -> Option<&Page>
Sourcepub fn rewrite_link_url(
&self,
src: &str,
page_path: &PagePath,
) -> Option<String>
pub fn rewrite_link_url( &self, src: &str, page_path: &PagePath, ) -> Option<String>
Return the modified link URL.
return None when no expansion is possible, which should
lead to the container being skipped.
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.