Skip to content

Commit

Permalink
add uuid, since heading ids must be unique and there is no other way
Browse files Browse the repository at this point in the history
  • Loading branch information
hsjobeki committed Jan 3, 2024
1 parent 3355136 commit c0fc25c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
textwrap = "0.16"
clap = { version = "4.4.4", features = ["derive"] }
uuid = { version = "1.6.1", features = ["v4"] }

[dev-dependencies]
insta = "1.31.0"
6 changes: 5 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ use std::io::Write;

use clap::Parser;
use std::path::PathBuf;
use uuid::Uuid;

/// Command line arguments for nixdoc
#[derive(Debug, Parser)]
Expand Down Expand Up @@ -300,7 +301,10 @@ fn handle_heading(line: &str, levels: usize) -> String {
_ => "#".repeat(hashes.len() + levels),
};

format!("{leading_trivials}{new_hashes} {rest}")
format!(
"{leading_trivials}{new_hashes} {rest} {{#{rest}-{}}}",
Uuid::new_v4()
)
}

/// Dumb, mutable, hacky doc comment "parser".
Expand Down

0 comments on commit c0fc25c

Please sign in to comment.