Home / Function/ add_parents() — tailwindcss Function Reference

add_parents() — tailwindcss Function Reference

Architecture documentation for the add_parents() function in dir.rs from the tailwindcss codebase.

Function rust Oxide PreProcessors calls 3 called by 2

Entity Profile

Dependency Diagram

graph TD
  f704589e_68db_601b_f96b_2d1fcf26e7d3["add_parents()"]
  a558c8e1_3e7c_59d2_b113_bacec65ba188["dir.rs"]
  f704589e_68db_601b_f96b_2d1fcf26e7d3 -->|defined in| a558c8e1_3e7c_59d2_b113_bacec65ba188
  d5516104_0133_7434_5b45_4583cbaabaed["absolute_parent()"]
  d5516104_0133_7434_5b45_4583cbaabaed -->|calls| f704589e_68db_601b_f96b_2d1fcf26e7d3
  53702791_969b_9258_823e_f6e5e40538b2["absolute_parent_anchored()"]
  53702791_969b_9258_823e_f6e5e40538b2 -->|calls| f704589e_68db_601b_f96b_2d1fcf26e7d3
  47225fa8_28c5_e629_dd3e_5a43bb922b64["is_root()"]
  f704589e_68db_601b_f96b_2d1fcf26e7d3 -->|calls| 47225fa8_28c5_e629_dd3e_5a43bb922b64
  8c62ba78_171e_30aa_8e17_07236273bb2e["parent()"]
  f704589e_68db_601b_f96b_2d1fcf26e7d3 -->|calls| 8c62ba78_171e_30aa_8e17_07236273bb2e
  855cb886_6757_8d3a_1a48_e3c2290b323b["add_child_path()"]
  f704589e_68db_601b_f96b_2d1fcf26e7d3 -->|calls| 855cb886_6757_8d3a_1a48_e3c2290b323b
  style f704589e_68db_601b_f96b_2d1fcf26e7d3 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

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