Add test cases for intra-doc links

This commit is contained in:
arferreira
2026-02-24 11:41:26 -05:00
parent 0da2c0c691
commit b3a41f2385
2 changed files with 16 additions and 3 deletions
+1
View File
@@ -532,6 +532,7 @@ fn make_href(
fqp: &[Symbol],
is_absolute: bool,
) -> String {
// FIXME: relative extern URLs may break when prefixed with root_path
if !is_absolute && let Some(root_path) = root_path {
let root = root_path.trim_end_matches('/');
url_parts.push_front(root);
+15 -3
View File
@@ -1,4 +1,4 @@
//@ compile-flags:-Z unstable-options --extern-html-root-url core=../ --extern-html-root-takes-precedence
//@ compile-flags:-Z unstable-options --extern-html-root-url core=../ --extern-html-root-takes-precedence --generate-link-to-definition
// At depth 1 (top-level), the href should be ../core/...
//@ has extern_html_root_url_relative/index.html
@@ -9,7 +9,19 @@
// At depth 2 (inside a module), the href should be ../../core/...
pub mod nested {
//@ has extern_html_root_url_relative/nested/index.html
//@ has - '//a/@href' '../../core/iter/index.html'
//@ has - '//a/@href' '../../core/future/index.html'
#[doc(no_inline)]
pub use std::iter;
pub use std::future;
}
// Also depth 2, but for an intra-doc link.
//@ has extern_html_root_url_relative/intra_doc_link/index.html
//@ has - '//a/@href' '../../core/ptr/fn.write.html'
/// [write](<core::ptr::write()>)
pub mod intra_doc_link {
}
// link-to-definition
//@ has src/extern_html_root_url_relative/extern-html-root-url-relative.rs.html
//@ has - '//a/@href' '../../core/iter/index.html'
//@ has - '//a/@href' '../../core/future/index.html'