docs: don't build platform docs for docsrs

Due to casts and use of platform specific crates in those modules
it's not really feasible to build docs for them.

After separating crates, thus should become way easier to navigate,
since backends information would be publicly available.
This commit is contained in:
Kirill Chibisov 2025-02-08 14:19:58 +03:00
parent f1c5afd84e
commit b3dcfa1275
7 changed files with 43 additions and 46 deletions

View file

@ -2,7 +2,7 @@
use crate::event::{DeviceEvent, DeviceId, StartCause, WindowEvent};
use crate::event_loop::ActiveEventLoop;
#[cfg(any(docsrs, macos_platform))]
#[cfg(macos_platform)]
use crate::platform::macos::ApplicationHandlerExtMacOS;
use crate::window::WindowId;
@ -349,7 +349,7 @@ pub trait ApplicationHandler {
/// The macOS-specific handler.
///
/// The return value from this should not change at runtime.
#[cfg(any(docsrs, macos_platform))]
#[cfg(macos_platform)]
#[inline(always)]
fn macos_handler(&mut self) -> Option<&mut dyn ApplicationHandlerExtMacOS> {
None
@ -423,7 +423,7 @@ impl<A: ?Sized + ApplicationHandler> ApplicationHandler for &mut A {
(**self).memory_warning(event_loop);
}
#[cfg(any(docsrs, macos_platform))]
#[cfg(macos_platform)]
#[inline]
fn macos_handler(&mut self) -> Option<&mut dyn ApplicationHandlerExtMacOS> {
(**self).macos_handler()
@ -497,7 +497,7 @@ impl<A: ?Sized + ApplicationHandler> ApplicationHandler for Box<A> {
(**self).memory_warning(event_loop);
}
#[cfg(any(docsrs, macos_platform))]
#[cfg(macos_platform)]
#[inline]
fn macos_handler(&mut self) -> Option<&mut dyn ApplicationHandlerExtMacOS> {
(**self).macos_handler()

View file

@ -657,11 +657,11 @@ pub enum DeviceEvent {
/// **Web:** Only returns raw data, not OS accelerated, if [`CursorGrabMode::Locked`] is used
/// and browser support is available, see
#[cfg_attr(
any(web_platform, docsrs),
web_platform,
doc = "[`ActiveEventLoopExtWeb::is_cursor_lock_raw()`][crate::platform::web::ActiveEventLoopExtWeb::is_cursor_lock_raw()]."
)]
#[cfg_attr(
not(any(web_platform, docsrs)),
not(web_platform),
doc = "`ActiveEventLoopExtWeb::is_cursor_lock_raw()`."
)]
///

View file

@ -198,10 +198,10 @@ impl EventLoop {
///
/// Web applications are recommended to use
#[cfg_attr(
any(web_platform, docsrs),
web_platform,
doc = " [`EventLoopExtWeb::spawn_app()`][crate::platform::web::EventLoopExtWeb::spawn_app()]"
)]
#[cfg_attr(not(any(web_platform, docsrs)), doc = " `EventLoopExtWeb::spawn_app()`")]
#[cfg_attr(not(web_platform), doc = " `EventLoopExtWeb::spawn_app()`")]
/// [^1] instead of [`run_app()`] to avoid the need for the Javascript exception trick, and to
/// make it clearer that the event loop runs asynchronously (via the browser's own,
/// internal, event loop) and doesn't block the current thread of execution like it does
@ -332,10 +332,10 @@ pub trait ActiveEventLoop: AsAny + fmt::Debug {
///
/// **Web:** Only returns the current monitor without
#[cfg_attr(
any(web_platform, docsrs),
web_platform,
doc = "[detailed monitor permissions][crate::platform::web::ActiveEventLoopExtWeb::request_detailed_monitor_permission]."
)]
#[cfg_attr(not(any(web_platform, docsrs)), doc = "detailed monitor permissions.")]
#[cfg_attr(not(web_platform), doc = "detailed monitor permissions.")]
fn available_monitors(&self) -> Box<dyn Iterator<Item = MonitorHandle>>;
/// Returns the primary monitor of the system.
@ -347,10 +347,10 @@ pub trait ActiveEventLoop: AsAny + fmt::Debug {
/// - **Wayland:** Always returns `None`.
/// - **Web:** Always returns `None` without
#[cfg_attr(
any(web_platform, docsrs),
web_platform,
doc = " [detailed monitor permissions][crate::platform::web::ActiveEventLoopExtWeb::request_detailed_monitor_permission]."
)]
#[cfg_attr(not(any(web_platform, docsrs)), doc = " detailed monitor permissions.")]
#[cfg_attr(not(web_platform), doc = " detailed monitor permissions.")]
fn primary_monitor(&self) -> Option<MonitorHandle>;
/// Change if or when [`DeviceEvent`]s are captured.

View file

@ -30,17 +30,17 @@ use crate::utils::AsAny;
///
/// **Web:** A [`MonitorHandle`] created without
#[cfg_attr(
any(web_platform, docsrs),
web_platform,
doc = "[detailed monitor permissions][crate::platform::web::ActiveEventLoopExtWeb::request_detailed_monitor_permission]."
)]
#[cfg_attr(not(any(web_platform, docsrs)), doc = "detailed monitor permissions.")]
#[cfg_attr(not(web_platform), doc = "detailed monitor permissions.")]
/// will always represent the current monitor the browser window is in instead of a specific
/// monitor. See
#[cfg_attr(
any(web_platform, docsrs),
web_platform,
doc = "[`MonitorHandleExtWeb::is_detailed()`][crate::platform::web::MonitorHandleExtWeb::is_detailed]"
)]
#[cfg_attr(not(any(web_platform, docsrs)), doc = "`MonitorHandleExtWeb::is_detailed()`")]
#[cfg_attr(not(web_platform), doc = "`MonitorHandleExtWeb::is_detailed()`")]
/// to check.
///
/// [`Window`]: crate::window::Window
@ -91,10 +91,10 @@ pub trait MonitorHandleProvider: AsAny + fmt::Debug + Send + Sync {
///
/// **Web:** Always returns [`None`] without
#[cfg_attr(
any(web_platform, docsrs),
web_platform,
doc = "[detailed monitor permissions][crate::platform::web::ActiveEventLoopExtWeb::request_detailed_monitor_permission]."
)]
#[cfg_attr(not(any(web_platform, docsrs)), doc = "detailed monitor permissions.")]
#[cfg_attr(not(web_platform), doc = "detailed monitor permissions.")]
fn name(&self) -> Option<Cow<'_, str>>;
/// Returns the top-left corner position of the monitor in desktop coordinates.
@ -107,10 +107,10 @@ pub trait MonitorHandleProvider: AsAny + fmt::Debug + Send + Sync {
///
/// **Web:** Always returns [`None`] without
#[cfg_attr(
any(web_platform, docsrs),
web_platform,
doc = "[detailed monitor permissions][crate::platform::web::ActiveEventLoopExtWeb::request_detailed_monitor_permission]."
)]
#[cfg_attr(not(any(web_platform, docsrs)), doc = "detailed monitor permissions.")]
#[cfg_attr(not(web_platform), doc = "detailed monitor permissions.")]
fn position(&self) -> Option<PhysicalPosition<i32>>;
/// Returns the scale factor of the underlying monitor. To map logical pixels to physical
@ -125,10 +125,10 @@ pub trait MonitorHandleProvider: AsAny + fmt::Debug + Send + Sync {
/// - **Android:** Always returns 1.0.
/// - **Web:** Always returns `0.0` without
#[cfg_attr(
any(web_platform, docsrs),
web_platform,
doc = " [detailed monitor permissions][crate::platform::web::ActiveEventLoopExtWeb::request_detailed_monitor_permission]."
)]
#[cfg_attr(not(any(web_platform, docsrs)), doc = " detailed monitor permissions.")]
#[cfg_attr(not(web_platform), doc = " detailed monitor permissions.")]
///
#[rustfmt::skip]
/// [`Window::scale_factor`]: crate::window::Window::scale_factor

View file

@ -2,23 +2,23 @@
//!
//! Only the modules corresponding to the platform you're compiling to will be available.
#[cfg(any(android_platform, docsrs))]
#[cfg(android_platform)]
pub mod android;
#[cfg(any(ios_platform, docsrs))]
#[cfg(ios_platform)]
pub mod ios;
#[cfg(any(macos_platform, docsrs))]
#[cfg(macos_platform)]
pub mod macos;
#[cfg(any(orbital_platform, docsrs))]
#[cfg(orbital_platform)]
pub mod orbital;
#[cfg(any(x11_platform, wayland_platform, docsrs))]
#[cfg(any(x11_platform, wayland_platform))]
pub mod startup_notify;
#[cfg(any(wayland_platform, docsrs))]
#[cfg(wayland_platform)]
pub mod wayland;
#[cfg(any(web_platform, docsrs))]
#[cfg(web_platform)]
pub mod web;
#[cfg(any(windows_platform, docsrs))]
#[cfg(windows_platform)]
pub mod windows;
#[cfg(any(x11_platform, docsrs))]
#[cfg(x11_platform)]
pub mod x11;
#[allow(unused_imports)]

View file

@ -33,10 +33,10 @@ pub trait EventLoopExtRunOnDemand {
/// to the caller (specifically this is impossible on iOS and Web - though with the Web
/// backend it is possible to use
#[cfg_attr(
any(web_platform, docsrs),
web_platform,
doc = " [`EventLoopExtWeb::spawn_app()`][crate::platform::web::EventLoopExtWeb::spawn_app()]"
)]
#[cfg_attr(not(any(web_platform, docsrs)), doc = " `EventLoopExtWeb::spawn_app()`")]
#[cfg_attr(not(web_platform), doc = " `EventLoopExtWeb::spawn_app()`")]
/// [^1] more than once instead).
/// - No [`Window`] state can be carried between separate runs of the event loop.
///

View file

@ -593,12 +593,12 @@ pub trait Window: AsAny + Send + Sync + fmt::Debug {
///
/// [`outer_position`]: Self::outer_position
#[cfg_attr(
any(macos_platform, docsrs),
macos_platform,
doc = "[`with_titlebar_transparent`]: \
crate::platform::macos::WindowAttributesExtMacOS::with_titlebar_transparent"
)]
#[cfg_attr(
not(any(macos_platform, docsrs)),
not(macos_platform),
doc = "[`with_titlebar_transparent`]: #only-available-on-macos"
)]
fn surface_position(&self) -> PhysicalPosition<i32>;
@ -966,10 +966,10 @@ pub trait Window: AsAny + Send + Sync + fmt::Debug {
/// - **Android / Orbital:** Unsupported.
/// - **Web:** Passing a [`MonitorHandle`] or [`VideoMode`] that was not created with
#[cfg_attr(
any(web_platform, docsrs),
web_platform,
doc = " [detailed monitor permissions][crate::platform::web::ActiveEventLoopExtWeb::request_detailed_monitor_permission]"
)]
#[cfg_attr(not(any(web_platform, docsrs)), doc = " detailed monitor permissions")]
#[cfg_attr(not(web_platform), doc = " detailed monitor permissions")]
/// or calling without a [transient activation] does nothing.
///
/// [transient activation]: https://developer.mozilla.org/en-US/docs/Glossary/Transient_activation
@ -1299,10 +1299,10 @@ pub trait Window: AsAny + Send + Sync + fmt::Debug {
///
/// **Web:** Only returns the current monitor without
#[cfg_attr(
any(web_platform, docsrs),
web_platform,
doc = "[detailed monitor permissions][crate::platform::web::ActiveEventLoopExtWeb::request_detailed_monitor_permission]."
)]
#[cfg_attr(not(any(web_platform, docsrs)), doc = "detailed monitor permissions.")]
#[cfg_attr(not(any(web_platform,)), doc = "detailed monitor permissions.")]
///
#[rustfmt::skip]
/// [`ActiveEventLoop::available_monitors`]: crate::event_loop::ActiveEventLoop::available_monitors
@ -1319,10 +1319,10 @@ pub trait Window: AsAny + Send + Sync + fmt::Debug {
/// - **Wayland:** Always returns `None`.
/// - **Web:** Always returns `None` without
#[cfg_attr(
any(web_platform, docsrs),
web_platform,
doc = " [detailed monitor permissions][crate::platform::web::ActiveEventLoopExtWeb::request_detailed_monitor_permission]."
)]
#[cfg_attr(not(any(web_platform, docsrs)), doc = " detailed monitor permissions.")]
#[cfg_attr(not(web_platform), doc = " detailed monitor permissions.")]
///
#[rustfmt::skip]
/// [`ActiveEventLoop::primary_monitor`]: crate::event_loop::ActiveEventLoop::primary_monitor
@ -1549,13 +1549,10 @@ impl ActivationToken {
///
/// To obtain a valid token, use
#[cfg_attr(
any(x11_platform, wayland_platform, docsrs),
any(x11_platform, wayland_platform),
doc = " [`request_activation_token`](crate::platform::startup_notify::WindowExtStartupNotify::request_activation_token)."
)]
#[cfg_attr(
not(any(x11_platform, wayland_platform, docsrs)),
doc = " `request_activation_token`."
)]
#[cfg_attr(not(any(x11_platform, wayland_platform)), doc = " `request_activation_token`.")]
pub fn from_raw(token: String) -> Self {
Self { token }
}