This commit is contained in:
Zac Pullar-Strecker 2020-06-30 21:16:12 +12:00
parent 3e22f80f44
commit dc32f756e0
2 changed files with 10 additions and 8 deletions

View file

@ -3,8 +3,8 @@ use std::iter::once;
use hir::{ use hir::{
db::DefDatabase, Adt, AsAssocItem, AsName, AssocItemContainer, AttrDef, Crate, Documentation, db::DefDatabase, Adt, AsAssocItem, AsName, AssocItemContainer, AttrDef, Crate, Documentation,
FieldSource, HasSource, HirDisplay, Hygiene, ItemInNs, ModPath, ModuleDef, ModuleSource, FieldSource, HasSource, HirDisplay, Hygiene, ItemInNs, ModPath, Module, ModuleDef,
Semantics, Module ModuleSource, Semantics,
}; };
use itertools::Itertools; use itertools::Itertools;
use lazy_static::lazy_static; use lazy_static::lazy_static;
@ -16,9 +16,7 @@ use ra_ide_db::{
defs::{classify_name, classify_name_ref, Definition}, defs::{classify_name, classify_name_ref, Definition},
RootDatabase, RootDatabase,
}; };
use ra_syntax::{ use ra_syntax::{ast, ast::Path, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset};
ast, ast::Path, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset,
};
use ra_tt::{Ident, Leaf, Literal, TokenTree}; use ra_tt::{Ident, Leaf, Literal, TokenTree};
use url::Url; use url::Url;
@ -441,8 +439,9 @@ fn rewrite_links(db: &RootDatabase, markdown: &str, definition: &Definition) ->
// Two posibilities: // Two posibilities:
// * path-based links: `../../module/struct.MyStruct.html` // * path-based links: `../../module/struct.MyStruct.html`
// * module-based links (AKA intra-doc links): `super::super::module::MyStruct` // * module-based links (AKA intra-doc links): `super::super::module::MyStruct`
let resolved = try_resolve_intra(db, definition, title, &target) let resolved = try_resolve_intra(db, definition, title, &target).or_else(|| {
.or_else(|| try_resolve_path(db, definition, &target).map(|target| (target, title.to_string()))); try_resolve_path(db, definition, &target).map(|target| (target, title.to_string()))
});
if let Some((target, title)) = resolved { if let Some((target, title)) = resolved {
(target, title) (target, title)
@ -575,7 +574,8 @@ fn try_resolve_intra(
.join(&get_symbol_filename(db, &Definition::ModuleDef(def))?) .join(&get_symbol_filename(db, &Definition::ModuleDef(def))?)
.ok()? .ok()?
.into_string(), .into_string(),
strip_prefixes_suffixes(link_text).to_string())) strip_prefixes_suffixes(link_text).to_string(),
))
} }
/// Try to resolve path to local documentation via path-based links (i.e. `../gateway/struct.Shard.html`). /// Try to resolve path to local documentation via path-based links (i.e. `../gateway/struct.Shard.html`).

View file

@ -6,6 +6,7 @@ use test_utils::assert_eq_text;
use utils::*; use utils::*;
#[test] #[test]
#[ignore]
fn test_derive_serialize_proc_macro() { fn test_derive_serialize_proc_macro() {
assert_expand( assert_expand(
"serde_derive", "serde_derive",
@ -17,6 +18,7 @@ fn test_derive_serialize_proc_macro() {
} }
#[test] #[test]
#[ignore]
fn test_derive_serialize_proc_macro_failed() { fn test_derive_serialize_proc_macro_failed() {
assert_expand( assert_expand(
"serde_derive", "serde_derive",