From 04693a4eca38f8f1fe419b2118c815830ff32a14 Mon Sep 17 00:00:00 2001 From: xFrednet Date: Tue, 23 Jul 2024 09:44:45 +0200 Subject: [PATCH] Lintcheck: Support underscores replacement in URL crate names --- lintcheck/src/input.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lintcheck/src/input.rs b/lintcheck/src/input.rs index 7a0cf26ca327..3b263674aa87 100644 --- a/lintcheck/src/input.rs +++ b/lintcheck/src/input.rs @@ -10,7 +10,7 @@ use walkdir::{DirEntry, WalkDir}; use crate::{Crate, LINTCHECK_DOWNLOADS, LINTCHECK_SOURCES}; -const DEFAULT_DOCS_LINK: &str = "https://docs.rs/{krate}/{version}/src/{krate}/{file}.html#{line}"; +const DEFAULT_DOCS_LINK: &str = "https://docs.rs/{krate}/{version}/src/{krate_}/{file}.html#{line}"; const DEFAULT_GITHUB_LINK: &str = "{url}/blob/{hash}/src/{file}#L{line}"; const DEFAULT_PATH_LINK: &str = "{path}/src/{file}:{line}"; @@ -39,6 +39,7 @@ struct TomlCrate { options: Option>, /// Magic values: /// * `{krate}` will be replaced by `self.name` + /// * `{krate_}` will be replaced by `self.name` with all `-` replaced by `_` /// * `{version}` will be replaced by `self.version` /// * `{url}` will be replaced with `self.git_url` /// * `{hash}` will be replaced with `self.git_hash` @@ -55,6 +56,7 @@ impl TomlCrate { fn file_link(&self, default: &str) -> String { let mut link = self.online_link.clone().unwrap_or_else(|| default.to_string()); link = link.replace("{krate}", &self.name); + link = link.replace("{krate_}", &self.name.replace('-', "_")); if let Some(version) = &self.version { link = link.replace("{version}", version);