Run doc tests on Web as well (#3799)
This commit is contained in:
parent
88bbdb33da
commit
73c01fff96
5 changed files with 39 additions and 12 deletions
|
|
@ -616,7 +616,7 @@ pub struct KeyEvent {
|
|||
/// In games, you often want to ignore repated key events - this can be
|
||||
/// done by ignoring events where this property is set.
|
||||
///
|
||||
/// ```
|
||||
/// ```no_run
|
||||
/// use winit::event::{ElementState, KeyEvent, WindowEvent};
|
||||
/// use winit::keyboard::{KeyCode, PhysicalKey};
|
||||
/// # let window_event = WindowEvent::RedrawRequested; // To make the example compile
|
||||
|
|
|
|||
|
|
@ -1568,10 +1568,15 @@ impl NamedKey {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # #[cfg(web_platform)]
|
||||
/// # wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
|
||||
/// # #[cfg_attr(web_platform, wasm_bindgen_test::wasm_bindgen_test)]
|
||||
/// # fn main() {
|
||||
/// use winit::keyboard::NamedKey;
|
||||
///
|
||||
/// assert_eq!(NamedKey::Enter.to_text(), Some("\r"));
|
||||
/// assert_eq!(NamedKey::F20.to_text(), None);
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn to_text(&self) -> Option<&str> {
|
||||
match self {
|
||||
|
|
@ -1591,11 +1596,16 @@ impl Key {
|
|||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # #[cfg(web_platform)]
|
||||
/// # wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
|
||||
/// # #[cfg_attr(web_platform, wasm_bindgen_test::wasm_bindgen_test)]
|
||||
/// # fn main() {
|
||||
/// use winit::keyboard::{Key, NamedKey};
|
||||
///
|
||||
/// assert_eq!(Key::Character("a".into()).to_text(), Some("a"));
|
||||
/// assert_eq!(Key::Named(NamedKey::Enter).to_text(), Some("\r"));
|
||||
/// assert_eq!(Key::Named(NamedKey::F20).to_text(), None);
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn to_text(&self) -> Option<&str> {
|
||||
match self {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue