From 1cb8150cea6c86f77a945d53e14f691f742d434a Mon Sep 17 00:00:00 2001 From: Jonathan Pallant Date: Mon, 15 Jul 2024 17:30:32 +0100 Subject: [PATCH] generate-copyright: Update HTML format The h3 containing the tag didn't work, format wise. Also tried to harmonise the out-of-tree metadata formatting with the in-tree metadata formatting. --- src/tools/generate-copyright/src/main.rs | 35 ++++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/tools/generate-copyright/src/main.rs b/src/tools/generate-copyright/src/main.rs index 35b47082fb1a8..29babd2282b1e 100644 --- a/src/tools/generate-copyright/src/main.rs +++ b/src/tools/generate-copyright/src/main.rs @@ -174,27 +174,38 @@ fn render_deps<'a, 'b>( license_set: &mut BTreeSet, ) -> Result<(), Error> { for dep in deps { - let authors_list = dep.authors.join(", "); + let authors_list = if dep.authors.is_empty() { + "None Specified".to_owned() + } else { + dep.authors.join(", ") + }; let url = format!("https://crates.io/crates/{}/{}", dep.name, dep.version); writeln!(buffer)?; writeln!( buffer, - r#"

{name} {version}

"#, + r#"

📦 {name}-{version}

"#, name = dep.name, version = dep.version, - url = url, )?; - writeln!(buffer, "

Authors

{}

", escape_html(&authors_list))?; - writeln!(buffer, "

License

{}

", escape_html(&dep.license))?; + writeln!(buffer, r#"

URL: {url}

"#,)?; + writeln!(buffer, "

Authors: {}

", escape_html(&authors_list))?; + writeln!(buffer, "

License: {}

", escape_html(&dep.license))?; license_set.insert(dep.license.clone()); - for (name, contents) in &dep.notices { - writeln!(buffer)?; - writeln!(buffer, "

{}

", name.to_string_lossy())?; - writeln!(buffer)?; - writeln!(buffer, "
Click to expand")?; - writeln!(buffer, "
\n{}\n
", contents)?; - writeln!(buffer, "
")?; + writeln!(buffer, "

Notices: ")?; + if dep.notices.is_empty() { + writeln!(buffer, "None")?; + } else { + for (name, contents) in &dep.notices { + writeln!( + buffer, + "

{}", + name.to_string_lossy() + )?; + writeln!(buffer, "
\n{}\n
", contents)?; + writeln!(buffer, "
")?; + } } + writeln!(buffer, "

")?; } Ok(()) }