Skip to content

Commit 2bff9d4

Browse files
Add GUI tests for comments highlighting in items declaration
1 parent 7bf2afd commit 2bff9d4

File tree

5 files changed

+117
-0
lines changed

5 files changed

+117
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// This test checks that comments in item declarations are highlighted.
2+
go-to: "file://" + |DOC_PATH| + "/test_docs/private/enum.Enum.html"
3+
show-text: true
4+
5+
define-function: (
6+
"check-item-decl-comment",
7+
(theme, url, comment_color),
8+
block {
9+
go-to: |url|
10+
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
11+
reload:
12+
assert-css: (".item-decl .comment", {"color": |comment_color|}, ALL)
13+
}
14+
)
15+
16+
define-function: (
17+
"check-items-for-theme",
18+
(theme, comment_color),
19+
block {
20+
call-function: ("check-item-decl-comment", {
21+
"theme": |theme|,
22+
"url": "file://" + |DOC_PATH| + "/test_docs/private/enum.Enum.html",
23+
"comment_color": |comment_color|,
24+
})
25+
call-function: ("check-item-decl-comment", {
26+
"theme": |theme|,
27+
"url": "file://" + |DOC_PATH| + "/test_docs/private/struct.Struct.html",
28+
"comment_color": |comment_color|,
29+
})
30+
call-function: ("check-item-decl-comment", {
31+
"theme": |theme|,
32+
"url": "file://" + |DOC_PATH| + "/test_docs/private/struct.Tuple.html",
33+
"comment_color": |comment_color|,
34+
})
35+
call-function: ("check-item-decl-comment", {
36+
"theme": |theme|,
37+
"url": "file://" + |DOC_PATH| + "/test_docs/private/union.Union.html",
38+
"comment_color": |comment_color|,
39+
})
40+
call-function: ("check-item-decl-comment", {
41+
"theme": |theme|,
42+
"url": "file://" + |DOC_PATH| + "/proc_macro_test/macro.make_answer.html",
43+
"comment_color": |comment_color|,
44+
})
45+
call-function: ("check-item-decl-comment", {
46+
"theme": |theme|,
47+
"url": "file://" + |DOC_PATH| + "/proc_macro_test/derive.HelperAttr.html",
48+
"comment_color": |comment_color|,
49+
})
50+
}
51+
)
52+
53+
call-function: (
54+
"check-items-for-theme",
55+
{
56+
"theme": "ayu",
57+
"comment_color": "#788797",
58+
}
59+
)
60+
call-function: (
61+
"check-items-for-theme",
62+
{
63+
"theme": "dark",
64+
"comment_color": "#8d8d8b",
65+
}
66+
)
67+
call-function: (
68+
"check-items-for-theme",
69+
{
70+
"theme": "light",
71+
"comment_color": "#8e908c",
72+
}
73+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file is automatically @generated by Cargo.
2+
# It is not intended for manual editing.
3+
version = 3
4+
5+
[[package]]
6+
name = "proc_macro_test"
7+
version = "0.1.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "proc_macro_test"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[lib]
7+
path = "lib.rs"
8+
proc-macro = true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
use proc_macro::TokenStream;
2+
3+
#[proc_macro]
4+
pub fn make_answer(_item: TokenStream) -> TokenStream {
5+
"fn answer() -> u32 { 42 }".parse().unwrap()
6+
}
7+
8+
#[proc_macro_derive(HelperAttr, attributes(helper))]
9+
pub fn derive_helper_attr(_item: TokenStream) -> TokenStream {
10+
TokenStream::new()
11+
}

tests/rustdoc-gui/src/test_docs/lib.rs

+18
Original file line numberDiff line numberDiff line change
@@ -593,3 +593,21 @@ pub mod foreign_impl_order {
593593
fn f(&mut self, fg: [u8; 3]) {}
594594
}
595595
}
596+
597+
pub mod private {
598+
pub struct Tuple(u32, u8);
599+
pub struct Struct {
600+
a: u8,
601+
}
602+
603+
pub union Union {
604+
a: u8,
605+
b: u16,
606+
}
607+
608+
pub enum Enum {
609+
A,
610+
#[doc(hidden)]
611+
B,
612+
}
613+
}

0 commit comments

Comments
 (0)