add_line() — tailwindcss Function Reference
Architecture documentation for the add_line() function in gitignore.rs from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD beacadb8_c4b1_66be_a831_13b5d839d638["add_line()"] e58274c7_3647_b80e_0fb2_dc3c49dd0e95["add()"] e58274c7_3647_b80e_0fb2_dc3c49dd0e95 -->|calls| beacadb8_c4b1_66be_a831_13b5d839d638 34528413_025e_b66e_b0cb_4851a28b21d1["add_str()"] 34528413_025e_b66e_b0cb_4851a28b21d1 -->|calls| beacadb8_c4b1_66be_a831_13b5d839d638 39e475ea_b9d2_0858_b175_c71a0421de7a["is_empty()"] beacadb8_c4b1_66be_a831_13b5d839d638 -->|calls| 39e475ea_b9d2_0858_b175_c71a0421de7a 34e5d119_dbb7_e0b8_4b36_cda2ff6cc270["len()"] beacadb8_c4b1_66be_a831_13b5d839d638 -->|calls| 34e5d119_dbb7_e0b8_4b36_cda2ff6cc270 fe9e090a_a601_998f_c7f5_372c7d9112ce["has_doublestar_prefix()"] beacadb8_c4b1_66be_a831_13b5d839d638 -->|calls| fe9e090a_a601_998f_c7f5_372c7d9112ce ee32774f_3bf8_a225_b735_dfa008e155d2["allow_unclosed_class()"] beacadb8_c4b1_66be_a831_13b5d839d638 -->|calls| ee32774f_3bf8_a225_b735_dfa008e155d2 68e416a6_57fe_bc5e_90c3_04138c3922d0["build()"] beacadb8_c4b1_66be_a831_13b5d839d638 -->|calls| 68e416a6_57fe_bc5e_90c3_04138c3922d0 e58274c7_3647_b80e_0fb2_dc3c49dd0e95["add()"] beacadb8_c4b1_66be_a831_13b5d839d638 -->|calls| e58274c7_3647_b80e_0fb2_dc3c49dd0e95 51754853_8079_3758_294f_83d1fbb1e545["case_insensitive()"] beacadb8_c4b1_66be_a831_13b5d839d638 -->|calls| 51754853_8079_3758_294f_83d1fbb1e545 style beacadb8_c4b1_66be_a831_13b5d839d638 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
Source
Frequently Asked Questions
What does add_line() do?
add_line() is a function in the tailwindcss codebase.
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