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 7d4fc0a8_2482_5c00_9ba0_171b0cafaa7a["add_line()"] ae012ab6_9cfc_afd5_a99d_c076b3ac0f7c["add()"] ae012ab6_9cfc_afd5_a99d_c076b3ac0f7c -->|calls| 7d4fc0a8_2482_5c00_9ba0_171b0cafaa7a c315d9a5_ab6e_e200_eab8_ffefbfc19c45["add_str()"] c315d9a5_ab6e_e200_eab8_ffefbfc19c45 -->|calls| 7d4fc0a8_2482_5c00_9ba0_171b0cafaa7a 5ef9c4eb_dd26_3310_8883_d6d0d0fc9c0e["is_empty()"] 7d4fc0a8_2482_5c00_9ba0_171b0cafaa7a -->|calls| 5ef9c4eb_dd26_3310_8883_d6d0d0fc9c0e 5121fe2c_3958_9f97_6237_7d89a9ec2376["len()"] 7d4fc0a8_2482_5c00_9ba0_171b0cafaa7a -->|calls| 5121fe2c_3958_9f97_6237_7d89a9ec2376 48e7ab42_9c4f_b037_2a48_3d6b14871215["has_doublestar_prefix()"] 7d4fc0a8_2482_5c00_9ba0_171b0cafaa7a -->|calls| 48e7ab42_9c4f_b037_2a48_3d6b14871215 ff8dedb4_7a06_fe55_ad0b_d284b0aef7d7["allow_unclosed_class()"] 7d4fc0a8_2482_5c00_9ba0_171b0cafaa7a -->|calls| ff8dedb4_7a06_fe55_ad0b_d284b0aef7d7 7903e9fa_c4f3_6282_ebe5_eed525a2a2b0["build()"] 7d4fc0a8_2482_5c00_9ba0_171b0cafaa7a -->|calls| 7903e9fa_c4f3_6282_ebe5_eed525a2a2b0 ae012ab6_9cfc_afd5_a99d_c076b3ac0f7c["add()"] 7d4fc0a8_2482_5c00_9ba0_171b0cafaa7a -->|calls| ae012ab6_9cfc_afd5_a99d_c076b3ac0f7c d9c5715c_6a1d_ab61_7c43_8466954ed48c["case_insensitive()"] 7d4fc0a8_2482_5c00_9ba0_171b0cafaa7a -->|calls| d9c5715c_6a1d_ab61_7c43_8466954ed48c style 7d4fc0a8_2482_5c00_9ba0_171b0cafaa7a 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