Home / Function/ add_line() — tailwindcss Function Reference

add_line() — tailwindcss Function Reference

Architecture documentation for the add_line() function in gitignore.rs from the tailwindcss codebase.

Function rust Oxide PreProcessors calls 7 called by 2

Entity Profile

Dependency Diagram

graph TD
  253ea400_e0d4_304c_157c_a6dad80fd874["add_line()"]
  61377720_4557_3c63_7653_b6ed73e2face["gitignore.rs"]
  253ea400_e0d4_304c_157c_a6dad80fd874 -->|defined in| 61377720_4557_3c63_7653_b6ed73e2face
  f95b3cad_268d_6201_5f31_b8ae0f47ef4a["add()"]
  f95b3cad_268d_6201_5f31_b8ae0f47ef4a -->|calls| 253ea400_e0d4_304c_157c_a6dad80fd874
  a2ef63dc_fea6_963f_b41b_91e6e8e4d6e8["add_str()"]
  a2ef63dc_fea6_963f_b41b_91e6e8e4d6e8 -->|calls| 253ea400_e0d4_304c_157c_a6dad80fd874
  78994562_f741_b984_8df0_fdebd0d531e2["is_empty()"]
  253ea400_e0d4_304c_157c_a6dad80fd874 -->|calls| 78994562_f741_b984_8df0_fdebd0d531e2
  bb67cb4e_1b81_9de3_403a_c443da47d119["len()"]
  253ea400_e0d4_304c_157c_a6dad80fd874 -->|calls| bb67cb4e_1b81_9de3_403a_c443da47d119
  7759ea53_037c_bc3d_f4aa_2e669510fa17["has_doublestar_prefix()"]
  253ea400_e0d4_304c_157c_a6dad80fd874 -->|calls| 7759ea53_037c_bc3d_f4aa_2e669510fa17
  31475ef5_8371_db14_d713_bde9c127b678["case_insensitive()"]
  253ea400_e0d4_304c_157c_a6dad80fd874 -->|calls| 31475ef5_8371_db14_d713_bde9c127b678
  1ef15646_a565_ecd3_cd0c_27ffa77e65ca["allow_unclosed_class()"]
  253ea400_e0d4_304c_157c_a6dad80fd874 -->|calls| 1ef15646_a565_ecd3_cd0c_27ffa77e65ca
  80a773f9_5f57_2f17_0199_9d45d676f37b["build()"]
  253ea400_e0d4_304c_157c_a6dad80fd874 -->|calls| 80a773f9_5f57_2f17_0199_9d45d676f37b
  f95b3cad_268d_6201_5f31_b8ae0f47ef4a["add()"]
  253ea400_e0d4_304c_157c_a6dad80fd874 -->|calls| f95b3cad_268d_6201_5f31_b8ae0f47ef4a
  style 253ea400_e0d4_304c_157c_a6dad80fd874 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

crates/ignore/src/gitignore.rs lines 451–532

    pub fn add_line(
        &mut self,
        from: Option<PathBuf>,
        mut line: &str,
    ) -> Result<&mut GitignoreBuilder, Error> {
        #![allow(deprecated)]

        if line.starts_with("#") {
            return Ok(self);
        }
        if !line.ends_with("\\ ") {
            line = line.trim_right();
        }
        if line.is_empty() {
            return Ok(self);
        }
        let mut glob = Glob {
            from,
            original: line.to_string(),
            actual: String::new(),
            is_whitelist: false,
            is_only_dir: false,
        };
        let mut is_absolute = false;
        if line.starts_with("\\!") || line.starts_with("\\#") {
            line = &line[1..];
            is_absolute = line.chars().nth(0) == Some('/');
        } else {
            if line.starts_with("!") {
                glob.is_whitelist = true;
                line = &line[1..];
            }
            if line.starts_with("/") {
                // `man gitignore` says that if a glob starts with a slash,
                // then the glob can only match the beginning of a path
                // (relative to the location of gitignore). We achieve this by
                // simply banning wildcards from matching /.
                line = &line[1..];
                is_absolute = true;
            }
        }
        // If it ends with a slash, then this should only match directories,
        // but the slash should otherwise not be used while globbing.
        if line.as_bytes().last() == Some(&b'/') {
            glob.is_only_dir = true;
            line = &line[..line.len() - 1];
            // If the slash was escaped, then remove the escape.
            // See: https://github.com/BurntSushi/ripgrep/issues/2236
            if line.as_bytes().last() == Some(&b'\\') {
                line = &line[..line.len() - 1];
            }
        }
        glob.actual = line.to_string();
        // If there is a literal slash, then this is a glob that must match the
        // entire path name. Otherwise, we should let it match anywhere, so use
        // a **/ prefix.
        if !is_absolute && !line.chars().any(|c| c == '/') {
            // ... but only if we don't already have a **/ prefix.
            if !glob.has_doublestar_prefix() {
                glob.actual = format!("**/{}", glob.actual);
            }
        }
        // If the glob ends with `/**`, then we should only match everything
        // inside a directory, but not the directory itself. Standard globs
        // will match the directory. So we add `/*` to force the issue.
        if glob.actual.ends_with("/**") {
            glob.actual = format!("{}/*", glob.actual);
        }
        let parsed = GlobBuilder::new(&glob.actual)
            .literal_separator(true)
            .case_insensitive(self.case_insensitive)
            .backslash_escape(true)
            .allow_unclosed_class(self.allow_unclosed_class)
            .build()
            .map_err(|err| Error::Glob {
                glob: Some(glob.original.clone()),
                err: err.kind().to_string(),
            })?;
        self.builder.add(parsed);
        self.globs.push(glob);
        Ok(self)

Domain

Subdomains

Called By

Frequently Asked Questions

What does add_line() do?
add_line() is a function in the tailwindcss codebase, defined in crates/ignore/src/gitignore.rs.
Where is add_line() defined?
add_line() is defined in crates/ignore/src/gitignore.rs at line 451.
What does add_line() call?
add_line() calls 7 function(s): add, allow_unclosed_class, build, case_insensitive, has_doublestar_prefix, is_empty, len.
What calls add_line()?
add_line() is called by 2 function(s): add, add_str.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free