From c0fc25c4430271519b632e48cb4a83593b1dff19 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 3 Jan 2024 21:21:06 +0100 Subject: [PATCH] add uuid, since heading ids must be unique and there is no other way --- Cargo.lock | 10 ++++++++++ Cargo.toml | 1 + src/main.rs | 6 +++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 827c6f4..6437229 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -241,6 +241,7 @@ dependencies = [ "serde", "serde_json", "textwrap", + "uuid", ] [[package]] @@ -423,6 +424,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "uuid" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" +dependencies = [ + "getrandom", +] + [[package]] name = "version_check" version = "0.9.4" diff --git a/Cargo.toml b/Cargo.toml index 13dd513..ef145ee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/main.rs b/src/main.rs index fc1c188..df61447 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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)] @@ -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".