Skip to content

Commit

Permalink
prefix: allow any --prefix flags
Browse files Browse the repository at this point in the history
  • Loading branch information
hsjobeki committed Apr 25, 2024
1 parent 7f408d0 commit 0f8eb3a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/commonmark.rs
Expand Up @@ -133,9 +133,9 @@ impl ManualEntry {
locs: &HashMap<String, String>,
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")
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Expand Up @@ -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').
Expand Down
18 changes: 9 additions & 9 deletions src/test.rs
Expand Up @@ -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
Expand All @@ -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");
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand Down

0 comments on commit 0f8eb3a

Please sign in to comment.