From 0f8eb3ac6e24a8aea459d17f2b2600468c72177f Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Thu, 25 Apr 2024 15:01:43 +0200 Subject: [PATCH] prefix: allow any --prefix flags --- src/commonmark.rs | 4 ++-- src/main.rs | 2 +- src/test.rs | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/commonmark.rs b/src/commonmark.rs index e9b5b65..fc60ff4 100644 --- a/src/commonmark.rs +++ b/src/commonmark.rs @@ -133,9 +133,9 @@ impl ManualEntry { locs: &HashMap, writer: &mut W, ) -> Result<()> { - let title = format!("{}.{}.{}", self.prefix, self.category, self.name); + let title = format!("{}{}.{}", self.prefix, self.category, self.name); let ident = format!( - "{}.{}.{}", + "{}{}.{}", self.prefix, self.category, self.name.replace('\'', "-prime") diff --git a/src/main.rs b/src/main.rs index 3a93330..f367ce3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,7 +53,7 @@ use std::path::PathBuf; #[command(author, version, about)] struct Options { /// Prefix for the category (e.g. 'lib' or 'utils'). - #[arg(short, long, default_value_t = String::from("lib"))] + #[arg(short, long, default_value_t = String::from("lib."))] prefix: String, /// Name of the function category (e.g. 'strings', 'attrsets'). diff --git a/src/test.rs b/src/test.rs index eaa0654..756e620 100644 --- a/src/test.rs +++ b/src/test.rs @@ -12,7 +12,7 @@ fn test_main() { 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 prefix = "lib"; + let prefix = "lib."; let category = "strings"; // TODO: move this to commonmark.rs @@ -39,7 +39,7 @@ fn test_description_of_lib_debug() { let mut output = Vec::new(); let src = fs::read_to_string("test/lib-debug.nix").unwrap(); let nix = rnix::Root::parse(&src).ok().expect("failed to parse input"); - let prefix = "lib"; + let prefix = "lib."; let category = "debug"; let desc = retrieve_description(&nix, &"Debug", category); writeln!(output, "{}", desc).expect("Failed to write header"); @@ -60,7 +60,7 @@ 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 prefix = "lib"; + let prefix = "lib."; let category = "options"; for entry in collect_entries(nix, prefix, category) { @@ -79,7 +79,7 @@ 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 prefix = "lib"; + let prefix = "lib."; let category = "let"; for entry in collect_entries(nix, prefix, category) { @@ -98,7 +98,7 @@ 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 prefix = "lib"; + let prefix = "lib."; let category = "let"; for entry in collect_entries(nix, prefix, category) { @@ -117,7 +117,7 @@ fn test_multi_line() { let mut output = Vec::new(); let src = fs::read_to_string("test/multi-line.nix").unwrap(); let nix = rnix::Root::parse(&src).ok().expect("failed to parse input"); - let prefix = "lib"; + let prefix = "lib."; let category = "let"; for entry in collect_entries(nix, prefix, category) { @@ -136,7 +136,7 @@ fn test_doc_comment() { let mut output = Vec::new(); let src = fs::read_to_string("test/doc-comment.nix").unwrap(); let nix = rnix::Root::parse(&src).ok().expect("failed to parse input"); - let prefix = "lib"; + let prefix = "lib."; let category = "debug"; for entry in collect_entries(nix, prefix, category) { @@ -173,7 +173,7 @@ fn test_doc_comment_section_description() { let mut output = Vec::new(); let src = fs::read_to_string("test/doc-comment-sec-heading.nix").unwrap(); let nix = rnix::Root::parse(&src).ok().expect("failed to parse input"); - let prefix = "lib"; + let prefix = "lib."; let category = "debug"; let desc = retrieve_description(&nix, &"Debug", category); writeln!(output, "{}", desc).expect("Failed to write header"); @@ -194,7 +194,7 @@ fn test_doc_comment_no_duplicate_arguments() { let mut output = Vec::new(); let src = fs::read_to_string("test/doc-comment-arguments.nix").unwrap(); let nix = rnix::Root::parse(&src).ok().expect("failed to parse input"); - let prefix = "lib"; + let prefix = "lib."; let category = "debug"; let desc = retrieve_description(&nix, &"Debug", category); writeln!(output, "{}", desc).expect("Failed to write header");