add_parents() — tailwindcss Function Reference
Architecture documentation for the add_parents() function in dir.rs from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 54b22d2f_3aaa_d065_0cd7_db53eddaeeff["add_parents()"] 510a4ebc_9a2a_672a_2d6d_a56dabd1134b["dir.rs"] 54b22d2f_3aaa_d065_0cd7_db53eddaeeff -->|defined in| 510a4ebc_9a2a_672a_2d6d_a56dabd1134b 8530d811_9abb_3027_4676_819060145dc4["absolute_parent()"] 8530d811_9abb_3027_4676_819060145dc4 -->|calls| 54b22d2f_3aaa_d065_0cd7_db53eddaeeff fb5c3777_d449_8158_614b_d0315cd15cd8["absolute_parent_anchored()"] fb5c3777_d449_8158_614b_d0315cd15cd8 -->|calls| 54b22d2f_3aaa_d065_0cd7_db53eddaeeff 77c45013_fd24_9443_8381_d41127a8aed0["is_root()"] 54b22d2f_3aaa_d065_0cd7_db53eddaeeff -->|calls| 77c45013_fd24_9443_8381_d41127a8aed0 1fcf6f1c_93fd_1ecd_9603_9b7a2350bd50["parent()"] 54b22d2f_3aaa_d065_0cd7_db53eddaeeff -->|calls| 1fcf6f1c_93fd_1ecd_9603_9b7a2350bd50 85a07ccd_8d36_b2b7_e048_c40326822cad["add_child_path()"] 54b22d2f_3aaa_d065_0cd7_db53eddaeeff -->|calls| 85a07ccd_8d36_b2b7_e048_c40326822cad style 54b22d2f_3aaa_d065_0cd7_db53eddaeeff fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
crates/ignore/src/dir.rs lines 178–233
pub(crate) fn add_parents<P: AsRef<Path>>(&self, path: P) -> (Ignore, Option<Error>) {
if !self.0.opts.parents
&& !self.0.opts.git_ignore
&& !self.0.opts.git_exclude
&& !self.0.opts.git_global
{
// If we never need info from parent directories, then don't do
// anything.
return (self.clone(), None);
}
if !self.is_root() {
panic!("Ignore::add_parents called on non-root matcher");
}
// CHANGED: Use `dunce::canonicalize` as we use it everywhere else.
let absolute_base = match dunce::canonicalize(path.as_ref()) {
Ok(path) => Arc::new(path),
Err(_) => {
// There's not much we can do here, so just return our
// existing matcher. We drop the error to be consistent
// with our general pattern of ignoring I/O errors when
// processing ignore files.
return (self.clone(), None);
}
};
// List of parents, from child to root.
let mut parents = vec![];
let mut path = &**absolute_base;
while let Some(parent) = path.parent() {
parents.push(parent);
path = parent;
}
let mut errs = PartialErrorBuilder::default();
let mut ig = self.clone();
for parent in parents.into_iter().rev() {
let mut compiled = self.0.compiled.write().unwrap();
if let Some(weak) = compiled.get(parent.as_os_str()) {
if let Some(prebuilt) = weak.upgrade() {
ig = Ignore(prebuilt);
continue;
}
}
let (mut igtmp, err) = ig.add_child_path(parent);
errs.maybe_push(err);
igtmp.is_absolute_parent = true;
igtmp.absolute_base = Some(absolute_base.clone());
igtmp.has_git = if self.0.opts.require_git && self.0.opts.git_ignore {
parent.join(".git").exists() || parent.join(".jj").exists()
} else {
false
};
let ig_arc = Arc::new(igtmp);
ig = Ignore(ig_arc.clone());
compiled.insert(parent.as_os_str().to_os_string(), Arc::downgrade(&ig_arc));
}
(ig, errs.into_error_option())
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does add_parents() do?
add_parents() is a function in the tailwindcss codebase, defined in crates/ignore/src/dir.rs.
Where is add_parents() defined?
add_parents() is defined in crates/ignore/src/dir.rs at line 178.
What does add_parents() call?
add_parents() calls 3 function(s): add_child_path, is_root, parent.
What calls add_parents()?
add_parents() is called by 2 function(s): absolute_parent, absolute_parent_anchored.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free