determine_path

Function determine_path 

Source
pub fn determine_path(
    root_path: impl AsRef<Utf8Path>,
    member_path: &Option<impl AsRef<Utf8Path>>,
    path: impl AsRef<Utf8Path>,
) -> Result<Option<Utf8PathBuf>>
Expand description

Creates a workspace-safe relative path. Takes the following arguments:

  • The root path of the workspace (or single project)
  • An optional workspace member path
  • The path itself, usually extracted from the configuration Member path and the path itself can be relative or absolute . The function will attempt to lazily build the smallest possible absolute and canonicalized path, before diffing it with the root path to create a path that’s always relative to the workspace root.

Some example scenarios:

  1. root path = “/my/directory”, member path = None, path = “myfile.md” Output = “myfile.md”
  2. root path = “/my/directory”, member path = “member”, path = “myfile.md” Output = “member/myfile.md”
  3. root path= “/my/directory”, member path = “/my/directory/member”, path = “../root.md” Output = “root.md”