diff --git a/Cargo.lock b/Cargo.lock index 1f47537..d4ebbda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,26 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +dependencies = [ + "memchr", +] + [[package]] name = "ansi_term" version = "0.11.0" @@ -35,7 +55,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" dependencies = [ "backtrace-sys", - "cfg-if", + "cfg-if 0.1.6", "libc", "rustc-demangle", "winapi", @@ -69,6 +89,12 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + [[package]] name = "clap" version = "2.32.0" @@ -79,7 +105,7 @@ dependencies = [ "atty", "bitflags", "strsim", - "textwrap", + "textwrap 0.10.0", "unicode-width", "vec_map", ] @@ -124,17 +150,31 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 0.4.20", + "quote 0.6.8", + "syn 0.15.15", "synstructure", ] +[[package]] +name = "getrandom" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi", +] + [[package]] name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] [[package]] name = "insta" @@ -149,6 +189,12 @@ dependencies = [ "yaml-rust", ] +[[package]] +name = "itoa" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" + [[package]] name = "lazy_static" version = "1.4.0" @@ -167,6 +213,12 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + [[package]] name = "memoffset" version = "0.8.0" @@ -184,10 +236,19 @@ dependencies = [ "insta", "rnix", "rowan", + "serde", + "serde_json", "structopt", + "textwrap 0.16.0", "xml-rs", ] +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + [[package]] name = "proc-macro2" version = "0.4.20" @@ -197,13 +258,31 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "proc-macro2" +version = "1.0.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406" +dependencies = [ + "unicode-ident", +] + [[package]] name = "quote" version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5" dependencies = [ - "proc-macro2", + "proc-macro2 0.4.20", +] + +[[package]] +name = "quote" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +dependencies = [ + "proc-macro2 1.0.60", ] [[package]] @@ -221,6 +300,23 @@ dependencies = [ "redox_syscall", ] +[[package]] +name = "regex" +version = "1.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" + [[package]] name = "rnix" version = "0.11.0" @@ -255,12 +351,55 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "ryu" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" + +[[package]] +name = "serde" +version = "1.0.164" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.164" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" +dependencies = [ + "proc-macro2 1.0.60", + "quote 1.0.28", + "syn 2.0.18", +] + +[[package]] +name = "serde_json" +version = "1.0.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdf3bf93142acad5821c99197022e170842cdbc1c30482b98750c688c640842a" +dependencies = [ + "itoa", + "ryu", + "serde", +] + [[package]] name = "similar" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "420acb44afdae038210c99e69aae24109f32f15500aa708e81d46c9f29d55fcf" +[[package]] +name = "smawk" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" + [[package]] name = "strsim" version = "0.7.0" @@ -283,9 +422,9 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17ff01fe96de9d16e7372ae5f19dd7ece2c703b51043c3db9ea27f9e393ea311" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 0.4.20", + "quote 0.6.8", + "syn 0.15.15", ] [[package]] @@ -294,20 +433,31 @@ version = "0.15.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a9c2bf1e53c21704a7cce1b2a42768f1ae32a6777108a0d7f1faa4bfe7f7c04" dependencies = [ - "proc-macro2", - "quote", + "proc-macro2 0.4.20", + "quote 0.6.8", "unicode-xid", ] +[[package]] +name = "syn" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" +dependencies = [ + "proc-macro2 1.0.60", + "quote 1.0.28", + "unicode-ident", +] + [[package]] name = "synstructure" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015" dependencies = [ - "proc-macro2", - "quote", - "syn", + "proc-macro2 0.4.20", + "quote 0.6.8", + "syn 0.15.15", "unicode-xid", ] @@ -337,11 +487,38 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "textwrap" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" +dependencies = [ + "smawk", + "unicode-linebreak", + "unicode-width", +] + +[[package]] +name = "unicode-ident" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" + +[[package]] +name = "unicode-linebreak" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5faade31a542b8b35855fff6e8def199853b2da8da256da52f52f1316ee3137" +dependencies = [ + "hashbrown", + "regex", +] + [[package]] name = "unicode-width" -version = "0.1.5" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "unicode-xid" @@ -355,6 +532,18 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "winapi" version = "0.3.6" diff --git a/Cargo.toml b/Cargo.toml index e8f04ed..4458a6e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,9 @@ structopt = "0.2" failure = "0.1" rnix = "0.11" rowan = "0.15.11" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +textwrap = "0.16" [dev-dependencies] insta = "1.29.0" diff --git a/src/commonmark.rs b/src/commonmark.rs index a9a4dc8..6025889 100644 --- a/src/commonmark.rs +++ b/src/commonmark.rs @@ -17,13 +17,13 @@ //! representing a single entry in the manual. use failure::Error; -use std::iter::repeat; +use std::collections::HashMap; use std::io::Write; /// Represent a single function argument name and its (optional) /// doc-string. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct SingleArg { pub name: String, pub doc: Option, @@ -31,7 +31,7 @@ pub struct SingleArg { /// Represent a function argument, which is either a flat identifier /// or a pattern set. -#[derive(Debug)] +#[derive(Clone, Debug)] pub enum Argument { /// Flat function argument (e.g. `n: n * 2`). Flat(SingleArg), @@ -40,48 +40,40 @@ pub enum Argument { Pattern(Vec), } -fn print_indented(writer: &mut W, indent: usize, text: &str) -> Result<(), Error> { - let prefix = repeat(' ').take(indent).collect::(); - writeln!( - writer, - "{}", - text.replace("\r\n", "\n") - .replace("\n", &format!("\n{prefix}")) - )?; - - Ok(()) -} - impl Argument { /// Write CommonMark structure for a single function argument. - fn write_argument(self, writer: &mut W, indent: usize) -> Result<(), Error> { + fn format_argument(self) -> String { match self { // Write a flat argument entry. Argument::Flat(arg) => { - let arg_text = format!( + format!( "`{}`\n\n: {}\n\n", arg.name, arg.doc.unwrap_or("Function argument".into()).trim() - ); - print_indented(writer, indent, &arg_text)?; + ) } // Write a pattern argument entry and its individual // parameters as a nested structure. Argument::Pattern(pattern_args) => { - print_indented(writer, indent, "structured function argument\n\n: ")?; + let mut inner = String::new(); for pattern_arg in pattern_args { - Argument::Flat(pattern_arg).write_argument(writer, indent + 2)?; + inner += &Argument::Flat(pattern_arg).format_argument(); } + + let indented = textwrap::indent(&inner, " "); + // drop leading indentation, the `: ` serves this function already + format!( + "structured function argument\n\n: {}", + indented.trim_start() + ) } } - - Ok(()) } } /// Represents a single manual section describing a library function. -#[derive(Debug)] +#[derive(Clone, Debug)] pub struct ManualEntry { /// Name of the function category (e.g. 'strings', 'trivial', 'attrsets') pub category: String, @@ -106,7 +98,11 @@ pub struct ManualEntry { impl ManualEntry { /// Write a single CommonMark entry for a documented Nix function. - pub fn write_section(self, writer: &mut W) -> Result<(), Error> { + pub fn write_section( + self, + locs: &HashMap, + writer: &mut W, + ) -> Result<(), Error> { let title = format!("lib.{}.{}", self.category, self.name); let ident = format!( "lib.{}.{}", @@ -118,7 +114,7 @@ impl ManualEntry { // (type signature) if let Some(t) = &self.fn_type { - writeln!(writer, "`{}`\n", t)?; + writeln!(writer, "**Type**: `{}`\n", t)?; } // Primary doc string @@ -130,7 +126,7 @@ impl ManualEntry { // Function argument names if !self.args.is_empty() { for arg in self.args { - arg.write_argument(writer, 0)?; + writeln!(writer, "{}", arg.format_argument())?; } } @@ -141,14 +137,16 @@ impl ManualEntry { if let Some(example) = &self.example { writeln!( writer, - "### {} usage example {{#function-library-example-{}}}\n", - title, ident + "::: {{.example #function-library-example-{}}}", + ident )?; - writeln!(writer, "```nix{}```\n", example)?; + writeln!(writer, "# `{}` usage example\n", title)?; + writeln!(writer, "```nix\n{}\n```\n:::\n", example.trim())?; } - // TODO: add source links - //println!("[Source](#function-location-{})", ident); + if let Some(loc) = locs.get(&ident) { + writeln!(writer, "Located at {loc}.\n")?; + } Ok(()) } diff --git a/src/main.rs b/src/main.rs index df81bfd..6e40469 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,12 +30,13 @@ mod commonmark; use self::commonmark::*; use rnix::{ - ast::{AstToken, AttrSet, AttrpathValue, Comment, Expr, Lambda, Param}, + ast::{AstToken, Attr, AttrpathValue, Comment, Expr, Inherit, Lambda, LetIn, Param}, SyntaxKind, SyntaxNode, }; use rowan::{ast::AstNode, WalkEvent}; use std::fs; +use std::collections::HashMap; use std::io; use std::io::Write; @@ -53,6 +54,10 @@ struct Options { #[structopt(short = "f", long = "file", parse(from_os_str))] file: PathBuf, + /// Path to a file containing location data as JSON. + #[structopt(short = "l", long = "locs", parse(from_os_str))] + locs: Option, + /// Name of the function category (e.g. 'strings', 'attrsets'). #[structopt(short = "c", long = "category")] category: String, @@ -81,11 +86,29 @@ struct DocItem { args: Vec, } +impl DocItem { + fn to_entry(self, category: &str) -> ManualEntry { + ManualEntry { + category: category.to_string(), + name: self.name, + description: self + .comment + .doc + .split("\n\n") + .map(|s| s.to_string()) + .collect(), + fn_type: self.comment.doc_type, + example: self.comment.example, + args: self.args, + } + } +} + /// Retrieve documentation comments. -fn retrieve_doc_comment(node: &SyntaxNode) -> Option { +fn retrieve_doc_comment(node: &SyntaxNode, allow_line_comments: bool) -> Option { // if the current node has a doc comment it'll be immediately preceded by that comment, // or there will be a whitespace token and *then* the comment tokens before it. we merge - // multiple single-line comments into one large comment if they are on adjacent lines for + // multiple line comments into one large comment if they are on adjacent lines for // documentation simplicity. let mut token = node.first_token()?.prev_token()?; if token.kind() == SyntaxKind::TOKEN_WHITESPACE { @@ -95,36 +118,55 @@ fn retrieve_doc_comment(node: &SyntaxNode) -> Option { return None; } - // backtrack to the start of the doc comment, allowing only a single multi-line comment - // or adjacent single-line comments. - // we don't care much about optimization here, doc comments aren't long enough for that. + // if we want to ignore line comments (eg because they may contain deprecation + // comments on attributes) we'll backtrack to the first preceding multiline comment. + while !allow_line_comments && token.text().starts_with("#") { + token = token.prev_token()?; + if token.kind() == SyntaxKind::TOKEN_WHITESPACE { + token = token.prev_token()?; + } + if token.kind() != SyntaxKind::TOKEN_COMMENT { + return None; + } + } + if token.text().starts_with("/*") { return Some(Comment::cast(token)?.text().to_string()); } - let mut result = String::new(); - while let Some(comment) = Comment::cast(token) { - result.insert_str(0, comment.text()); - let ws = match comment.syntax().prev_token() { - Some(t) if t.kind() == SyntaxKind::TOKEN_WHITESPACE => t, - _ => break, - }; - // only adjacent lines continue a doc comment, empty lines do not. - match ws.text().strip_prefix("\n") { - Some(trail) if !trail.contains("\n") => result.insert_str(0, ws.text()), - _ => break, + + // backtrack to the start of the doc comment, allowing only adjacent line comments. + // we don't care much about optimization here, doc comments aren't long enough for that. + if token.text().starts_with("#") { + let mut result = String::new(); + while let Some(comment) = Comment::cast(token) { + if !comment.syntax().text().starts_with("#") { + break; + } + result.insert_str(0, comment.text().trim()); + let ws = match comment.syntax().prev_token() { + Some(t) if t.kind() == SyntaxKind::TOKEN_WHITESPACE => t, + _ => break, + }; + // only adjacent lines continue a doc comment, empty lines do not. + match ws.text().strip_prefix("\n") { + Some(trail) if !trail.contains("\n") => result.insert_str(0, " "), + _ => break, + } + token = match ws.prev_token() { + Some(c) => c, + _ => break, + }; } - token = match ws.prev_token() { - Some(c) => c, - _ => break, - }; + return Some(result); } - Some(result) + + None } /// Transforms an AST node into a `DocItem` if it has a leading /// documentation comment. fn retrieve_doc_item(node: &AttrpathValue) -> Option { - let comment = retrieve_doc_comment(node.syntax())?; + let comment = retrieve_doc_comment(node.syntax(), false)?; let ident = node.attrpath().unwrap(); // TODO this should join attrs() with '.' to handle whitespace, dynamic attrs and string // attrs. none of these happen in nixpkgs lib, and the latter two should probably be @@ -196,7 +238,7 @@ fn collect_lambda_args(mut lambda: Lambda) -> Vec { Param::IdentParam(id) => { args.push(Argument::Flat(SingleArg { name: id.to_string(), - doc: retrieve_doc_comment(id.syntax()), + doc: retrieve_doc_comment(id.syntax(), true), })); } Param::Pattern(pat) => { @@ -204,7 +246,7 @@ fn collect_lambda_args(mut lambda: Lambda) -> Vec { .pat_entries() .map(|entry| SingleArg { name: entry.ident().unwrap().to_string(), - doc: retrieve_doc_comment(entry.syntax()), + doc: retrieve_doc_comment(entry.syntax(), true), }) .collect(); @@ -242,32 +284,81 @@ fn collect_entry_information(entry: AttrpathValue) -> Option { } } +fn collect_bindings( + node: &SyntaxNode, + category: &str, + scope: HashMap, +) -> Vec { + for ev in node.preorder() { + match ev { + WalkEvent::Enter(n) if n.kind() == SyntaxKind::NODE_ATTR_SET => { + let mut entries = vec![]; + for child in n.children() { + if let Some(apv) = AttrpathValue::cast(child.clone()) { + entries + .extend(collect_entry_information(apv).map(|di| di.to_entry(category))); + } else if let Some(inh) = Inherit::cast(child) { + // `inherit (x) ...` needs much more handling than we can + // reasonably do here + if inh.from().is_some() { + continue; + } + entries.extend(inh.attrs().filter_map(|a| match a { + Attr::Ident(i) => scope.get(&i.syntax().text().to_string()).cloned(), + // ignore non-ident keys. these aren't useful as lib + // functions in general anyway. + _ => None, + })); + } + } + return entries; + } + _ => (), + } + } + + vec![] +} + fn collect_entries(root: rnix::Root, category: &str) -> Vec { - root.syntax() - .preorder() - .filter_map(|ev| match ev { - WalkEvent::Enter(n) => Some(n), - _ => None, - }) - .filter_map(AttrSet::cast) - .flat_map(|n| n.syntax().children()) - .filter_map(AttrpathValue::cast) - .filter_map(collect_entry_information) - .map(|d| ManualEntry { - category: category.to_string(), - name: d.name, - description: d.comment.doc.split("\n\n").map(|s| s.to_string()).collect(), - fn_type: d.comment.doc_type, - example: d.comment.example, - args: d.args, - }) - .collect() + // we will look into the top-level let and its body for function docs. + // we only need a single level of scope for this. + // since only the body can export a function we don't need to implement + // mutually recursive resolution. + for ev in root.syntax().preorder() { + match ev { + WalkEvent::Enter(n) if n.kind() == SyntaxKind::NODE_LET_IN => { + return collect_bindings( + LetIn::cast(n.clone()).unwrap().body().unwrap().syntax(), + category, + n.children() + .filter_map(AttrpathValue::cast) + .filter_map(collect_entry_information) + .map(|di| (di.name.to_string(), di.to_entry(category))) + .collect(), + ); + } + WalkEvent::Enter(n) if n.kind() == SyntaxKind::NODE_ATTR_SET => { + return collect_bindings(&n, category, Default::default()); + } + _ => (), + } + } + + vec![] } fn main() { let mut output = io::stdout(); let opts = Options::from_args(); let src = fs::read_to_string(&opts.file).unwrap(); + let locs = match opts.locs { + None => Default::default(), + Some(p) => fs::read_to_string(p) + .map_err(|e| e.to_string()) + .and_then(|json| serde_json::from_str(&json).map_err(|e| e.to_string())) + .expect("could not read location information"), + }; let nix = rnix::Root::parse(&src).ok().expect("failed to parse input"); // TODO: move this to commonmark.rs @@ -280,7 +371,7 @@ fn main() { for entry in collect_entries(nix, &opts.category) { entry - .write_section(&mut output) + .write_section(&locs, &mut output) .expect("Failed to write section") } } @@ -289,6 +380,7 @@ fn main() { fn test_main() { let mut output = Vec::new(); let src = fs::read_to_string("test/strings.nix").unwrap(); + let locs = serde_json::from_str(&fs::read_to_string("test/strings.json").unwrap()).unwrap(); let nix = rnix::Root::parse(&src).ok().expect("failed to parse input"); let desc = "string manipulation functions"; let category = "strings"; @@ -303,7 +395,61 @@ fn test_main() { for entry in collect_entries(nix, category) { entry - .write_section(&mut output) + .write_section(&locs, &mut output) + .expect("Failed to write section") + } + + let output = String::from_utf8(output).expect("not utf8"); + + insta::assert_snapshot!(output); +} + +#[test] +fn test_arg_formatting() { + let mut output = Vec::new(); + let src = fs::read_to_string("test/arg-formatting.nix").unwrap(); + let nix = rnix::Root::parse(&src).ok().expect("failed to parse input"); + let category = "options"; + + for entry in collect_entries(nix, category) { + entry + .write_section(&Default::default(), &mut output) + .expect("Failed to write section") + } + + let output = String::from_utf8(output).expect("not utf8"); + + insta::assert_snapshot!(output); +} + +#[test] +fn test_inherited_exports() { + let mut output = Vec::new(); + let src = fs::read_to_string("test/inherited-exports.nix").unwrap(); + let nix = rnix::Root::parse(&src).ok().expect("failed to parse input"); + let category = "let"; + + for entry in collect_entries(nix, category) { + entry + .write_section(&Default::default(), &mut output) + .expect("Failed to write section") + } + + let output = String::from_utf8(output).expect("not utf8"); + + insta::assert_snapshot!(output); +} + +#[test] +fn test_line_comments() { + let mut output = Vec::new(); + let src = fs::read_to_string("test/line-comments.nix").unwrap(); + let nix = rnix::Root::parse(&src).ok().expect("failed to parse input"); + let category = "let"; + + for entry in collect_entries(nix, category) { + entry + .write_section(&Default::default(), &mut output) .expect("Failed to write section") } diff --git a/src/snapshots/nixdoc__arg_formatting.snap b/src/snapshots/nixdoc__arg_formatting.snap new file mode 100644 index 0000000..fc2e8ee --- /dev/null +++ b/src/snapshots/nixdoc__arg_formatting.snap @@ -0,0 +1,25 @@ +--- +source: src/main.rs +expression: output +--- +## `lib.options.fn` {#function-library-lib.options.fn} + +documented function + +`a` + +: single arugment + + +structured function argument + +: `default` + + : documented argument + + `example` + + : i like this argument. another! + + + diff --git a/src/snapshots/nixdoc__inherited_exports.snap b/src/snapshots/nixdoc__inherited_exports.snap new file mode 100644 index 0000000..ff6cbbc --- /dev/null +++ b/src/snapshots/nixdoc__inherited_exports.snap @@ -0,0 +1,24 @@ +--- +source: src/main.rs +expression: output +--- +## `lib.let.concatStrings` {#function-library-lib.let.concatStrings} + +**Type**: `concatStrings :: [string] -> string` + +Concatenate a list of strings. + +::: {.example #function-library-example-lib.let.concatStrings} +# `lib.let.concatStrings` usage example + +```nix +concatStrings ["foo" "bar"] +=> "foobar" +``` +::: + +## `lib.let.foo2` {#function-library-lib.let.foo2} + +this should be found + + diff --git a/src/snapshots/nixdoc__line_comments.snap b/src/snapshots/nixdoc__line_comments.snap new file mode 100644 index 0000000..2b9ed97 --- /dev/null +++ b/src/snapshots/nixdoc__line_comments.snap @@ -0,0 +1,24 @@ +--- +source: src/main.rs +expression: output +--- +## `lib.let.shown` {#function-library-lib.let.shown} + +is a doc comment + +`a` + +: a doc comment + + +`b` + +: also a doc comment + + +`c` + +: a doc comment with continuation + + + diff --git a/src/snapshots/nixdoc__main.snap b/src/snapshots/nixdoc__main.snap index 9a77b59..e686ef1 100644 --- a/src/snapshots/nixdoc__main.snap +++ b/src/snapshots/nixdoc__main.snap @@ -6,20 +6,24 @@ expression: output ## `lib.strings.concatStrings` {#function-library-lib.strings.concatStrings} -`concatStrings :: [string] -> string` +**Type**: `concatStrings :: [string] -> string` Concatenate a list of strings. -### lib.strings.concatStrings usage example {#function-library-example-lib.strings.concatStrings} +::: {.example #function-library-example-lib.strings.concatStrings} +# `lib.strings.concatStrings` usage example ```nix concatStrings ["foo" "bar"] => "foobar" ``` +::: + +Located at [lib/strings.nix:49](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L49) in ``. ## `lib.strings.concatMapStrings` {#function-library-lib.strings.concatMapStrings} -`concatMapStrings :: (a -> string) -> [a] -> string` +**Type**: `concatMapStrings :: (a -> string) -> [a] -> string` Map a function over a list and concatenate the resulting strings. @@ -33,16 +37,20 @@ Map a function over a list and concatenate the resulting strings. : Function argument -### lib.strings.concatMapStrings usage example {#function-library-example-lib.strings.concatMapStrings} +::: {.example #function-library-example-lib.strings.concatMapStrings} +# `lib.strings.concatMapStrings` usage example ```nix concatMapStrings (x: "a" + x) ["foo" "bar"] => "afooabar" ``` +::: + +Located at [lib/strings.nix:59](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L59) in ``. ## `lib.strings.concatImapStrings` {#function-library-lib.strings.concatImapStrings} -`concatImapStrings :: (int -> a -> string) -> [a] -> string` +**Type**: `concatImapStrings :: (int -> a -> string) -> [a] -> string` Like `concatMapStrings` except that the f functions also gets the position as a parameter. @@ -57,16 +65,20 @@ position as a parameter. : Function argument -### lib.strings.concatImapStrings usage example {#function-library-example-lib.strings.concatImapStrings} +::: {.example #function-library-example-lib.strings.concatImapStrings} +# `lib.strings.concatImapStrings` usage example ```nix concatImapStrings (pos: x: "${toString pos}-${x}") ["foo" "bar"] => "1-foo2-bar" ``` +::: + +Located at [lib/strings.nix:70](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L70) in ``. ## `lib.strings.intersperse` {#function-library-lib.strings.intersperse} -`intersperse :: a -> [a] -> [a]` +**Type**: `intersperse :: a -> [a] -> [a]` Place an element between each element of a list @@ -80,29 +92,37 @@ Place an element between each element of a list : Input list -### lib.strings.intersperse usage example {#function-library-example-lib.strings.intersperse} +::: {.example #function-library-example-lib.strings.intersperse} +# `lib.strings.intersperse` usage example ```nix intersperse "/" ["usr" "local" "bin"] => ["usr" "/" "local" "/" "bin"]. ``` +::: + +Located at [lib/strings.nix:80](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L80) in ``. ## `lib.strings.concatStringsSep` {#function-library-lib.strings.concatStringsSep} -`concatStringsSep :: string -> [string] -> string` +**Type**: `concatStringsSep :: string -> [string] -> string` Concatenate a list of strings with a separator between each element -### lib.strings.concatStringsSep usage example {#function-library-example-lib.strings.concatStringsSep} +::: {.example #function-library-example-lib.strings.concatStringsSep} +# `lib.strings.concatStringsSep` usage example ```nix concatStringsSep "/" ["usr" "local" "bin"] => "usr/local/bin" ``` +::: + +Located at [lib/strings.nix:97](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L97) in ``. ## `lib.strings.concatMapStringsSep` {#function-library-lib.strings.concatMapStringsSep} -`concatMapStringsSep :: string -> (a -> string) -> [a] -> string` +**Type**: `concatMapStringsSep :: string -> (a -> string) -> [a] -> string` Maps a function over a list of strings and then concatenates the result with the specified separator interspersed between @@ -123,16 +143,20 @@ elements. : List of input strings -### lib.strings.concatMapStringsSep usage example {#function-library-example-lib.strings.concatMapStringsSep} +::: {.example #function-library-example-lib.strings.concatMapStringsSep} +# `lib.strings.concatMapStringsSep` usage example ```nix concatMapStringsSep "-" (x: toUpper x) ["foo" "bar" "baz"] => "FOO-BAR-BAZ" ``` +::: + +Located at [lib/strings.nix:110](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L110) in ``. ## `lib.strings.concatImapStringsSep` {#function-library-lib.strings.concatImapStringsSep} -`concatIMapStringsSep :: string -> (int -> a -> string) -> [a] -> string` +**Type**: `concatIMapStringsSep :: string -> (int -> a -> string) -> [a] -> string` Same as `concatMapStringsSep`, but the mapping function additionally receives the position of its argument. @@ -152,30 +176,38 @@ additionally receives the position of its argument. : List of input strings -### lib.strings.concatImapStringsSep usage example {#function-library-example-lib.strings.concatImapStringsSep} +::: {.example #function-library-example-lib.strings.concatImapStringsSep} +# `lib.strings.concatImapStringsSep` usage example ```nix concatImapStringsSep "-" (pos: x: toString (x / pos)) [ 6 6 6 ] => "6-3-2" ``` +::: + +Located at [lib/strings.nix:127](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L127) in ``. ## `lib.strings.concatLines` {#function-library-lib.strings.concatLines} -`concatLines :: [string] -> string` +**Type**: `concatLines :: [string] -> string` Concatenate a list of strings, adding a newline at the end of each one. Defined as `concatMapStrings (s: s + "\n")`. -### lib.strings.concatLines usage example {#function-library-example-lib.strings.concatLines} +::: {.example #function-library-example-lib.strings.concatLines} +# `lib.strings.concatLines` usage example ```nix concatLines [ "foo" "bar" ] => "foo\nbar\n" ``` +::: + +Located at [lib/strings.nix:144](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L144) in ``. ## `lib.strings.makeSearchPath` {#function-library-lib.strings.makeSearchPath} -`makeSearchPath :: string -> [string] -> string` +**Type**: `makeSearchPath :: string -> [string] -> string` Construct a Unix-style, colon-separated search path consisting of the given `subDir` appended to each of the given paths. @@ -190,7 +222,8 @@ the given `subDir` appended to each of the given paths. : List of base paths -### lib.strings.makeSearchPath usage example {#function-library-example-lib.strings.makeSearchPath} +::: {.example #function-library-example-lib.strings.makeSearchPath} +# `lib.strings.makeSearchPath` usage example ```nix makeSearchPath "bin" ["/root" "/usr" "/usr/local"] @@ -198,10 +231,13 @@ makeSearchPath "bin" ["/root" "/usr" "/usr/local"] makeSearchPath "bin" [""] => "/bin" ``` +::: + +Located at [lib/strings.nix:157](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L157) in ``. ## `lib.strings.makeSearchPathOutput` {#function-library-lib.strings.makeSearchPathOutput} -`string -> string -> [package] -> string` +**Type**: `string -> string -> [package] -> string` Construct a Unix-style search path by appending the given `subDir` to the specified `output` of each of the packages. If no @@ -223,19 +259,24 @@ the default. : List of packages -### lib.strings.makeSearchPathOutput usage example {#function-library-example-lib.strings.makeSearchPathOutput} +::: {.example #function-library-example-lib.strings.makeSearchPathOutput} +# `lib.strings.makeSearchPathOutput` usage example ```nix makeSearchPathOutput "dev" "bin" [ pkgs.openssl pkgs.zlib ] => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r-dev/bin:/nix/store/wwh7mhwh269sfjkm6k5665b5kgp7jrk2-zlib-1.2.8/bin" ``` +::: + +Located at [lib/strings.nix:175](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L175) in ``. ## `lib.strings.makeLibraryPath` {#function-library-lib.strings.makeLibraryPath} Construct a library search path (such as RPATH) containing the libraries for a set of packages -### lib.strings.makeLibraryPath usage example {#function-library-example-lib.strings.makeLibraryPath} +::: {.example #function-library-example-lib.strings.makeLibraryPath} +# `lib.strings.makeLibraryPath` usage example ```nix makeLibraryPath [ "/usr" "/usr/local" ] @@ -244,22 +285,29 @@ pkgs = import { } makeLibraryPath [ pkgs.openssl pkgs.zlib ] => "/nix/store/9rz8gxhzf8sw4kf2j2f1grr49w8zx5vj-openssl-1.0.1r/lib:/nix/store/wwh7mhwh269sfjkm6k5665b5kgp7jrk2-zlib-1.2.8/lib" ``` +::: + +Located at [lib/strings.nix:193](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L193) in ``. ## `lib.strings.makeBinPath` {#function-library-lib.strings.makeBinPath} Construct a binary search path (such as $PATH) containing the binaries for a set of packages. -### lib.strings.makeBinPath usage example {#function-library-example-lib.strings.makeBinPath} +::: {.example #function-library-example-lib.strings.makeBinPath} +# `lib.strings.makeBinPath` usage example ```nix makeBinPath ["/root" "/usr" "/usr/local"] => "/root/bin:/usr/bin:/usr/local/bin" ``` +::: + +Located at [lib/strings.nix:202](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L202) in ``. ## `lib.strings.normalizePath` {#function-library-lib.strings.normalizePath} -`normalizePath :: string -> string` +**Type**: `normalizePath :: string -> string` Normalize path, removing extraneous /s @@ -268,16 +316,20 @@ Normalize path, removing extraneous /s : Function argument -### lib.strings.normalizePath usage example {#function-library-example-lib.strings.normalizePath} +::: {.example #function-library-example-lib.strings.normalizePath} +# `lib.strings.normalizePath` usage example ```nix normalizePath "/a//b///c/" => "/a/b/c/" ``` +::: + +Located at [lib/strings.nix:212](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L212) in ``. ## `lib.strings.optionalString` {#function-library-lib.strings.optionalString} -`optionalString :: bool -> string -> string` +**Type**: `optionalString :: bool -> string -> string` Depending on the boolean `cond', return either the given string or the empty string. Useful to concatenate against a bigger string. @@ -292,7 +344,8 @@ or the empty string. Useful to concatenate against a bigger string. : String to return if condition is true -### lib.strings.optionalString usage example {#function-library-example-lib.strings.optionalString} +::: {.example #function-library-example-lib.strings.optionalString} +# `lib.strings.optionalString` usage example ```nix optionalString true "some-string" @@ -300,10 +353,13 @@ optionalString true "some-string" optionalString false "some-string" => "" ``` +::: + +Located at [lib/strings.nix:238](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L238) in ``. ## `lib.strings.hasPrefix` {#function-library-lib.strings.hasPrefix} -`hasPrefix :: string -> string -> bool` +**Type**: `hasPrefix :: string -> string -> bool` Determine whether a string has given prefix. @@ -317,7 +373,8 @@ Determine whether a string has given prefix. : Input string -### lib.strings.hasPrefix usage example {#function-library-example-lib.strings.hasPrefix} +::: {.example #function-library-example-lib.strings.hasPrefix} +# `lib.strings.hasPrefix` usage example ```nix hasPrefix "foo" "foobar" @@ -325,10 +382,13 @@ hasPrefix "foo" "foobar" hasPrefix "foo" "barfoo" => false ``` +::: + +Located at [lib/strings.nix:254](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L254) in ``. ## `lib.strings.hasSuffix` {#function-library-lib.strings.hasSuffix} -`hasSuffix :: string -> string -> bool` +**Type**: `hasSuffix :: string -> string -> bool` Determine whether a string has given suffix. @@ -342,7 +402,8 @@ Determine whether a string has given suffix. : Input string -### lib.strings.hasSuffix usage example {#function-library-example-lib.strings.hasSuffix} +::: {.example #function-library-example-lib.strings.hasSuffix} +# `lib.strings.hasSuffix` usage example ```nix hasSuffix "foo" "foobar" @@ -350,10 +411,13 @@ hasSuffix "foo" "foobar" hasSuffix "foo" "barfoo" => true ``` +::: + +Located at [lib/strings.nix:280](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L280) in ``. ## `lib.strings.hasInfix` {#function-library-lib.strings.hasInfix} -`hasInfix :: string -> string -> bool` +**Type**: `hasInfix :: string -> string -> bool` Determine whether a string contains the given infix @@ -367,7 +431,8 @@ Determine whether a string contains the given infix : Function argument -### lib.strings.hasInfix usage example {#function-library-example-lib.strings.hasInfix} +::: {.example #function-library-example-lib.strings.hasInfix} +# `lib.strings.hasInfix` usage example ```nix hasInfix "bc" "abcd" @@ -379,10 +444,13 @@ hasInfix "cd" "abcd" hasInfix "foo" "abcd" => false ``` +::: + +Located at [lib/strings.nix:317](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L317) in ``. ## `lib.strings.stringToCharacters` {#function-library-lib.strings.stringToCharacters} -`stringToCharacters :: string -> [string]` +**Type**: `stringToCharacters :: string -> [string]` Convert a string to a list of characters (i.e. singleton strings). This allows you to, e.g., map a function over each character. However, @@ -397,7 +465,8 @@ handle unicode. : Function argument -### lib.strings.stringToCharacters usage example {#function-library-example-lib.strings.stringToCharacters} +::: {.example #function-library-example-lib.strings.stringToCharacters} +# `lib.strings.stringToCharacters` usage example ```nix stringToCharacters "" @@ -407,10 +476,13 @@ stringToCharacters "abc" stringToCharacters "🦄" => [ "�" "�" "�" "�" ] ``` +::: + +Located at [lib/strings.nix:347](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L347) in ``. ## `lib.strings.stringAsChars` {#function-library-lib.strings.stringAsChars} -`stringAsChars :: (string -> string) -> string -> string` +**Type**: `stringAsChars :: (string -> string) -> string -> string` Manipulate a string character by character and replace them by strings before concatenating the results. @@ -425,16 +497,20 @@ strings before concatenating the results. : Input string -### lib.strings.stringAsChars usage example {#function-library-example-lib.strings.stringAsChars} +::: {.example #function-library-example-lib.strings.stringAsChars} +# `lib.strings.stringAsChars` usage example ```nix stringAsChars (x: if x == "a" then "i" else x) "nax" => "nix" ``` +::: + +Located at [lib/strings.nix:359](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L359) in ``. ## `lib.strings.charToInt` {#function-library-lib.strings.charToInt} -`charToInt :: string -> int` +**Type**: `charToInt :: string -> int` Convert char to ascii value, must be in printable range @@ -443,7 +519,8 @@ Convert char to ascii value, must be in printable range : Function argument -### lib.strings.charToInt usage example {#function-library-example-lib.strings.charToInt} +::: {.example #function-library-example-lib.strings.charToInt} +# `lib.strings.charToInt` usage example ```nix charToInt "A" @@ -451,10 +528,13 @@ charToInt "A" charToInt "(" => 40 ``` +::: + +Located at [lib/strings.nix:378](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L378) in ``. ## `lib.strings.escape` {#function-library-lib.strings.escape} -`escape :: [string] -> string -> string` +**Type**: `escape :: [string] -> string -> string` Escape occurrence of the elements of `list` in `string` by prefixing it with a backslash. @@ -464,16 +544,20 @@ prefixing it with a backslash. : Function argument -### lib.strings.escape usage example {#function-library-example-lib.strings.escape} +::: {.example #function-library-example-lib.strings.escape} +# `lib.strings.escape` usage example ```nix escape ["(" ")"] "(foo)" => "\\(foo\\)" ``` +::: + +Located at [lib/strings.nix:389](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L389) in ``. ## `lib.strings.escapeC` {#function-library-lib.strings.escapeC} -`escapeC = [string] -> string -> string` +**Type**: `escapeC = [string] -> string -> string` Escape occurrence of the element of `list` in `string` by converting to its ASCII value and prefixing it with \\x. @@ -484,30 +568,38 @@ Only works for printable ascii characters. : Function argument -### lib.strings.escapeC usage example {#function-library-example-lib.strings.escapeC} +::: {.example #function-library-example-lib.strings.escapeC} +# `lib.strings.escapeC` usage example ```nix escapeC [" "] "foo bar" => "foo\\x20bar" ``` +::: + +Located at [lib/strings.nix:402](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L402) in ``. ## `lib.strings.escapeURL` {#function-library-lib.strings.escapeURL} -`escapeURL :: string -> string` +**Type**: `escapeURL :: string -> string` Escape the string so it can be safely placed inside a URL query. -### lib.strings.escapeURL usage example {#function-library-example-lib.strings.escapeURL} +::: {.example #function-library-example-lib.strings.escapeURL} +# `lib.strings.escapeURL` usage example ```nix escapeURL "foo/bar baz" => "foo%2Fbar%20baz" ``` +::: + +Located at [lib/strings.nix:413](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L413) in ``. ## `lib.strings.escapeShellArg` {#function-library-lib.strings.escapeShellArg} -`escapeShellArg :: string -> string` +**Type**: `escapeShellArg :: string -> string` Quote string to be used safely within the Bourne shell. @@ -516,29 +608,37 @@ Quote string to be used safely within the Bourne shell. : Function argument -### lib.strings.escapeShellArg usage example {#function-library-example-lib.strings.escapeShellArg} +::: {.example #function-library-example-lib.strings.escapeShellArg} +# `lib.strings.escapeShellArg` usage example ```nix escapeShellArg "esc'ape\nme" => "'esc'\\''ape\nme'" ``` +::: + +Located at [lib/strings.nix:427](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L427) in ``. ## `lib.strings.escapeShellArgs` {#function-library-lib.strings.escapeShellArgs} -`escapeShellArgs :: [string] -> string` +**Type**: `escapeShellArgs :: [string] -> string` Quote all arguments to be safely passed to the Bourne shell. -### lib.strings.escapeShellArgs usage example {#function-library-example-lib.strings.escapeShellArgs} +::: {.example #function-library-example-lib.strings.escapeShellArgs} +# `lib.strings.escapeShellArgs` usage example ```nix escapeShellArgs ["one" "two three" "four'five"] => "'one' 'two three' 'four'\\''five'" ``` +::: + +Located at [lib/strings.nix:437](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L437) in ``. ## `lib.strings.isValidPosixName` {#function-library-lib.strings.isValidPosixName} -`string -> bool` +**Type**: `string -> bool` Test whether the given name is a valid POSIX shell variable name. @@ -547,7 +647,8 @@ Test whether the given name is a valid POSIX shell variable name. : Function argument -### lib.strings.isValidPosixName usage example {#function-library-example-lib.strings.isValidPosixName} +::: {.example #function-library-example-lib.strings.isValidPosixName} +# `lib.strings.isValidPosixName` usage example ```nix isValidPosixName "foo_bar000" @@ -555,10 +656,13 @@ isValidPosixName "foo_bar000" isValidPosixName "0-bad.jpg" => false ``` +::: + +Located at [lib/strings.nix:449](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L449) in ``. ## `lib.strings.toShellVar` {#function-library-lib.strings.toShellVar} -`string -> (string | listOf string | attrsOf string) -> string` +**Type**: `string -> (string | listOf string | attrsOf string) -> string` Translate a Nix value into a shell variable declaration, with proper escaping. @@ -580,7 +684,8 @@ assume a shell that understands Bash syntax (e.g. Bash or ZSH). : Function argument -### lib.strings.toShellVar usage example {#function-library-example-lib.strings.toShellVar} +::: {.example #function-library-example-lib.strings.toShellVar} +# `lib.strings.toShellVar` usage example ```nix '' @@ -588,10 +693,13 @@ ${toShellVar "foo" "some string"} [[ "$foo" == "some string" ]] '' ``` +::: + +Located at [lib/strings.nix:469](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L469) in ``. ## `lib.strings.toShellVars` {#function-library-lib.strings.toShellVars} -`attrsOf (string | listOf string | attrsOf string) -> string` +**Type**: `attrsOf (string | listOf string | attrsOf string) -> string` Translate an attribute set into corresponding shell variable declarations using `toShellVar`. @@ -601,7 +709,8 @@ using `toShellVar`. : Function argument -### lib.strings.toShellVars usage example {#function-library-example-lib.strings.toShellVars} +::: {.example #function-library-example-lib.strings.toShellVars} +# `lib.strings.toShellVars` usage example ```nix let @@ -612,10 +721,13 @@ ${toShellVars { inherit foo bar; }} [[ "$foo" == "$bar" ]] '' ``` +::: + +Located at [lib/strings.nix:497](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L497) in ``. ## `lib.strings.escapeNixString` {#function-library-lib.strings.escapeNixString} -`string -> string` +**Type**: `string -> string` Turn a string into a Nix expression representing that string @@ -624,29 +736,37 @@ Turn a string into a Nix expression representing that string : Function argument -### lib.strings.escapeNixString usage example {#function-library-example-lib.strings.escapeNixString} +::: {.example #function-library-example-lib.strings.escapeNixString} +# `lib.strings.escapeNixString` usage example ```nix escapeNixString "hello\${}\n" => "\"hello\\\${}\\n\"" ``` +::: + +Located at [lib/strings.nix:507](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L507) in ``. ## `lib.strings.escapeRegex` {#function-library-lib.strings.escapeRegex} -`string -> string` +**Type**: `string -> string` Turn a string into an exact regular expression -### lib.strings.escapeRegex usage example {#function-library-example-lib.strings.escapeRegex} +::: {.example #function-library-example-lib.strings.escapeRegex} +# `lib.strings.escapeRegex` usage example ```nix escapeRegex "[^a-z]*" => "\\[\\^a-z]\\*" ``` +::: + +Located at [lib/strings.nix:517](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L517) in ``. ## `lib.strings.escapeNixIdentifier` {#function-library-lib.strings.escapeNixIdentifier} -`string -> string` +**Type**: `string -> string` Quotes a string if it can't be used as an identifier directly. @@ -655,7 +775,8 @@ Quotes a string if it can't be used as an identifier directly. : Function argument -### lib.strings.escapeNixIdentifier usage example {#function-library-example-lib.strings.escapeNixIdentifier} +::: {.example #function-library-example-lib.strings.escapeNixIdentifier} +# `lib.strings.escapeNixIdentifier` usage example ```nix escapeNixIdentifier "hello" @@ -663,54 +784,61 @@ escapeNixIdentifier "hello" escapeNixIdentifier "0abc" => "\"0abc\"" ``` +::: + +Located at [lib/strings.nix:529](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L529) in ``. ## `lib.strings.escapeXML` {#function-library-lib.strings.escapeXML} -`string -> string` +**Type**: `string -> string` Escapes a string such that it is safe to include verbatim in an XML document. -### lib.strings.escapeXML usage example {#function-library-example-lib.strings.escapeXML} +::: {.example #function-library-example-lib.strings.escapeXML} +# `lib.strings.escapeXML` usage example ```nix escapeXML ''"test" 'test' < & >'' => ""test" 'test' < & >" ``` +::: -## `lib.strings.replaceChars` {#function-library-lib.strings.replaceChars} - -warning added 12-12-2022 - -## `lib.strings.lowerChars` {#function-library-lib.strings.lowerChars} - -Case conversion utilities. +Located at [lib/strings.nix:543](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L543) in ``. ## `lib.strings.toLower` {#function-library-lib.strings.toLower} -`toLower :: string -> string` +**Type**: `toLower :: string -> string` Converts an ASCII string to lower-case. -### lib.strings.toLower usage example {#function-library-example-lib.strings.toLower} +::: {.example #function-library-example-lib.strings.toLower} +# `lib.strings.toLower` usage example ```nix toLower "HOME" => "home" ``` +::: + +Located at [lib/strings.nix:562](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L562) in ``. ## `lib.strings.toUpper` {#function-library-lib.strings.toUpper} -`toUpper :: string -> string` +**Type**: `toUpper :: string -> string` Converts an ASCII string to upper-case. -### lib.strings.toUpper usage example {#function-library-example-lib.strings.toUpper} +::: {.example #function-library-example-lib.strings.toUpper} +# `lib.strings.toUpper` usage example ```nix toUpper "home" => "HOME" ``` +::: + +Located at [lib/strings.nix:572](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L572) in ``. ## `lib.strings.addContextFrom` {#function-library-lib.strings.addContextFrom} @@ -732,13 +860,17 @@ inputSrcs. : Function argument -### lib.strings.addContextFrom usage example {#function-library-example-lib.strings.addContextFrom} +::: {.example #function-library-example-lib.strings.addContextFrom} +# `lib.strings.addContextFrom` usage example ```nix pkgs = import { }; addContextFrom pkgs.coreutils "bar" => "bar" ``` +::: + +Located at [lib/strings.nix:587](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L587) in ``. ## `lib.strings.splitString` {#function-library-lib.strings.splitString} @@ -755,7 +887,8 @@ were separated by this separator. : Function argument -### lib.strings.splitString usage example {#function-library-example-lib.strings.splitString} +::: {.example #function-library-example-lib.strings.splitString} +# `lib.strings.splitString` usage example ```nix splitString "." "foo.bar.baz" @@ -763,10 +896,13 @@ splitString "." "foo.bar.baz" splitString "/" "/usr/local/bin" => [ "" "usr" "local" "bin" ] ``` +::: + +Located at [lib/strings.nix:598](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L598) in ``. ## `lib.strings.removePrefix` {#function-library-lib.strings.removePrefix} -`string -> string -> string` +**Type**: `string -> string -> string` Return a string without the specified prefix, if the prefix matches. @@ -780,7 +916,8 @@ Return a string without the specified prefix, if the prefix matches. : Input string -### lib.strings.removePrefix usage example {#function-library-example-lib.strings.removePrefix} +::: {.example #function-library-example-lib.strings.removePrefix} +# `lib.strings.removePrefix` usage example ```nix removePrefix "foo." "foo.bar.baz" @@ -788,10 +925,13 @@ removePrefix "foo." "foo.bar.baz" removePrefix "xxx" "foo.bar.baz" => "foo.bar.baz" ``` +::: + +Located at [lib/strings.nix:614](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L614) in ``. ## `lib.strings.removeSuffix` {#function-library-lib.strings.removeSuffix} -`string -> string -> string` +**Type**: `string -> string -> string` Return a string without the specified suffix, if the suffix matches. @@ -805,7 +945,8 @@ Return a string without the specified suffix, if the suffix matches. : Input string -### lib.strings.removeSuffix usage example {#function-library-example-lib.strings.removeSuffix} +::: {.example #function-library-example-lib.strings.removeSuffix} +# `lib.strings.removeSuffix` usage example ```nix removeSuffix "front" "homefront" @@ -813,6 +954,9 @@ removeSuffix "front" "homefront" removeSuffix "xxx" "homefront" => "homefront" ``` +::: + +Located at [lib/strings.nix:647](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L647) in ``. ## `lib.strings.versionOlder` {#function-library-lib.strings.versionOlder} @@ -828,7 +972,8 @@ Return true if string v1 denotes a version older than v2. : Function argument -### lib.strings.versionOlder usage example {#function-library-example-lib.strings.versionOlder} +::: {.example #function-library-example-lib.strings.versionOlder} +# `lib.strings.versionOlder` usage example ```nix versionOlder "1.1" "1.2" @@ -836,6 +981,9 @@ versionOlder "1.1" "1.2" versionOlder "1.1" "1.1" => false ``` +::: + +Located at [lib/strings.nix:678](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L678) in ``. ## `lib.strings.versionAtLeast` {#function-library-lib.strings.versionAtLeast} @@ -851,7 +999,8 @@ Return true if string v1 denotes a version equal to or newer than v2. : Function argument -### lib.strings.versionAtLeast usage example {#function-library-example-lib.strings.versionAtLeast} +::: {.example #function-library-example-lib.strings.versionAtLeast} +# `lib.strings.versionAtLeast` usage example ```nix versionAtLeast "1.1" "1.0" @@ -861,6 +1010,9 @@ versionAtLeast "1.1" "1.1" versionAtLeast "1.1" "1.2" => false ``` +::: + +Located at [lib/strings.nix:690](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L690) in ``. ## `lib.strings.getName` {#function-library-lib.strings.getName} @@ -873,7 +1025,8 @@ argument. : Function argument -### lib.strings.getName usage example {#function-library-example-lib.strings.getName} +::: {.example #function-library-example-lib.strings.getName} +# `lib.strings.getName` usage example ```nix getName "youtube-dl-2016.01.01" @@ -881,6 +1034,9 @@ getName "youtube-dl-2016.01.01" getName pkgs.youtube-dl => "youtube-dl" ``` +::: + +Located at [lib/strings.nix:702](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L702) in ``. ## `lib.strings.getVersion` {#function-library-lib.strings.getVersion} @@ -893,7 +1049,8 @@ argument. : Function argument -### lib.strings.getVersion usage example {#function-library-example-lib.strings.getVersion} +::: {.example #function-library-example-lib.strings.getVersion} +# `lib.strings.getVersion` usage example ```nix getVersion "youtube-dl-2016.01.01" @@ -901,6 +1058,9 @@ getVersion "youtube-dl-2016.01.01" getVersion pkgs.youtube-dl => "2016.01.01" ``` +::: + +Located at [lib/strings.nix:719](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L719) in ``. ## `lib.strings.nameFromURL` {#function-library-lib.strings.nameFromURL} @@ -917,7 +1077,8 @@ supposed to start extension. : Function argument -### lib.strings.nameFromURL usage example {#function-library-example-lib.strings.nameFromURL} +::: {.example #function-library-example-lib.strings.nameFromURL} +# `lib.strings.nameFromURL` usage example ```nix nameFromURL "https://nixos.org/releases/nix/nix-1.7/nix-1.7-x86_64-linux.tar.bz2" "-" @@ -925,10 +1086,13 @@ nameFromURL "https://nixos.org/releases/nix/nix-1.7/nix-1.7-x86_64-linux.tar.bz2 nameFromURL "https://nixos.org/releases/nix/nix-1.7/nix-1.7-x86_64-linux.tar.bz2" "_" => "nix-1.7-x86" ``` +::: + +Located at [lib/strings.nix:735](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L735) in ``. ## `lib.strings.mesonOption` {#function-library-lib.strings.mesonOption} -`mesonOption :: string -> string -> string@param feature The feature to be set@param value The desired value` +**Type**: `mesonOption :: string -> string -> string@param feature The feature to be set@param value The desired value` Create a -D= string that can be passed to typical Meson invocations. @@ -943,16 +1107,20 @@ invocations. : Function argument -### lib.strings.mesonOption usage example {#function-library-example-lib.strings.mesonOption} +::: {.example #function-library-example-lib.strings.mesonOption} +# `lib.strings.mesonOption` usage example ```nix mesonOption "engine" "opengl" => "-Dengine=opengl" ``` +::: + +Located at [lib/strings.nix:754](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L754) in ``. ## `lib.strings.mesonBool` {#function-library-lib.strings.mesonBool} -`mesonBool :: string -> bool -> string@param condition The condition to be made true or false@param flag The controlling flag of the condition` +**Type**: `mesonBool :: string -> bool -> string@param condition The condition to be made true or false@param flag The controlling flag of the condition` Create a -D={true,false} string that can be passed to typical Meson invocations. @@ -967,7 +1135,8 @@ Meson invocations. : Function argument -### lib.strings.mesonBool usage example {#function-library-example-lib.strings.mesonBool} +::: {.example #function-library-example-lib.strings.mesonBool} +# `lib.strings.mesonBool` usage example ```nix mesonBool "hardened" true @@ -975,10 +1144,13 @@ mesonBool "hardened" true mesonBool "static" false => "-Dstatic=false" ``` +::: + +Located at [lib/strings.nix:773](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L773) in ``. ## `lib.strings.mesonEnable` {#function-library-lib.strings.mesonEnable} -`mesonEnable :: string -> bool -> string@param feature The feature to be enabled or disabled@param flag The controlling flag` +**Type**: `mesonEnable :: string -> bool -> string@param feature The feature to be enabled or disabled@param flag The controlling flag` Create a -D={enabled,disabled} string that can be passed to typical Meson invocations. @@ -993,7 +1165,8 @@ typical Meson invocations. : Function argument -### lib.strings.mesonEnable usage example {#function-library-example-lib.strings.mesonEnable} +::: {.example #function-library-example-lib.strings.mesonEnable} +# `lib.strings.mesonEnable` usage example ```nix mesonEnable "docs" true @@ -1001,6 +1174,9 @@ mesonEnable "docs" true mesonEnable "savage" false => "-Dsavage=disabled" ``` +::: + +Located at [lib/strings.nix:792](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L792) in ``. ## `lib.strings.enableFeature` {#function-library-lib.strings.enableFeature} @@ -1017,7 +1193,8 @@ standard GNU Autoconf scripts. : Function argument -### lib.strings.enableFeature usage example {#function-library-example-lib.strings.enableFeature} +::: {.example #function-library-example-lib.strings.enableFeature} +# `lib.strings.enableFeature` usage example ```nix enableFeature true "shared" @@ -1025,6 +1202,9 @@ enableFeature true "shared" enableFeature false "shared" => "--disable-shared" ``` +::: + +Located at [lib/strings.nix:806](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L806) in ``. ## `lib.strings.enableFeatureAs` {#function-library-lib.strings.enableFeatureAs} @@ -1046,7 +1226,8 @@ standard GNU Autoconf scripts. : Function argument -### lib.strings.enableFeatureAs usage example {#function-library-example-lib.strings.enableFeatureAs} +::: {.example #function-library-example-lib.strings.enableFeatureAs} +# `lib.strings.enableFeatureAs` usage example ```nix enableFeatureAs true "shared" "foo" @@ -1054,6 +1235,9 @@ enableFeatureAs true "shared" "foo" enableFeatureAs false "shared" (throw "ignored") => "--disable-shared" ``` +::: + +Located at [lib/strings.nix:819](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L819) in ``. ## `lib.strings.withFeature` {#function-library-lib.strings.withFeature} @@ -1070,7 +1254,8 @@ standard GNU Autoconf scripts. : Function argument -### lib.strings.withFeature usage example {#function-library-example-lib.strings.withFeature} +::: {.example #function-library-example-lib.strings.withFeature} +# `lib.strings.withFeature` usage example ```nix withFeature true "shared" @@ -1078,6 +1263,9 @@ withFeature true "shared" withFeature false "shared" => "--without-shared" ``` +::: + +Located at [lib/strings.nix:830](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L830) in ``. ## `lib.strings.withFeatureAs` {#function-library-lib.strings.withFeatureAs} @@ -1099,7 +1287,8 @@ standard GNU Autoconf scripts. : Function argument -### lib.strings.withFeatureAs usage example {#function-library-example-lib.strings.withFeatureAs} +::: {.example #function-library-example-lib.strings.withFeatureAs} +# `lib.strings.withFeatureAs` usage example ```nix withFeatureAs true "shared" "foo" @@ -1107,10 +1296,13 @@ withFeatureAs true "shared" "foo" withFeatureAs false "shared" (throw "ignored") => "--without-shared" ``` +::: + +Located at [lib/strings.nix:843](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L843) in ``. ## `lib.strings.fixedWidthString` {#function-library-lib.strings.fixedWidthString} -`fixedWidthString :: int -> string -> string -> string` +**Type**: `fixedWidthString :: int -> string -> string -> string` Create a fixed width string with additional prefix to match required width. @@ -1133,12 +1325,16 @@ requested length. : Function argument -### lib.strings.fixedWidthString usage example {#function-library-example-lib.strings.fixedWidthString} +::: {.example #function-library-example-lib.strings.fixedWidthString} +# `lib.strings.fixedWidthString` usage example ```nix fixedWidthString 5 "0" (toString 15) => "00015" ``` +::: + +Located at [lib/strings.nix:857](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L857) in ``. ## `lib.strings.fixedWidthNumber` {#function-library-lib.strings.fixedWidthNumber} @@ -1154,12 +1350,16 @@ Format a number adding leading zeroes up to fixed width. : Function argument -### lib.strings.fixedWidthNumber usage example {#function-library-example-lib.strings.fixedWidthNumber} +::: {.example #function-library-example-lib.strings.fixedWidthNumber} +# `lib.strings.fixedWidthNumber` usage example ```nix fixedWidthNumber 5 15 => "00015" ``` +::: + +Located at [lib/strings.nix:874](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L874) in ``. ## `lib.strings.floatToString` {#function-library-lib.strings.floatToString} @@ -1171,7 +1371,8 @@ during the conversion : Function argument -### lib.strings.floatToString usage example {#function-library-example-lib.strings.floatToString} +::: {.example #function-library-example-lib.strings.floatToString} +# `lib.strings.floatToString` usage example ```nix floatToString 0.000001 @@ -1180,12 +1381,17 @@ floatToString 0.0000001 => trace: warning: Imprecise conversion from float to string 0.000000 "0.000000" ``` +::: + +Located at [lib/strings.nix:886](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L886) in ``. ## `lib.strings.isCoercibleToString` {#function-library-lib.strings.isCoercibleToString} Soft-deprecated function. While the original implementation is available as isConvertibleWithToString, consider using isStringLike instead, if suitable. +Located at [lib/strings.nix:894](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L894) in ``. + ## `lib.strings.isConvertibleWithToString` {#function-library-lib.strings.isConvertibleWithToString} Check whether a list or other value can be passed to toString. @@ -1198,6 +1404,8 @@ null, bool, list of similarly coercible values. : Function argument +Located at [lib/strings.nix:903](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L903) in ``. + ## `lib.strings.isStringLike` {#function-library-lib.strings.isStringLike} Check whether a value can be coerced to a string. @@ -1211,6 +1419,8 @@ string interpolations and in most functions that expect a string. : Function argument +Located at [lib/strings.nix:914](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L914) in ``. + ## `lib.strings.isStorePath` {#function-library-lib.strings.isStorePath} Check whether a value is a store path. @@ -1220,7 +1430,8 @@ Check whether a value is a store path. : Function argument -### lib.strings.isStorePath usage example {#function-library-example-lib.strings.isStorePath} +::: {.example #function-library-example-lib.strings.isStorePath} +# `lib.strings.isStorePath` usage example ```nix isStorePath "/nix/store/d945ibfx9x185xf04b890y4f9g3cbb63-python-2.7.11/bin/python" @@ -1232,10 +1443,13 @@ isStorePath pkgs.python isStorePath [] || isStorePath 42 || isStorePath {} || … => false ``` +::: + +Located at [lib/strings.nix:932](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L932) in ``. ## `lib.strings.toInt` {#function-library-lib.strings.toInt} -`string -> int` +**Type**: `string -> int` Parse a string as an int. Does not support parsing of integers with preceding zero due to ambiguity between zero-padded and octal numbers. See toIntBase10. @@ -1245,10 +1459,10 @@ ambiguity between zero-padded and octal numbers. See toIntBase10. : Function argument -### lib.strings.toInt usage example {#function-library-example-lib.strings.toInt} +::: {.example #function-library-example-lib.strings.toInt} +# `lib.strings.toInt` usage example ```nix - toInt "1337" => 1337 @@ -1264,10 +1478,13 @@ toInt "00024" toInt "3.14" => error: floating point JSON numbers are not supported ``` +::: + +Located at [lib/strings.nix:962](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L962) in ``. ## `lib.strings.toIntBase10` {#function-library-lib.strings.toIntBase10} -`string -> int` +**Type**: `string -> int` Parse a string as a base 10 int. This supports parsing of zero-padded integers. @@ -1276,7 +1493,8 @@ Parse a string as a base 10 int. This supports parsing of zero-padded integers. : Function argument -### lib.strings.toIntBase10 usage example {#function-library-example-lib.strings.toIntBase10} +::: {.example #function-library-example-lib.strings.toIntBase10} +# `lib.strings.toIntBase10` usage example ```nix toIntBase10 "1337" @@ -1294,6 +1512,9 @@ toIntBase10 "00024" toIntBase10 "3.14" => error: floating point JSON numbers are not supported ``` +::: + +Located at [lib/strings.nix:1013](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L1013) in ``. ## `lib.strings.readPathsFromFile` {#function-library-lib.strings.readPathsFromFile} @@ -1303,7 +1524,8 @@ Whitespace is significant. NOTE: This function is not performant and should be avoided. -### lib.strings.readPathsFromFile usage example {#function-library-example-lib.strings.readPathsFromFile} +::: {.example #function-library-example-lib.strings.readPathsFromFile} +# `lib.strings.readPathsFromFile` usage example ```nix readPathsFromFile /prefix @@ -1314,10 +1536,13 @@ readPathsFromFile /prefix "/prefix/nix-profiles-library-paths.patch" "/prefix/compose-search-path.patch" ] ``` +::: + +Located at [lib/strings.nix:1056](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L1056) in ``. ## `lib.strings.fileContents` {#function-library-lib.strings.fileContents} -`fileContents :: path -> string` +**Type**: `fileContents :: path -> string` Read the contents of a file removing the trailing \n @@ -1326,7 +1551,8 @@ Read the contents of a file removing the trailing \n : Function argument -### lib.strings.fileContents usage example {#function-library-example-lib.strings.fileContents} +::: {.example #function-library-example-lib.strings.fileContents} +# `lib.strings.fileContents` usage example ```nix $ echo "1.0" > ./version @@ -1334,14 +1560,18 @@ $ echo "1.0" > ./version fileContents ./version => "1.0" ``` +::: + +Located at [lib/strings.nix:1076](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L1076) in ``. ## `lib.strings.sanitizeDerivationName` {#function-library-lib.strings.sanitizeDerivationName} -`sanitizeDerivationName :: String -> String` +**Type**: `sanitizeDerivationName :: String -> String` Creates a valid derivation name from a potentially invalid one. -### lib.strings.sanitizeDerivationName usage example {#function-library-example-lib.strings.sanitizeDerivationName} +::: {.example #function-library-example-lib.strings.sanitizeDerivationName} +# `lib.strings.sanitizeDerivationName` usage example ```nix sanitizeDerivationName "../hello.bar # foo" @@ -1351,10 +1581,13 @@ sanitizeDerivationName "" sanitizeDerivationName pkgs.hello => "-nix-store-2g75chlbpxlrqn15zlby2dfh8hr9qwbk-hello-2.10" ``` +::: + +Located at [lib/strings.nix:1091](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L1091) in ``. ## `lib.strings.levenshtein` {#function-library-lib.strings.levenshtein} -`levenshtein :: string -> string -> int` +**Type**: `levenshtein :: string -> string -> int` Computes the Levenshtein distance between two strings. Complexity O(n*m) where n and m are the lengths of the strings. @@ -1370,7 +1603,8 @@ Algorithm adjusted from https://stackoverflow.com/a/9750974/6605742 : Function argument -### lib.strings.levenshtein usage example {#function-library-example-lib.strings.levenshtein} +::: {.example #function-library-example-lib.strings.levenshtein} +# `lib.strings.levenshtein` usage example ```nix levenshtein "foo" "foo" @@ -1380,6 +1614,9 @@ levenshtein "book" "hook" levenshtein "hello" "Heyo" => 3 ``` +::: + +Located at [lib/strings.nix:1130](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L1130) in ``. ## `lib.strings.commonPrefixLength` {#function-library-lib.strings.commonPrefixLength} @@ -1395,6 +1632,8 @@ Returns the length of the prefix common to both strings. : Function argument +Located at [lib/strings.nix:1151](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L1151) in ``. + ## `lib.strings.commonSuffixLength` {#function-library-lib.strings.commonSuffixLength} Returns the length of the suffix common to both strings. @@ -1409,14 +1648,17 @@ Returns the length of the suffix common to both strings. : Function argument +Located at [lib/strings.nix:1159](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L1159) in ``. + ## `lib.strings.levenshteinAtMost` {#function-library-lib.strings.levenshteinAtMost} -`levenshteinAtMost :: int -> string -> string -> bool` +**Type**: `levenshteinAtMost :: int -> string -> string -> bool` Returns whether the levenshtein distance between two strings is at most some value Complexity is O(min(n,m)) for k <= 2 and O(n*m) otherwise -### lib.strings.levenshteinAtMost usage example {#function-library-example-lib.strings.levenshteinAtMost} +::: {.example #function-library-example-lib.strings.levenshteinAtMost} +# `lib.strings.levenshteinAtMost` usage example ```nix levenshteinAtMost 0 "foo" "foo" @@ -1430,5 +1672,8 @@ levenshteinAtMost 2 "This is a sentence" "this is a sentense." levenshteinAtMost 3 "This is a sentence" "this is a sentense." => true ``` +::: + +Located at [lib/strings.nix:1183](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L1183) in ``. diff --git a/test/arg-formatting.nix b/test/arg-formatting.nix new file mode 100644 index 0000000..1c3c337 --- /dev/null +++ b/test/arg-formatting.nix @@ -0,0 +1,14 @@ +{ + /* documented function */ + fn = + # single arugment + a: + # set argument + { + # documented argument + default ? null, + # i like this argument. another! + example ? null + } @ args: + 0; +} diff --git a/test/inherited-exports.nix b/test/inherited-exports.nix new file mode 100644 index 0000000..64e457a --- /dev/null +++ b/test/inherited-exports.nix @@ -0,0 +1,31 @@ +{ lib }: + +let + /* Concatenate a list of strings. + + Type: concatStrings :: [string] -> string + + Example: + concatStrings ["foo" "bar"] + => "foobar" + */ + concatStrings = builtins.concatStringsSep ""; + + /* this should be ignored because it's inherited from an explicit source */ + from = a: a; +in { + inherit concatStrings; + inherit ({}) from; + + foo1 = { + /* this should be ignored because it's in a nested attrset */ + bar = a: a; + }; + + /* this should be found */ + foo2 = + let + /* this should be ignored because it's in a nested let */ + bar = a: a; + in bar; +} diff --git a/test/line-comments.nix b/test/line-comments.nix new file mode 100644 index 0000000..2d7378e --- /dev/null +++ b/test/line-comments.nix @@ -0,0 +1,15 @@ +{ + # not a doc comment + hidden = a: a; + + /* is a doc comment */ + shown = + # a doc comment + a: + /* also a doc comment */ + b: + # a doc comment + # with continuation + c: + {}; +} diff --git a/test/strings.json b/test/strings.json new file mode 100644 index 0000000..c34081a --- /dev/null +++ b/test/strings.json @@ -0,0 +1,94 @@ +{ + "lib.strings.addContextFrom": "[lib/strings.nix:587](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L587) in ``", + "lib.strings.charToInt": "[lib/strings.nix:378](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L378) in ``", + "lib.strings.commonPrefixLength": "[lib/strings.nix:1151](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L1151) in ``", + "lib.strings.commonSuffixLength": "[lib/strings.nix:1159](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L1159) in ``", + "lib.strings.compareVersions": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.concatImapStrings": "[lib/strings.nix:70](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L70) in ``", + "lib.strings.concatImapStringsSep": "[lib/strings.nix:127](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L127) in ``", + "lib.strings.concatLines": "[lib/strings.nix:144](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L144) in ``", + "lib.strings.concatMapStrings": "[lib/strings.nix:59](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L59) in ``", + "lib.strings.concatMapStringsSep": "[lib/strings.nix:110](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L110) in ``", + "lib.strings.concatStrings": "[lib/strings.nix:49](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L49) in ``", + "lib.strings.concatStringsSep": "[lib/strings.nix:97](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L97) in ``", + "lib.strings.elem": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.elemAt": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.enableFeature": "[lib/strings.nix:806](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L806) in ``", + "lib.strings.enableFeatureAs": "[lib/strings.nix:819](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L819) in ``", + "lib.strings.escape": "[lib/strings.nix:389](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L389) in ``", + "lib.strings.escapeC": "[lib/strings.nix:402](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L402) in ``", + "lib.strings.escapeNixIdentifier": "[lib/strings.nix:529](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L529) in ``", + "lib.strings.escapeNixString": "[lib/strings.nix:507](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L507) in ``", + "lib.strings.escapeRegex": "[lib/strings.nix:517](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L517) in ``", + "lib.strings.escapeShellArg": "[lib/strings.nix:427](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L427) in ``", + "lib.strings.escapeShellArgs": "[lib/strings.nix:437](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L437) in ``", + "lib.strings.escapeURL": "[lib/strings.nix:413](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L413) in ``", + "lib.strings.escapeXML": "[lib/strings.nix:543](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L543) in ``", + "lib.strings.fileContents": "[lib/strings.nix:1076](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L1076) in ``", + "lib.strings.filter": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.fixedWidthNumber": "[lib/strings.nix:874](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L874) in ``", + "lib.strings.fixedWidthString": "[lib/strings.nix:857](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L857) in ``", + "lib.strings.floatToString": "[lib/strings.nix:886](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L886) in ``", + "lib.strings.fromJSON": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.getName": "[lib/strings.nix:702](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L702) in ``", + "lib.strings.getVersion": "[lib/strings.nix:719](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L719) in ``", + "lib.strings.hasInfix": "[lib/strings.nix:317](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L317) in ``", + "lib.strings.hasPrefix": "[lib/strings.nix:254](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L254) in ``", + "lib.strings.hasSuffix": "[lib/strings.nix:280](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L280) in ``", + "lib.strings.head": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.intersperse": "[lib/strings.nix:80](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L80) in ``", + "lib.strings.isAttrs": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.isCoercibleToString": "[lib/strings.nix:894](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L894) in ``", + "lib.strings.isConvertibleWithToString": "[lib/strings.nix:903](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L903) in ``", + "lib.strings.isInt": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.isList": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.isPath": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.isStorePath": "[lib/strings.nix:932](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L932) in ``", + "lib.strings.isString": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.isStringLike": "[lib/strings.nix:914](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L914) in ``", + "lib.strings.isValidPosixName": "[lib/strings.nix:449](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L449) in ``", + "lib.strings.levenshtein": "[lib/strings.nix:1130](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L1130) in ``", + "lib.strings.levenshteinAtMost": "[lib/strings.nix:1183](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L1183) in ``", + "lib.strings.lowerChars": "[lib/strings.nix:551](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L551) in ``", + "lib.strings.makeBinPath": "[lib/strings.nix:202](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L202) in ``", + "lib.strings.makeLibraryPath": "[lib/strings.nix:193](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L193) in ``", + "lib.strings.makeSearchPath": "[lib/strings.nix:157](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L157) in ``", + "lib.strings.makeSearchPathOutput": "[lib/strings.nix:175](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L175) in ``", + "lib.strings.match": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.mesonBool": "[lib/strings.nix:773](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L773) in ``", + "lib.strings.mesonEnable": "[lib/strings.nix:792](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L792) in ``", + "lib.strings.mesonOption": "[lib/strings.nix:754](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L754) in ``", + "lib.strings.nameFromURL": "[lib/strings.nix:735](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L735) in ``", + "lib.strings.normalizePath": "[lib/strings.nix:212](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L212) in ``", + "lib.strings.optionalString": "[lib/strings.nix:238](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L238) in ``", + "lib.strings.parseDrvName": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.readFile": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.readPathsFromFile": "[lib/strings.nix:1056](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L1056) in ``", + "lib.strings.removePrefix": "[lib/strings.nix:614](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L614) in ``", + "lib.strings.removeSuffix": "[lib/strings.nix:647](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L647) in ``", + "lib.strings.replaceChars": "[lib/strings.nix:548](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L548) in ``", + "lib.strings.replaceStrings": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.sanitizeDerivationName": "[lib/strings.nix:1091](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L1091) in ``", + "lib.strings.split": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.splitString": "[lib/strings.nix:598](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L598) in ``", + "lib.strings.storeDir": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.stringAsChars": "[lib/strings.nix:359](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L359) in ``", + "lib.strings.stringLength": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.stringToCharacters": "[lib/strings.nix:347](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L347) in ``", + "lib.strings.substring": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.tail": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.toInt": "[lib/strings.nix:962](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L962) in ``", + "lib.strings.toIntBase10": "[lib/strings.nix:1013](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L1013) in ``", + "lib.strings.toJSON": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.toLower": "[lib/strings.nix:562](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L562) in ``", + "lib.strings.toShellVar": "[lib/strings.nix:469](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L469) in ``", + "lib.strings.toShellVars": "[lib/strings.nix:497](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L497) in ``", + "lib.strings.toUpper": "[lib/strings.nix:572](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L572) in ``", + "lib.strings.typeOf": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.unsafeDiscardStringContext": "[lib/strings.nix:15](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L15) in ``", + "lib.strings.upperChars": "[lib/strings.nix:552](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L552) in ``", + "lib.strings.versionAtLeast": "[lib/strings.nix:690](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L690) in ``", + "lib.strings.versionOlder": "[lib/strings.nix:678](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L678) in ``", + "lib.strings.withFeature": "[lib/strings.nix:830](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L830) in ``", + "lib.strings.withFeatureAs": "[lib/strings.nix:843](https://github.com/NixOS/nixpkgs/blob/580dd2124db98c13c3798af23c2ecf6277ec7d9e/lib/strings.nix#L843) in ``" +}