Skip to content

Commit bb71ebb

Browse files
committed
Move doc_links tests from hover to doc_links
1 parent a35687f commit bb71ebb

File tree

2 files changed

+72
-383
lines changed

2 files changed

+72
-383
lines changed

crates/ide/src/doc_links.rs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,78 @@ trait Trait$0 {
602602
)
603603
}
604604

605+
#[test]
606+
fn test_rewrite_html_root_url() {
607+
check_rewrite(
608+
r#"
609+
#![doc(arbitrary_attribute = "test", html_root_url = "https:/example.com", arbitrary_attribute2)]
610+
611+
pub mod foo {
612+
pub struct Foo;
613+
}
614+
/// [Foo](foo::Foo)
615+
pub struct B$0ar
616+
"#,
617+
expect![[r#"[Foo](https://example.com/test/foo/struct.Foo.html)"#]],
618+
);
619+
}
620+
621+
#[test]
622+
fn test_rewrite_on_field() {
623+
// FIXME: Should be
624+
// [Foo](https://docs.rs/test/*/test/struct.Foo.html)
625+
check_rewrite(
626+
r#"
627+
pub struct Foo {
628+
/// [Foo](struct.Foo.html)
629+
fie$0ld: ()
630+
}
631+
"#,
632+
expect![[r#"[Foo](struct.Foo.html)"#]],
633+
);
634+
}
635+
636+
#[test]
637+
fn test_rewrite_struct() {
638+
check_rewrite(
639+
r#"
640+
/// [Foo]
641+
pub struct $0Foo;
642+
"#,
643+
expect![[r#"[Foo](https://docs.rs/test/*/test/struct.Foo.html)"#]],
644+
);
645+
check_rewrite(
646+
r#"
647+
/// [`Foo`]
648+
pub struct $0Foo;
649+
"#,
650+
expect![[r#"[`Foo`](https://docs.rs/test/*/test/struct.Foo.html)"#]],
651+
);
652+
check_rewrite(
653+
r#"
654+
/// [Foo](struct.Foo.html)
655+
pub struct $0Foo;
656+
"#,
657+
expect![[r#"[Foo](https://docs.rs/test/*/test/struct.Foo.html)"#]],
658+
);
659+
check_rewrite(
660+
r#"
661+
/// [struct Foo](struct.Foo.html)
662+
pub struct $0Foo;
663+
"#,
664+
expect![[r#"[struct Foo](https://docs.rs/test/*/test/struct.Foo.html)"#]],
665+
);
666+
check_rewrite(
667+
r#"
668+
/// [my Foo][foo]
669+
///
670+
/// [foo]: Foo
671+
pub struct $0Foo;
672+
"#,
673+
expect![[r#"[my Foo](https://docs.rs/test/*/test/struct.Foo.html)"#]],
674+
);
675+
}
676+
605677
#[test]
606678
fn test_rewrite() {
607679
check_rewrite(

0 commit comments

Comments
 (0)