Skip to content

Commit 04693a4

Browse files
committed
Lintcheck: Support underscores replacement in URL crate names
1 parent 1807580 commit 04693a4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lintcheck/src/input.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use walkdir::{DirEntry, WalkDir};
1010

1111
use crate::{Crate, LINTCHECK_DOWNLOADS, LINTCHECK_SOURCES};
1212

13-
const DEFAULT_DOCS_LINK: &str = "https://docs.rs/{krate}/{version}/src/{krate}/{file}.html#{line}";
13+
const DEFAULT_DOCS_LINK: &str = "https://docs.rs/{krate}/{version}/src/{krate_}/{file}.html#{line}";
1414
const DEFAULT_GITHUB_LINK: &str = "{url}/blob/{hash}/src/{file}#L{line}";
1515
const DEFAULT_PATH_LINK: &str = "{path}/src/{file}:{line}";
1616

@@ -39,6 +39,7 @@ struct TomlCrate {
3939
options: Option<Vec<String>>,
4040
/// Magic values:
4141
/// * `{krate}` will be replaced by `self.name`
42+
/// * `{krate_}` will be replaced by `self.name` with all `-` replaced by `_`
4243
/// * `{version}` will be replaced by `self.version`
4344
/// * `{url}` will be replaced with `self.git_url`
4445
/// * `{hash}` will be replaced with `self.git_hash`
@@ -55,6 +56,7 @@ impl TomlCrate {
5556
fn file_link(&self, default: &str) -> String {
5657
let mut link = self.online_link.clone().unwrap_or_else(|| default.to_string());
5758
link = link.replace("{krate}", &self.name);
59+
link = link.replace("{krate_}", &self.name.replace('-', "_"));
5860

5961
if let Some(version) = &self.version {
6062
link = link.replace("{version}", version);

0 commit comments

Comments
 (0)