mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Expose version string of crates fom HIR
This commit is contained in:
parent
b9fa37f5b4
commit
52f5af7165
8 changed files with 111 additions and 1 deletions
|
@ -473,12 +473,17 @@ fn get_doc_base_url(db: &RootDatabase, krate: &Crate) -> Option<Url> {
|
|||
}
|
||||
_ => {
|
||||
krate.get_html_root_url(db).or_else(|| {
|
||||
let version = krate.version(db);
|
||||
// Fallback to docs.rs. This uses `display_name` and can never be
|
||||
// correct, but that's what fallbacks are about.
|
||||
//
|
||||
// FIXME: clicking on the link should just open the file in the editor,
|
||||
// instead of falling back to external urls.
|
||||
Some(format!("https://docs.rs/{krate}/*/", krate = display_name))
|
||||
Some(format!(
|
||||
"https://docs.rs/{krate}/{version}/",
|
||||
krate = display_name,
|
||||
version = version.as_deref().unwrap_or("*")
|
||||
))
|
||||
})?
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue