// version of import map which follows the same process as rustdoc. Otherwise there'll always be some
// edge cases where we select the wrong import path.
fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> {
- eprintln!("enter");
// Get the outermost definition for the moduledef. This is used to resolve the public path to the type,
// then we can join the method, field, etc onto it if required.
let target_def: ModuleDef = match definition {
_ => return None,
};
- let ns = ItemInNs::Types(target_def.clone().into());
+ let ns = ItemInNs::from(target_def.clone());
let module = definition.module(db)?;
let krate = module.krate();
Definition::Field(field) => get_symbol_fragment(db, &FieldOrAssocItem::Field(field)),
_ => None,
};
- eprintln!("end-ish");
get_doc_url(db, &krate)
.and_then(|url| url.join(&base).ok())
);
}
- // TODO: Fix this test. Fails on `import_map.path_of(ns)`
#[test]
fn test_doc_url_fn() {
check(
r#"
pub fn fo<|>o() {}
"#,
- expect![[r#""#]],
+ expect![[r##"https://docs.rs/test/*/test/fn.foo.html#method.foo"##]],
);
}
);
}
-
#[test]
fn test_doc_url_field() {
check(