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.

Entity Profile

Dependency Diagram

graph TD
  53fcda14_433d_b98d_8ccd_5c1f3bb4d3c8["add_parents()"]
  ac45ed16_deea_3b31_5d2e_af6f2cfcd46f["absolute_parent()"]
  ac45ed16_deea_3b31_5d2e_af6f2cfcd46f -->|calls| 53fcda14_433d_b98d_8ccd_5c1f3bb4d3c8
  2007c28e_e062_6ac2_04ec_a9c9b04056f9["absolute_parent_anchored()"]
  2007c28e_e062_6ac2_04ec_a9c9b04056f9 -->|calls| 53fcda14_433d_b98d_8ccd_5c1f3bb4d3c8
  a0a52828_3acf_3f8b_7883_c98a98ca868d["is_root()"]
  53fcda14_433d_b98d_8ccd_5c1f3bb4d3c8 -->|calls| a0a52828_3acf_3f8b_7883_c98a98ca868d
  01f40608_680f_256e_e3c1_245909a51c22["parent()"]
  53fcda14_433d_b98d_8ccd_5c1f3bb4d3c8 -->|calls| 01f40608_680f_256e_e3c1_245909a51c22
  708ca884_a2b4_b556_4c28_c03a22aa3c1f["add_child_path()"]
  53fcda14_433d_b98d_8ccd_5c1f3bb4d3c8 -->|calls| 708ca884_a2b4_b556_4c28_c03a22aa3c1f
  style 53fcda14_433d_b98d_8ccd_5c1f3bb4d3c8 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())
    }

Subdomains

Frequently Asked Questions

What does add_parents() do?
add_parents() is a function in the tailwindcss codebase.
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