[][src]Function mdbook::utils::fs::path_to_root

pub fn path_to_root<P: Into<PathBuf>>(path: P) -> String

Takes a path and returns a path containing just enough ../ to point to the root of the given path.

This is mostly interesting for a relative path to point back to the directory from where the path starts.

let path = Path::new("some/relative/path");
assert_eq!(path_to_root(path), "../../");

note: it's not very fool-proof, if you find a situation where it doesn't return the correct path. Consider submitting a new issue or a pull-request to improve it.