Skip to content

Commit 1cb8150

Browse files
generate-copyright: Update HTML format
The h3 containing the <a> tag didn't work, format wise. Also tried to harmonise the out-of-tree metadata formatting with the in-tree metadata formatting.
1 parent cf04752 commit 1cb8150

File tree

1 file changed

+23
-12
lines changed
  • src/tools/generate-copyright/src

1 file changed

+23
-12
lines changed

src/tools/generate-copyright/src/main.rs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,27 +174,38 @@ fn render_deps<'a, 'b>(
174174
license_set: &mut BTreeSet<String>,
175175
) -> Result<(), Error> {
176176
for dep in deps {
177-
let authors_list = dep.authors.join(", ");
177+
let authors_list = if dep.authors.is_empty() {
178+
"None Specified".to_owned()
179+
} else {
180+
dep.authors.join(", ")
181+
};
178182
let url = format!("https://crates.io/crates/{}/{}", dep.name, dep.version);
179183
writeln!(buffer)?;
180184
writeln!(
181185
buffer,
182-
r#"<h3><a href="{url}">{name} {version}</a></h3>"#,
186+
r#"<h3>📦 {name}-{version}</h3>"#,
183187
name = dep.name,
184188
version = dep.version,
185-
url = url,
186189
)?;
187-
writeln!(buffer, "<h4>Authors</h4><p>{}</p>", escape_html(&authors_list))?;
188-
writeln!(buffer, "<h4>License</h4><p>{}</p>", escape_html(&dep.license))?;
190+
writeln!(buffer, r#"<p><b>URL:</b> <a href="{url}">{url}</a></p>"#,)?;
191+
writeln!(buffer, "<p><b>Authors:</b> {}</p>", escape_html(&authors_list))?;
192+
writeln!(buffer, "<p><b>License:</b> {}</p>", escape_html(&dep.license))?;
189193
license_set.insert(dep.license.clone());
190-
for (name, contents) in &dep.notices {
191-
writeln!(buffer)?;
192-
writeln!(buffer, "<h4>{}</h3>", name.to_string_lossy())?;
193-
writeln!(buffer)?;
194-
writeln!(buffer, "<details><summary>Click to expand</summary>")?;
195-
writeln!(buffer, "<pre>\n{}\n</pre>", contents)?;
196-
writeln!(buffer, "</details>")?;
194+
writeln!(buffer, "<p><b>Notices:</b> ")?;
195+
if dep.notices.is_empty() {
196+
writeln!(buffer, "None")?;
197+
} else {
198+
for (name, contents) in &dep.notices {
199+
writeln!(
200+
buffer,
201+
"<details><summary><code>{}</code></summary>",
202+
name.to_string_lossy()
203+
)?;
204+
writeln!(buffer, "<pre>\n{}\n</pre>", contents)?;
205+
writeln!(buffer, "</details>")?;
206+
}
197207
}
208+
writeln!(buffer, "</p>")?;
198209
}
199210
Ok(())
200211
}

0 commit comments

Comments
 (0)