1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 06:10:06 -04:00

Improve documentation of eframe, especially for wasm32 (#3295)

* Improve documentation of `eframe`, especially for wasm32

* remove dead code

* fix
This commit is contained in:
Emil Ernerfeldt
2023-09-04 09:55:47 +02:00
committed by GitHub
parent 209cbeb030
commit 5f742b9aba
12 changed files with 69 additions and 61 deletions

View File

@@ -50,7 +50,7 @@
//! #[derive(Clone)]
//! #[wasm_bindgen]
//! pub struct WebHandle {
//! runner: WebRunner,
//! runner: eframe::WebRunner,
//! }
//!
//! # #[cfg(target_arch = "wasm32")]
@@ -64,7 +64,7 @@
//! eframe::WebLogger::init(log::LevelFilter::Debug).ok();
//!
//! Self {
//! runner: WebRunner::new(),
//! runner: eframe::WebRunner::new(),
//! }
//! }
//!
@@ -82,6 +82,7 @@
//!
//! // The following are optional:
//!
//! /// Shut down eframe and clean up resources.
//! #[wasm_bindgen]
//! pub fn destroy(&self) {
//! self.runner.destroy();
@@ -121,6 +122,7 @@
#![cfg_attr(feature = "document-features", doc = document_features::document_features!())]
//!
#![warn(missing_docs)] // let's keep eframe well-documented
#![allow(clippy::needless_doctest_main)]
// Re-export all useful libraries:
@@ -296,23 +298,28 @@ pub fn run_simple_native(
/// The different problems that can occur when trying to run `eframe`.
#[derive(thiserror::Error, Debug)]
pub enum Error {
/// An error from [`winit`].
#[cfg(not(target_arch = "wasm32"))]
#[error("winit error: {0}")]
Winit(#[from] winit::error::OsError),
/// An error from [`glutin`] when using [`glow`].
#[cfg(all(feature = "glow", not(target_arch = "wasm32")))]
#[error("glutin error: {0}")]
Glutin(#[from] glutin::error::Error),
/// An error from [`glutin`] when using [`glow`].
#[cfg(all(feature = "glow", not(target_arch = "wasm32")))]
#[error("Found no glutin configs matching the template: {0:?}. error: {1:?}")]
#[error("Found no glutin configs matching the template: {0:?}. Error: {1:?}")]
NoGlutinConfigs(glutin::config::ConfigTemplate, Box<dyn std::error::Error>),
/// An error from [`wgpu`].
#[cfg(feature = "wgpu")]
#[error("WGPU error: {0}")]
Wgpu(#[from] egui_wgpu::WgpuError),
}
/// Short for `Result<T, eframe::Error>`.
pub type Result<T> = std::result::Result<T, Error>;
// ---------------------------------------------------------------------------