Update rustdoc tests

This commit is contained in:
Guillaume Gomez 2025-01-17 18:36:11 +01:00
parent 42f9c79776
commit 3c62ccdff5
16 changed files with 42 additions and 56 deletions

View file

@ -3,7 +3,7 @@
go-to: "file://" + |DOC_PATH| + "/test_docs/huge_amount_of_consts/index.html"
compare-elements-position-near-false: (
"//ul[@class='item-table']/li[last()-1]",
"//ul[@class='item-table']/li[last()-3]",
"//dl[@class='item-table']/dt[last()-1]",
"//dl[@class='item-table']/dt[last()-3]",
{"y": 12},
)

View file

@ -3,9 +3,9 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/short_docs/index.html"
set-window-size: (1000, 600)
// First we ensure that there is only one `item-table`...
assert-count: ("ul.item-table", 1)
assert-count: ("dl.item-table", 1)
// And only two items in it.
assert-count: ("ul.item-table li", 2)
assert-count: ("dl.item-table dt", 2)
// If they don't have the same height, then it means one of the two is on two lines whereas it
// shouldn't!
@ -18,6 +18,6 @@ compare-elements-size: (
// We also check that the `item-table` is taking the full width.
compare-elements-size: (
"#functions",
"ul.item-table",
"dl.item-table",
["width"],
)

View file

@ -16,7 +16,7 @@ mod bar {
//@ count - '//*[@id="main-content"]/h2' 2
//@ has - '//*[@id="main-content"]/h2' 'Re-exports'
//@ has - '//*[@id="main-content"]/h2' 'Modules'
//@ has - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 'pub use foo::Foo as _;'
//@ has - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 'pub use bar::Bar as _;'
//@ has - '//*[@id="main-content"]//*[@class="item-table reexports"]/dt//code' 'pub use foo::Foo as _;'
//@ has - '//*[@id="main-content"]//*[@class="item-table reexports"]/dt//code' 'pub use bar::Bar as _;'
pub use foo::Foo as _;
pub use bar::Bar as _;

View file

@ -9,7 +9,7 @@
//@ has - '//*[@id="main-content"]/h2' 'Structs'
//@ has - '//*[@id="main-content"]/h2' 'Re-exports'
// The 3 re-exports.
//@ count - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 3
//@ count - '//*[@id="main-content"]//*[@class="item-table"]/dt//code' 3
// The public struct.
//@ count - '//*[@id="main-content"]//a[@class="struct"]' 1

View file

@ -7,9 +7,9 @@
//@ has 'foo/index.html'
// There are two items.
//@ count - '//*[@class="item-table"]//div[@class="item-name"]' 2
//@ count - '//*[@class="item-table"]/dt[@class="item-name"]' 2
// Only one of them should have an attribute.
//@ count - '//*[@class="item-table"]//div[@class="item-name"]/*[@class="stab portability"]' 1
//@ count - '//*[@class="item-table"]/dt[@class="item-name"]/*[@class="stab portability"]' 1
mod a {
#[doc(cfg(not(feature = "a")))]

View file

@ -6,9 +6,9 @@
//@ has 'foo/index.html'
// There are two items.
//@ count - '//*[@class="item-table"]//div[@class="item-name"]' 2
//@ count - '//*[@class="item-table"]/dt[@class="item-name"]' 2
// Only one of them should have an attribute.
//@ count - '//*[@class="item-table"]//div[@class="item-name"]/*[@class="stab portability"]' 1
//@ count - '//*[@class="item-table"]/dt[@class="item-name"]/*[@class="stab portability"]' 1
mod a {
#[cfg(not(feature = "a"))]

View file

@ -15,6 +15,6 @@ mod sub4 {
pub use sub4::inner::*;
//@ has 'foo/index.html'
//@ has - '//div[@class="desc docblock-short"]' '1'
//@ !has - '//div[@class="desc docblock-short"]' '0'
//@ has - '//dd[@class="desc docblock-short"]' '1'
//@ !has - '//dd[@class="desc docblock-short"]' '0'
fn main() { assert_eq!(X, 1); }

View file

@ -1,17 +1,17 @@
//@ has 'glob_shadowing/index.html'
//@ count - '//div[@class="item-name"]' 6
//@ !has - '//div[@class="desc docblock-short"]' 'sub1::describe'
//@ has - '//div[@class="desc docblock-short"]' 'sub2::describe'
//@ count - '//dt[@class="item-name"]' 6
//@ !has - '//dd[@class="desc docblock-short"]' 'sub1::describe'
//@ has - '//dd[@class="desc docblock-short"]' 'sub2::describe'
//@ !has - '//div[@class="desc docblock-short"]' 'sub1::describe2'
//@ !has - '//dd[@class="desc docblock-short"]' 'sub1::describe2'
//@ !has - '//div[@class="desc docblock-short"]' 'sub1::prelude'
//@ has - '//div[@class="desc docblock-short"]' 'mod::prelude'
//@ !has - '//dd[@class="desc docblock-short"]' 'sub1::prelude'
//@ has - '//dd[@class="desc docblock-short"]' 'mod::prelude'
//@ has - '//div[@class="desc docblock-short"]' 'sub1::Foo (struct)'
//@ has - '//div[@class="desc docblock-short"]' 'mod::Foo (function)'
//@ has - '//dd[@class="desc docblock-short"]' 'sub1::Foo (struct)'
//@ has - '//dd[@class="desc docblock-short"]' 'mod::Foo (function)'
//@ has - '//div[@class="desc docblock-short"]' 'sub4::inner::X'
//@ has - '//dd[@class="desc docblock-short"]' 'sub4::inner::X'
//@ has 'glob_shadowing/fn.describe.html'
//@ has - '//div[@class="docblock"]' 'sub2::describe'

View file

@ -32,8 +32,8 @@ pub mod subone {
//@ has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.foo.html"]' 'foo'
//@ has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.bar.html"]' 'bar'
// Though there should be such links later
//@ has - '//section[@id="main-content"]/ul[@class="item-table"]//div[@class="item-name"]/a[@class="fn"][@href="fn.foo.html"]' 'foo'
//@ has - '//section[@id="main-content"]/ul[@class="item-table"]//div[@class="item-name"]/a[@class="fn"][@href="fn.bar.html"]' 'bar'
//@ has - '//section[@id="main-content"]/dl[@class="item-table"]/dt[@class="item-name"]/a[@class="fn"][@href="fn.foo.html"]' 'foo'
//@ has - '//section[@id="main-content"]/dl[@class="item-table"]/dt[@class="item-name"]/a[@class="fn"][@href="fn.bar.html"]' 'bar'
/// See either [foo] or [bar].
pub mod subtwo {
@ -71,8 +71,8 @@ pub mod subthree {
// Next we go *deeper* - In order to ensure it's not just "this or parent"
// we test `crate::` and a `super::super::...` chain
//@ has foo/subfour/subfive/subsix/subseven/subeight/index.html
//@ has - '//section[@id="main-content"]/ul[@class="item-table"]//div[@class="desc docblock-short"]//a[@href="../../../../../subone/fn.foo.html"]' 'other foo'
//@ has - '//section[@id="main-content"]/ul[@class="item-table"]//div[@class="desc docblock-short"]//a[@href="../../../../../subtwo/fn.bar.html"]' 'other bar'
//@ has - '//section[@id="main-content"]/dl[@class="item-table"]/dd[@class="desc docblock-short"]//a[@href="../../../../../subone/fn.foo.html"]' 'other foo'
//@ has - '//section[@id="main-content"]/dl[@class="item-table"]/dd[@class="desc docblock-short"]//a[@href="../../../../../subtwo/fn.bar.html"]' 'other bar'
pub mod subfour {
pub mod subfive {
pub mod subsix {

View file

@ -1 +1 @@
<ul class="item-table"><li><div class="item-name"><a class="constant" href="constant.MY_CONSTANT.html" title="constant item_desc_list_at_start::MY_CONSTANT">MY_<wbr />CONSTANT</a></div><div class="desc docblock-short">Groups: <code>SamplePatternSGIS</code>, <code>SamplePatternEXT</code></div></li></ul>
<dl class="item-table"><dt class="item-name"><a class="constant" href="constant.MY_CONSTANT.html" title="constant item_desc_list_at_start::MY_CONSTANT">MY_<wbr />CONSTANT</a></dt><dd class="desc docblock-short">Groups: <code>SamplePatternSGIS</code>, <code>SamplePatternEXT</code></dd></dl>

View file

@ -1,7 +1,8 @@
//@ has item_desc_list_at_start/index.html
//@ count - '//ul[@class="item-table"]/li/div/li' 0
//@ count - '//ul[@class="item-table"]/li' 1
//@ snapshot item-table - '//ul[@class="item-table"]'
//@ count - '//dl[@class="item-table"]/dd//ul' 0
//@ count - '//dl[@class="item-table"]/dd//li' 0
//@ count - '//dl[@class="item-table"]/dd' 1
//@ snapshot item-table - '//dl[@class="item-table"]'
// based on https://docs.rs/gl_constants/0.1.1/src/gl_constants/lib.rs.html#16

View file

@ -1,17 +0,0 @@
// https://github.com/rust-lang/rust/issues/106142
#![crate_name="foo"]
//@ has 'foo/a/index.html'
//@ count 'foo/a/index.html' '//ul[@class="item-table"]//li//a' 1
#![allow(rustdoc::broken_intra_doc_links)]
pub mod a {
/// [`m`]
pub fn f() {}
#[macro_export]
macro_rules! m {
() => {};
}
}

View file

@ -21,10 +21,12 @@ pub use crate::foo::Bar as Babar;
#[doc(cfg(not(feature = "cake")))]
pub use crate::foo::Bar2 as Babar2;
//@ has - '//*[@class="item-table"]/li' 'pub use crate::Babar as Elephant;Non-robot'
//@ has - '//*[@class="item-table"]/dt' 'pub use crate::Babar as Elephant;'
//@ has - '//*[@class="item-table"]/dd' 'Non-robot'
#[cfg(not(feature = "robot"))]
pub use crate::Babar as Elephant;
//@ has - '//*[@class="item-table"]/li' 'pub use crate::Babar2 as Elephant2;Non-cat'
//@ has - '//*[@class="item-table"]/dt' 'pub use crate::Babar2 as Elephant2;'
//@ has - '//*[@class="item-table"]/dd' 'Non-cat'
#[doc(cfg(not(feature = "cat")))]
pub use crate::Babar2 as Elephant2;

View file

@ -8,13 +8,13 @@ extern crate reexport_check;
#[allow(deprecated, deprecated_in_future)]
pub use std::i32;
//@ !has 'foo/index.html' '//code' 'pub use self::string::String;'
//@ has 'foo/index.html' '//div[@class="item-name"]' 'String'
//@ has 'foo/index.html' '//dt[@class="item-name"]' 'String'
pub use std::string::String;
// i32 is deprecated, String is not
//@ count 'foo/index.html' '//span[@class="stab deprecated"]' 1
//@ has 'foo/index.html' '//div[@class="desc docblock-short"]' 'Docs in original'
//@ has 'foo/index.html' '//dd[@class="desc docblock-short"]' 'Docs in original'
// this is a no-op, but shows what happens if there's an attribute that isn't a doc-comment
#[doc(inline)]
pub use reexport_check::S;

View file

@ -12,5 +12,5 @@ mod private_module {
//@ has - '//*[@id="reexport.Foo"]/code' 'pub use crate::private_module::Public as Foo;'
pub use crate::private_module::Public as Foo;
// Glob re-exports with no visible items should not be displayed.
//@ count - '//*[@class="item-table"]/li' 1
//@ count - '//*[@class="item-table"]/dt' 1
pub use crate::private_module::*;

View file

@ -5,9 +5,9 @@
#![stable(feature = "core", since = "1.6.0")]
//@ has stability/index.html
//@ has - '//ul[@class="item-table"]/li[1]//a' AaStable
//@ has - '//ul[@class="item-table"]/li[2]//a' ZzStable
//@ has - '//ul[@class="item-table"]/li[3]//a' Unstable
//@ has - '//dl[@class="item-table"]/dt[1]//a' AaStable
//@ has - '//dl[@class="item-table"]/dt[2]//a' ZzStable
//@ has - '//dl[@class="item-table"]/dt[3]//a' Unstable
#[stable(feature = "rust2", since = "2.2.2")]
pub struct AaStable;