From cd170799cc270f4793936c3dcb7e51f61948f973 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Mon, 20 May 2024 09:55:50 +0100 Subject: [PATCH 1/9] Use doc_auto_cfg in place of doc_cfg This leaves internal_doc items untouched. --- Cargo.toml | 4 ++-- crates/kas-core/Cargo.toml | 2 +- crates/kas-core/src/config/format.rs | 6 ------ crates/kas-core/src/event/cx/cx_pub.rs | 1 - crates/kas-core/src/event/cx/platform.rs | 1 - crates/kas-core/src/geom.rs | 1 - crates/kas-core/src/lib.rs | 1 + crates/kas-resvg/Cargo.toml | 2 +- crates/kas-resvg/src/lib.rs | 2 +- crates/kas-resvg/src/svg.rs | 1 - crates/kas-view/Cargo.toml | 2 +- crates/kas-view/src/lib.rs | 2 +- crates/kas-wgpu/Cargo.toml | 2 +- crates/kas-wgpu/src/lib.rs | 1 + crates/kas-widgets/Cargo.toml | 2 +- crates/kas-widgets/src/image.rs | 5 ----- crates/kas-widgets/src/lib.rs | 2 +- src/lib.rs | 8 +------- 18 files changed, 13 insertions(+), 32 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5db0748b4..b211cd92b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,9 +15,9 @@ rust-version = "1.75.0" [package.metadata.docs.rs] features = ["stable"] -rustdoc-args = ["--cfg", "doc_cfg"] +rustdoc-args = ["--cfg", "docsrs"] # To build locally: -# RUSTDOCFLAGS="--cfg doc_cfg" cargo +nightly doc --features=stable,internal_doc --all --no-deps --open +# RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --features=stable,internal_doc --all --no-deps --open [features] ######### meta / build features ######### diff --git a/crates/kas-core/Cargo.toml b/crates/kas-core/Cargo.toml index b9477285a..4fbd5ca9f 100644 --- a/crates/kas-core/Cargo.toml +++ b/crates/kas-core/Cargo.toml @@ -14,7 +14,7 @@ exclude = ["/screenshots"] [package.metadata.docs.rs] features = ["stable"] -rustdoc-args = ["--cfg", "doc_cfg"] +rustdoc-args = ["--cfg", "doc_cfg", "--cfg", "docsrs"] [features] # The minimal feature set needed to build basic applications (with assumptions diff --git a/crates/kas-core/src/config/format.rs b/crates/kas-core/src/config/format.rs index 9d2ad4f87..2570abd1a 100644 --- a/crates/kas-core/src/config/format.rs +++ b/crates/kas-core/src/config/format.rs @@ -14,32 +14,26 @@ use thiserror::Error; #[derive(Error, Debug)] pub enum Error { #[cfg(feature = "yaml")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "yaml")))] #[error("config (de)serialisation to YAML failed")] Yaml(#[from] serde_yaml::Error), #[cfg(feature = "json")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "json")))] #[error("config (de)serialisation to JSON failed")] Json(#[from] serde_json::Error), #[cfg(feature = "ron")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "ron")))] #[error("config serialisation to RON failed")] Ron(#[from] ron::Error), #[cfg(feature = "ron")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "ron")))] #[error("config deserialisation from RON failed")] RonSpanned(#[from] ron::error::SpannedError), #[cfg(feature = "toml")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "toml")))] #[error("config deserialisation from TOML failed")] TomlDe(#[from] toml::de::Error), #[cfg(feature = "toml")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "toml")))] #[error("config serialisation to TOML failed")] TomlSer(#[from] toml::ser::Error), diff --git a/crates/kas-core/src/event/cx/cx_pub.rs b/crates/kas-core/src/event/cx/cx_pub.rs index 9293cad37..96c765b2f 100644 --- a/crates/kas-core/src/event/cx/cx_pub.rs +++ b/crates/kas-core/src/event/cx/cx_pub.rs @@ -634,7 +634,6 @@ impl EventState { /// available, that may be used instead. See also [`async_global_executor`] /// documentation of configuration. #[cfg(feature = "spawn")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "spawn")))] pub fn push_spawn(&mut self, id: Id, fut: Fut) where Fut: IntoFuture + 'static, diff --git a/crates/kas-core/src/event/cx/platform.rs b/crates/kas-core/src/event/cx/platform.rs index b9409dea5..a254e4626 100644 --- a/crates/kas-core/src/event/cx/platform.rs +++ b/crates/kas-core/src/event/cx/platform.rs @@ -302,7 +302,6 @@ impl<'a> EventCx<'a> { /// events the graphics backend must take direct action anyway: /// `Resized(size)`, `RedrawRequested`, `HiDpiFactorChanged(factor)`. #[cfg(winit)] - #[cfg_attr(doc_cfg, doc(cfg(feature = "winit")))] pub(crate) fn handle_winit( &mut self, win: &mut Window, diff --git a/crates/kas-core/src/geom.rs b/crates/kas-core/src/geom.rs index 3940a81e6..27c6100ed 100644 --- a/crates/kas-core/src/geom.rs +++ b/crates/kas-core/src/geom.rs @@ -633,7 +633,6 @@ impl std::ops::SubAssign for Rect { } #[cfg(winit)] -#[cfg_attr(doc_cfg, doc(cfg(feature = "winit")))] mod winit_impls { use super::{Coord, Size}; use crate::cast::{Cast, CastApprox, Conv, ConvApprox, Result}; diff --git a/crates/kas-core/src/lib.rs b/crates/kas-core/src/lib.rs index 854e7c669..c3692bee4 100644 --- a/crates/kas-core/src/lib.rs +++ b/crates/kas-core/src/lib.rs @@ -11,6 +11,7 @@ //! - [`impl_scope!`], [`impl_anon!`], [`autoimpl`] and [`impl_default`] are //! re-implementations of [`impl-tools`](https://crates.io/crates/impl-tools) macros +#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(doc_cfg, feature(doc_cfg))] #![cfg_attr(feature = "spec", feature(specialization))] diff --git a/crates/kas-resvg/Cargo.toml b/crates/kas-resvg/Cargo.toml index fda83edda..f0a5aa95a 100644 --- a/crates/kas-resvg/Cargo.toml +++ b/crates/kas-resvg/Cargo.toml @@ -14,7 +14,7 @@ exclude = ["/screenshots"] [package.metadata.docs.rs] features = ["docs_rs", "svg"] -rustdoc-args = ["--cfg", "doc_cfg"] +rustdoc-args = ["--cfg", "docsrs"] [features] # Non-local features required for doc builds. diff --git a/crates/kas-resvg/src/lib.rs b/crates/kas-resvg/src/lib.rs index 06d4c5fae..4c4a49d05 100644 --- a/crates/kas-resvg/src/lib.rs +++ b/crates/kas-resvg/src/lib.rs @@ -11,7 +11,7 @@ //! [tiny-skia]: https://crates.io/crates/tiny-skia //! [resvg]: https://crates.io/crates/resvg -#![cfg_attr(doc_cfg, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] pub extern crate tiny_skia; diff --git a/crates/kas-resvg/src/svg.rs b/crates/kas-resvg/src/svg.rs index bc32c6952..edc86b3ea 100644 --- a/crates/kas-resvg/src/svg.rs +++ b/crates/kas-resvg/src/svg.rs @@ -128,7 +128,6 @@ impl_scope! { /// An SVG image loaded from a path /// /// May be default constructed (result is empty). - #[cfg_attr(doc_cfg, doc(cfg(feature = "svg")))] #[autoimpl(Debug ignore self.inner)] #[impl_default] #[derive(Clone)] diff --git a/crates/kas-view/Cargo.toml b/crates/kas-view/Cargo.toml index d57b4e50e..361d719a4 100644 --- a/crates/kas-view/Cargo.toml +++ b/crates/kas-view/Cargo.toml @@ -14,7 +14,7 @@ exclude = ["/screenshots"] [package.metadata.docs.rs] features = ["kas/winit", "kas/wayland"] -rustdoc-args = ["--cfg", "doc_cfg"] +rustdoc-args = ["--cfg", "docsrs"] [dependencies] kas-widgets = { version = "0.14.1", path = "../kas-widgets" } diff --git a/crates/kas-view/src/lib.rs b/crates/kas-view/src/lib.rs index a99ed1b38..daff1a8fb 100644 --- a/crates/kas-view/src/lib.rs +++ b/crates/kas-view/src/lib.rs @@ -25,7 +25,7 @@ //! to cover the visible area, and these are re-used to enable fast scrolling //! through large data sets. -#![cfg_attr(doc_cfg, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] mod data_impls; mod data_traits; diff --git a/crates/kas-wgpu/Cargo.toml b/crates/kas-wgpu/Cargo.toml index 1570d17dc..f69ed6342 100644 --- a/crates/kas-wgpu/Cargo.toml +++ b/crates/kas-wgpu/Cargo.toml @@ -13,7 +13,7 @@ documentation = "https://docs.rs/kas-wgpu/" [package.metadata.docs.rs] features = ["kas/winit", "kas/wayland"] -rustdoc-args = ["--cfg", "doc_cfg"] +rustdoc-args = ["--cfg", "doc_cfg", "--cfg", "docsrs"] [features] # WARNING: if "raster" is disabled, an alternative like "kas-text/fontdue" is required! diff --git a/crates/kas-wgpu/src/lib.rs b/crates/kas-wgpu/src/lib.rs index 04725a9d3..969526218 100644 --- a/crates/kas-wgpu/src/lib.rs +++ b/crates/kas-wgpu/src/lib.rs @@ -18,6 +18,7 @@ //! //! [WGPU]: https://github.com/gfx-rs/wgpu +#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(doc_cfg, feature(doc_cfg))] pub mod draw; diff --git a/crates/kas-widgets/Cargo.toml b/crates/kas-widgets/Cargo.toml index 5df76f8ca..e573b8db6 100644 --- a/crates/kas-widgets/Cargo.toml +++ b/crates/kas-widgets/Cargo.toml @@ -14,7 +14,7 @@ exclude = ["/screenshots"] [package.metadata.docs.rs] features = ["min_spec", "kas/winit", "kas/wayland"] -rustdoc-args = ["--cfg", "doc_cfg"] +rustdoc-args = ["--cfg", "docsrs"] [features] # Use min_specialization (enables access key underlining for AccessLabel) diff --git a/crates/kas-widgets/src/image.rs b/crates/kas-widgets/src/image.rs index 829d33fd1..6fa580726 100644 --- a/crates/kas-widgets/src/image.rs +++ b/crates/kas-widgets/src/image.rs @@ -11,7 +11,6 @@ use kas::prelude::*; /// Image loading errors #[cfg(feature = "image")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "image")))] #[derive(thiserror::Error, Debug)] pub enum ImageError { #[error("IO error")] @@ -23,7 +22,6 @@ pub enum ImageError { } #[cfg(feature = "image")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "image")))] impl From for ImageError { fn from(_: kas::draw::AllocError) -> ImageError { ImageError::Allocation @@ -32,7 +30,6 @@ impl From for ImageError { /// Image `Result` type #[cfg(feature = "image")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "image")))] pub type Result = std::result::Result; impl_scope! { @@ -61,7 +58,6 @@ impl_scope! { /// Construct from a path #[cfg(feature = "image")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "image")))] #[inline] pub fn new_path>( path: P, @@ -89,7 +85,6 @@ impl_scope! { /// /// Returns `Action::RESIZE` on success. On error, `self` is unchanged. #[cfg(feature = "image")] - #[cfg_attr(doc_cfg, doc(cfg(feature = "image")))] pub fn load_path>( &mut self, path: P, diff --git a/crates/kas-widgets/src/lib.rs b/crates/kas-widgets/src/lib.rs index 41dab8da7..58f6552f2 100644 --- a/crates/kas-widgets/src/lib.rs +++ b/crates/kas-widgets/src/lib.rs @@ -58,7 +58,7 @@ //! - [`AccessLabel`]: a label which parses access keys //! - [`GripPart`]: a handle (e.g. for a slider, splitter or scroll_bar) -#![cfg_attr(doc_cfg, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] #![cfg_attr(feature = "min_spec", feature(min_specialization))] pub mod adapt; diff --git a/src/lib.rs b/src/lib.rs index 392d11a32..207319337 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,7 +23,7 @@ //! - [Examples](https://github.com/kas-gui/kas/tree/master/examples) //! - [Discuss](https://github.com/kas-gui/kas/discussions) -#![cfg_attr(doc_cfg, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_auto_cfg))] /// KAS prelude /// @@ -35,10 +35,6 @@ /// This prelude may be more useful when implementing widgets than when simply /// using widgets in a GUI. pub mod prelude { - // Note: using #[doc(no_inline)] here causes doc issues in this crate: - // - kas::Id appears to have no methods - // - doc_cfg annotations appear to be attached to the wrong items - #[doc(no_inline)] pub use kas_core::prelude::*; #[doc(no_inline)] pub use kas_widgets::adapt::{AdaptWidget, AdaptWidgetAny}; @@ -49,7 +45,6 @@ pub use kas_core::*; #[doc(inline)] pub extern crate kas_widgets as widgets; #[cfg(feature = "view")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "view")))] #[doc(inline)] pub extern crate kas_view as view; @@ -63,7 +58,6 @@ pub extern crate kas_view as view; /// `tiny-skia` feature may be used to enable only the `Canvas` widget /// plus support (i.e. everything but `Svg`), saving approx 200 KiB. #[cfg(any(feature = "resvg", feature = "tiny-skia"))] -#[cfg_attr(doc_cfg, doc(cfg(feature = "resvg")))] pub mod resvg { pub use kas_resvg::*; } From f097a1c82f9d6f6043504f9f7b91d50b1149638b Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Mon, 20 May 2024 11:22:04 +0100 Subject: [PATCH 2/9] Remove unreachable feature-gated fn --- crates/kas-core/src/theme/text.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/crates/kas-core/src/theme/text.rs b/crates/kas-core/src/theme/text.rs index 1e1818e6c..1b513a376 100644 --- a/crates/kas-core/src/theme/text.rs +++ b/crates/kas-core/src/theme/text.rs @@ -597,16 +597,6 @@ impl Text { Ok(self.display()?.text_glyph_pos(index)) } - /// Get the number of glyphs - /// - /// See [`TextDisplay::num_glyphs`]. - #[inline] - #[cfg_attr(doc_cfg, doc(cfg(feature = "num_glyphs")))] - #[cfg(feature = "num_glyphs")] - pub fn num_glyphs(&self) -> Result { - Ok(self.wrapped_display()?.num_glyphs()) - } - /// Yield a sequence of positioned glyphs /// /// See [`TextDisplay::glyphs`]. From 59c795e310568e35cd4e602c49c5bd302c20998b Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Mon, 20 May 2024 11:46:12 +0100 Subject: [PATCH 3/9] Add feature kas-core/image to enable load_icon_from_path --- Cargo.toml | 2 +- crates/kas-core/Cargo.toml | 6 +++++- crates/kas-core/src/util.rs | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b211cd92b..6282a47e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,7 +84,7 @@ ron = ["serde", "kas-core/ron"] toml = ["serde", "kas-core/toml"] # Support image loading and decoding -image = ["kas-widgets/image"] +image = ["kas-core/image", "kas-widgets/image"] # Enable resvg module (Canvas + Svg widgets) resvg = ["dep:kas-resvg", "kas-resvg?/svg", "kas-dylib?/resvg"] diff --git a/crates/kas-core/Cargo.toml b/crates/kas-core/Cargo.toml index 4fbd5ca9f..33724d2c1 100644 --- a/crates/kas-core/Cargo.toml +++ b/crates/kas-core/Cargo.toml @@ -21,7 +21,7 @@ rustdoc-args = ["--cfg", "doc_cfg", "--cfg", "docsrs"] # about target platforms). minimal = ["winit", "wayland"] # All standard test target features -stable = ["minimal", "clipboard", "markdown", "shaping", "spawn", "x11", "serde", "toml", "yaml", "json", "ron", "macros_log"] +stable = ["minimal", "clipboard", "markdown", "shaping", "spawn", "x11", "serde", "toml", "yaml", "json", "ron", "macros_log", "image"] # Enables all "recommended" features for nightly rustc nightly = ["stable"] # Additional, less recommendation-worthy features @@ -73,6 +73,9 @@ x11 = ["winit?/x11"] # Enable serde integration (mainly config read/write) serde = ["dep:serde", "kas-text/serde", "winit?/serde"] +# Enable load_icon_from_path utility function +image = ["dep:image"] + # Automatically detect usage of dark theme dark-light = ["dep:dark-light"] @@ -106,6 +109,7 @@ raw-window-handle = "0.6.0" async-global-executor = { version = "2.3.1", optional = true } cfg-if = "1.0.0" smol_str = "0.2.0" +image = { version = "0.25.1", optional = true } [target.'cfg(any(target_os="linux", target_os="dragonfly", target_os="freebsd", target_os="netbsd", target_os="openbsd"))'.dependencies] smithay-clipboard = { version = "0.7.0", optional = true } diff --git a/crates/kas-core/src/util.rs b/crates/kas-core/src/util.rs index 2cccefd15..067304391 100644 --- a/crates/kas-core/src/util.rs +++ b/crates/kas-core/src/util.rs @@ -6,6 +6,8 @@ //! Utilities use crate::geom::Coord; +#[cfg(all(feature = "image", feature = "winit"))] +use crate::Icon; use crate::{Id, Layout, LayoutExt}; use std::fmt; @@ -122,8 +124,7 @@ pub fn nav_next(reverse: bool, from: Option, len: usize) -> Option } /// Load a window icon from a path -#[cfg(feature = "image")] -#[cfg_attr(doc_cfg, doc(cfg(feature = "image")))] +#[cfg(all(feature = "image", feature = "winit"))] pub fn load_icon_from_path>( path: P, ) -> Result> { From 1368528e52e0dfa90b19c5717642c8d06a248e94 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Mon, 20 May 2024 11:34:11 +0100 Subject: [PATCH 4/9] Un-hide Draw*Impl traits Although end users don't implement these, the traits do appear as bounds in other public items. --- crates/kas-core/src/draw/draw.rs | 6 ++---- crates/kas-core/src/draw/draw_rounded.rs | 6 ++---- crates/kas-core/src/draw/draw_shared.rs | 4 +--- crates/kas-wgpu/Cargo.toml | 2 +- crates/kas-wgpu/src/draw_shaded.rs | 6 ++---- crates/kas-wgpu/src/lib.rs | 1 - 6 files changed, 8 insertions(+), 17 deletions(-) diff --git a/crates/kas-core/src/draw/draw.rs b/crates/kas-core/src/draw/draw.rs index f73b31b3a..3a9e064dc 100644 --- a/crates/kas-core/src/draw/draw.rs +++ b/crates/kas-core/src/draw/draw.rs @@ -123,7 +123,7 @@ impl<'a, DS: DrawSharedImpl> DrawIface<'a, DS> { } } -/// Base drawing interface for [`DrawIface`] +/// Basic draw interface for [`DrawIface`] /// /// Most methods draw some feature. Exceptions are those starting with `get_` /// and [`Self::new_dyn_pass`]. @@ -301,7 +301,7 @@ impl<'a, DS: DrawSharedImpl> Draw for DrawIface<'a, DS> { } } -/// Base abstraction over drawing +/// Implementation target for [`Draw`] /// /// This trait covers only the bare minimum of functionality which *must* be /// provided by the graphics backend; extension traits such as [`DrawRoundedImpl`] @@ -318,8 +318,6 @@ impl<'a, DS: DrawSharedImpl> Draw for DrawIface<'a, DS> { /// Draw operations take place over multiple render passes, identified by a /// handle of type [`PassId`]. In general the user only needs to pass this value /// into methods as required. [`DrawImpl::new_pass`] creates a new [`PassId`]. -#[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] pub trait DrawImpl: Any { /// Access common data fn common_mut(&mut self) -> &mut WindowCommon; diff --git a/crates/kas-core/src/draw/draw_rounded.rs b/crates/kas-core/src/draw/draw_rounded.rs index 68b03355f..cb83281ad 100644 --- a/crates/kas-core/src/draw/draw_rounded.rs +++ b/crates/kas-core/src/draw/draw_rounded.rs @@ -9,7 +9,7 @@ use super::color::Rgba; use super::{Draw, DrawIface, DrawImpl, DrawSharedImpl, PassId}; use crate::geom::{Quad, Vec2}; -/// Extension over [`Draw`] for rounded shapes +/// Extended draw interface for [`DrawIface`] providing rounded drawing /// /// All methods draw some feature. pub trait DrawRounded: Draw { @@ -94,15 +94,13 @@ where } } -/// Drawing commands for rounded shapes +/// Implementation target for [`DrawRounded`] /// /// This trait is an extension over [`DrawImpl`] providing rounded shapes. /// /// The primitives provided by this trait are partially transparent. /// If the implementation buffers draw commands, it should draw these /// primitives after solid primitives. -#[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] pub trait DrawRoundedImpl: DrawImpl { /// Draw a line with rounded ends and uniform colour fn rounded_line(&mut self, pass: PassId, p1: Vec2, p2: Vec2, radius: f32, col: Rgba); diff --git a/crates/kas-core/src/draw/draw_shared.rs b/crates/kas-core/src/draw/draw_shared.rs index fda2bc720..0e3f1ffd1 100644 --- a/crates/kas-core/src/draw/draw_shared.rs +++ b/crates/kas-core/src/draw/draw_shared.rs @@ -141,11 +141,9 @@ impl DrawShared for SharedState { } } -/// Trait over shared data of draw object +/// Implementation target for [`DrawShared`] /// /// This is typically used via [`SharedState`]. -#[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] pub trait DrawSharedImpl: Any { type Draw: DrawImpl; diff --git a/crates/kas-wgpu/Cargo.toml b/crates/kas-wgpu/Cargo.toml index f69ed6342..052b6993c 100644 --- a/crates/kas-wgpu/Cargo.toml +++ b/crates/kas-wgpu/Cargo.toml @@ -13,7 +13,7 @@ documentation = "https://docs.rs/kas-wgpu/" [package.metadata.docs.rs] features = ["kas/winit", "kas/wayland"] -rustdoc-args = ["--cfg", "doc_cfg", "--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [features] # WARNING: if "raster" is disabled, an alternative like "kas-text/fontdue" is required! diff --git a/crates/kas-wgpu/src/draw_shaded.rs b/crates/kas-wgpu/src/draw_shaded.rs index a17d5ccfd..2078883f9 100644 --- a/crates/kas-wgpu/src/draw_shaded.rs +++ b/crates/kas-wgpu/src/draw_shaded.rs @@ -9,7 +9,7 @@ use kas::draw::color::Rgba; use kas::draw::{DrawIface, DrawImpl, DrawSharedImpl, PassId}; use kas::geom::Quad; -/// Extension trait providing shaded drawing over [`DrawIface`] +/// Extension trait providing shaded drawing for [`DrawIface`] /// /// All methods draw some feature. /// @@ -74,7 +74,7 @@ where } } -/// Drawing commands for shaded shapes +/// Extended draw interface for [`DrawIface`] providing shaded drawing /// /// This trait is an extension over [`DrawImpl`] providing solid shaded shapes. /// @@ -85,8 +85,6 @@ where /// Methods are parameterised via a pair of normals, `(inner, outer)`. These may /// have values from the closed range `[-1, 1]`, where -1 points inwards, /// 0 is perpendicular to the screen towards the viewer, and 1 points outwards. -#[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] pub trait DrawShadedImpl: DrawImpl { /// Add a shaded square to the draw buffer fn shaded_square(&mut self, pass: PassId, rect: Quad, norm: (f32, f32), col: Rgba); diff --git a/crates/kas-wgpu/src/lib.rs b/crates/kas-wgpu/src/lib.rs index 969526218..292c9190a 100644 --- a/crates/kas-wgpu/src/lib.rs +++ b/crates/kas-wgpu/src/lib.rs @@ -19,7 +19,6 @@ //! [WGPU]: https://github.com/gfx-rs/wgpu #![cfg_attr(docsrs, feature(doc_auto_cfg))] -#![cfg_attr(doc_cfg, feature(doc_cfg))] pub mod draw; mod draw_shaded; From 075a4323c455c6396a75e8fed8dc7be6de66b9dc Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Mon, 20 May 2024 11:36:42 +0100 Subject: [PATCH 5/9] Use cfg docsrs for internal_doc doc_cfg Unfortunately doc_cfg still doesn't work correctly with re-exports --- crates/kas-core/Cargo.toml | 2 +- crates/kas-core/src/action.rs | 6 +++--- crates/kas-core/src/app/app.rs | 2 +- crates/kas-core/src/app/common.rs | 4 ---- crates/kas-core/src/app/mod.rs | 5 ++++- crates/kas-core/src/config/config.rs | 2 +- crates/kas-core/src/core/data.rs | 4 ++-- crates/kas-core/src/core/mod.rs | 2 +- crates/kas-core/src/core/node.rs | 2 +- crates/kas-core/src/core/widget.rs | 12 ++++++------ crates/kas-core/src/draw/draw.rs | 10 +++++----- crates/kas-core/src/draw/draw_shared.rs | 4 ++-- crates/kas-core/src/draw/mod.rs | 6 ++---- crates/kas-core/src/event/components.rs | 2 +- crates/kas-core/src/event/cx/config.rs | 2 +- crates/kas-core/src/event/cx/mod.rs | 2 +- crates/kas-core/src/event/cx/platform.rs | 4 ++-- crates/kas-core/src/event/events.rs | 2 +- crates/kas-core/src/layout/mod.rs | 6 +++++- crates/kas-core/src/layout/size_rules.rs | 4 ++-- crates/kas-core/src/layout/visitor.rs | 6 ------ crates/kas-core/src/lib.rs | 4 ++-- crates/kas-core/src/theme/draw.rs | 4 +--- crates/kas-core/src/theme/mod.rs | 4 +++- crates/kas-core/src/theme/size.rs | 4 +--- crates/kas-core/src/util.rs | 2 +- 26 files changed, 50 insertions(+), 57 deletions(-) diff --git a/crates/kas-core/Cargo.toml b/crates/kas-core/Cargo.toml index 33724d2c1..34e19c5e2 100644 --- a/crates/kas-core/Cargo.toml +++ b/crates/kas-core/Cargo.toml @@ -14,7 +14,7 @@ exclude = ["/screenshots"] [package.metadata.docs.rs] features = ["stable"] -rustdoc-args = ["--cfg", "doc_cfg", "--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs"] [features] # The minimal feature set needed to build basic applications (with assumptions diff --git a/crates/kas-core/src/action.rs b/crates/kas-core/src/action.rs index e21ce8e26..71eaa85c7 100644 --- a/crates/kas-core/src/action.rs +++ b/crates/kas-core/src/action.rs @@ -48,19 +48,19 @@ bitflags! { /// /// Implies [`Action::RESIZE`]. #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] const THEME_UPDATE = 1 << 10; /// Reload per-window cache of event configuration /// /// Implies [`Action::UPDATE`]. #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] const EVENT_CONFIG = 1 << 11; /// Switch themes, replacing theme-window instances /// /// Implies [`Action::RESIZE`]. #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] const THEME_SWITCH = 1 << 12; /// Reconfigure all widgets of the window /// diff --git a/crates/kas-core/src/app/app.rs b/crates/kas-core/src/app/app.rs index 05c333fd5..7630c8a3e 100644 --- a/crates/kas-core/src/app/app.rs +++ b/crates/kas-core/src/app/app.rs @@ -32,7 +32,7 @@ impl_scope! { impl Self { /// Construct from a graphics backend and a theme #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub fn new(graphical: G, theme: T) -> Self { AppBuilder { graphical, diff --git a/crates/kas-core/src/app/common.rs b/crates/kas-core/src/app/common.rs index a569bd5cb..cea6448f9 100644 --- a/crates/kas-core/src/app/common.rs +++ b/crates/kas-core/src/app/common.rs @@ -175,8 +175,6 @@ impl Platform { /// Builder for a graphics backend /// /// See also [`Application`](super::Application). -#[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] pub trait AppGraphicsBuilder { /// The default theme type DefaultTheme: Default + Theme; @@ -203,8 +201,6 @@ pub trait AppGraphicsBuilder { } /// Window graphical surface requirements -#[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] pub trait WindowSurface { /// Shared draw state type Shared: kas::draw::DrawSharedImpl; diff --git a/crates/kas-core/src/app/mod.rs b/crates/kas-core/src/app/mod.rs index 18e11e2b3..ecea75b0c 100644 --- a/crates/kas-core/src/app/mod.rs +++ b/crates/kas-core/src/app/mod.rs @@ -21,11 +21,14 @@ pub(crate) use window::{Window, WindowDataErased}; #[cfg(winit)] pub use app::{AppAssoc, AppBuilder, Application, ClosedError, Proxy}; +pub use common::{Error, Platform, Result}; + #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] +#[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub use common::{AppGraphicsBuilder, WindowSurface}; -pub use common::{Error, Platform, Result}; #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] +#[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub extern crate raw_window_handle; /// Application state diff --git a/crates/kas-core/src/config/config.rs b/crates/kas-core/src/config/config.rs index f3e0a3053..d9e1798ea 100644 --- a/crates/kas-core/src/config/config.rs +++ b/crates/kas-core/src/config/config.rs @@ -249,7 +249,7 @@ impl WindowConfig { /// Minimum frame time #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] #[inline] pub fn frame_dur(&self) -> Duration { self.frame_dur diff --git a/crates/kas-core/src/core/data.rs b/crates/kas-core/src/core/data.rs index 26afa4a5d..203f0cc02 100644 --- a/crates/kas-core/src/core/data.rs +++ b/crates/kas-core/src/core/data.rs @@ -39,7 +39,7 @@ pub struct CoreData { pub rect: Rect, pub id: Id, #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] #[cfg(debug_assertions)] pub status: WidgetStatus, } @@ -63,7 +63,7 @@ impl Clone for CoreData { /// /// It is not used in release builds. #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] +#[cfg_attr(docsrs, doc(cfg(internal_doc)))] #[cfg(debug_assertions)] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)] pub enum WidgetStatus { diff --git a/crates/kas-core/src/core/mod.rs b/crates/kas-core/src/core/mod.rs index b202a1751..3d52ce23d 100644 --- a/crates/kas-core/src/core/mod.rs +++ b/crates/kas-core/src/core/mod.rs @@ -14,7 +14,7 @@ mod widget; mod widget_id; #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] +#[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub mod impls; pub use collection::{CellCollection, Collection}; diff --git a/crates/kas-core/src/core/node.rs b/crates/kas-core/src/core/node.rs index d1245b1fc..0019fb2fc 100644 --- a/crates/kas-core/src/core/node.rs +++ b/crates/kas-core/src/core/node.rs @@ -285,7 +285,7 @@ impl<'a> Node<'a> { } #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] +#[cfg_attr(docsrs, doc(cfg(internal_doc)))] impl<'a> Node<'a> { /// Get size rules for the given axis pub(crate) fn size_rules(&mut self, sizer: SizeCx, axis: AxisInfo) -> SizeRules { diff --git a/crates/kas-core/src/core/widget.rs b/crates/kas-core/src/core/widget.rs index 851e69004..7898d92d2 100644 --- a/crates/kas-core/src/core/widget.rs +++ b/crates/kas-core/src/core/widget.rs @@ -242,7 +242,7 @@ pub trait Events: Widget + Sized { /// Action of Widget::_nav_next #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] +#[cfg_attr(docsrs, doc(cfg(internal_doc)))] #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum NavAdvance { /// Match only `focus` if navigable @@ -383,21 +383,21 @@ pub trait Widget: Layout { /// /// Do not implement this method directly! #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] fn _configure(&mut self, cx: &mut ConfigCx, data: &Self::Data, id: Id); /// Internal method: update recursively /// /// Do not implement this method directly! #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] fn _update(&mut self, cx: &mut ConfigCx, data: &Self::Data); /// Internal method: send recursively /// /// Do not implement this method directly! #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] fn _send(&mut self, cx: &mut EventCx, data: &Self::Data, id: Id, event: Event) -> IsUsed; /// Internal method: replay recursively @@ -407,7 +407,7 @@ pub trait Widget: Layout { /// /// Do not implement this method directly! #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] fn _replay(&mut self, cx: &mut EventCx, data: &Self::Data, id: Id); /// Internal method: search for the previous/next navigation target @@ -416,7 +416,7 @@ pub trait Widget: Layout { /// /// Do not implement this method directly! #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] fn _nav_next( &mut self, cx: &mut ConfigCx, diff --git a/crates/kas-core/src/draw/draw.rs b/crates/kas-core/src/draw/draw.rs index 3a9e064dc..e72e0653c 100644 --- a/crates/kas-core/src/draw/draw.rs +++ b/crates/kas-core/src/draw/draw.rs @@ -46,13 +46,13 @@ use std::time::Instant; /// automatically for structs containing references.) pub struct DrawIface<'a, DS: DrawSharedImpl> { #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub draw: &'a mut DS::Draw, #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub shared: &'a mut SharedState, #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub pass: PassId, } @@ -61,7 +61,7 @@ impl<'a, DS: DrawSharedImpl> DrawIface<'a, DS> { /// /// For usage by graphics backends. #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub fn new(draw: &'a mut DS::Draw, shared: &'a mut SharedState) -> Self { DrawIface { draw, @@ -153,7 +153,7 @@ pub trait Draw { /// Cast fields to [`Any`] references #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] fn get_fields_as_any_mut(&mut self) -> (&mut dyn Any, &mut dyn Any); /// Add a draw pass diff --git a/crates/kas-core/src/draw/draw_shared.rs b/crates/kas-core/src/draw/draw_shared.rs index 0e3f1ffd1..17bfa2b15 100644 --- a/crates/kas-core/src/draw/draw_shared.rs +++ b/crates/kas-core/src/draw/draw_shared.rs @@ -38,7 +38,7 @@ impl ImageHandle { impl ImageId { /// Construct a new identifier from `u32` value not equal to 0 #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] #[inline] pub const fn try_new(n: u32) -> Option { // We can't use ? or .map in a const fn so do it the tedious way: @@ -78,7 +78,7 @@ pub struct SharedState { } #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] +#[cfg_attr(docsrs, doc(cfg(internal_doc)))] impl SharedState { /// Construct (this is only called by the graphics backend) pub fn new(draw: DS) -> Self { diff --git a/crates/kas-core/src/draw/mod.rs b/crates/kas-core/src/draw/mod.rs index 04419702e..a10f2dcc4 100644 --- a/crates/kas-core/src/draw/mod.rs +++ b/crates/kas-core/src/draw/mod.rs @@ -52,8 +52,6 @@ pub use draw_shared::{DrawShared, DrawSharedImpl, SharedState}; use std::time::{Duration, Instant}; /// Animation status -#[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[crate::impl_default(AnimationState::None)] pub(crate) enum AnimationState { @@ -80,7 +78,7 @@ impl AnimationState { /// Per-window "draw" data common to all backends #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] +#[cfg_attr(docsrs, doc(cfg(internal_doc)))] #[derive(Debug, Default)] pub struct WindowCommon { pub(crate) anim: AnimationState, @@ -105,7 +103,7 @@ pub struct PassId(u32); impl PassId { /// Construct a new pass from a `u32` identifier #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] #[inline] pub const fn new(n: u32) -> Self { PassId(n) diff --git a/crates/kas-core/src/event/components.rs b/crates/kas-core/src/event/components.rs index 8fb3f84e9..aeb9d1d6e 100644 --- a/crates/kas-core/src/event/components.rs +++ b/crates/kas-core/src/event/components.rs @@ -208,7 +208,7 @@ impl ScrollComponent { /// This is identical to [`Self::focus_rect`] except that it does not call /// [`EventCx::set_scroll`], thus will not affect ancestors. #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub fn self_focus_rect(&mut self, rect: Rect, window_rect: Rect) -> Action { self.glide.stop(); let v = rect.pos - window_rect.pos; diff --git a/crates/kas-core/src/event/cx/config.rs b/crates/kas-core/src/event/cx/config.rs index 3c80b99b7..a172bc4bf 100644 --- a/crates/kas-core/src/event/cx/config.rs +++ b/crates/kas-core/src/event/cx/config.rs @@ -34,7 +34,7 @@ pub struct ConfigCx<'a> { impl<'a> ConfigCx<'a> { /// Construct #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub fn new(sh: &'a dyn ThemeSize, ev: &'a mut EventState) -> Self { ConfigCx { sh, ev } } diff --git a/crates/kas-core/src/event/cx/mod.rs b/crates/kas-core/src/event/cx/mod.rs index bccaec4fc..635c77e87 100644 --- a/crates/kas-core/src/event/cx/mod.rs +++ b/crates/kas-core/src/event/cx/mod.rs @@ -221,7 +221,7 @@ pub struct EventState { pending_nav_focus: PendingNavFocus, pending_cmds: VecDeque<(Id, Command)>, #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub action: Action, } diff --git a/crates/kas-core/src/event/cx/platform.rs b/crates/kas-core/src/event/cx/platform.rs index a254e4626..ffb69a266 100644 --- a/crates/kas-core/src/event/cx/platform.rs +++ b/crates/kas-core/src/event/cx/platform.rs @@ -21,7 +21,7 @@ const FAKE_MOUSE_BUTTON: MouseButton = MouseButton::Other(0); /// Platform API #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] +#[cfg_attr(docsrs, doc(cfg(internal_doc)))] impl EventState { /// Construct per-window event state #[inline] @@ -257,7 +257,7 @@ impl EventState { /// Platform API #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] +#[cfg_attr(docsrs, doc(cfg(internal_doc)))] impl<'a> EventCx<'a> { /// Update widgets due to timer pub(crate) fn update_timer(&mut self, mut widget: Node<'_>) { diff --git a/crates/kas-core/src/event/events.rs b/crates/kas-core/src/event/events.rs index f9bb7599f..32c494912 100644 --- a/crates/kas-core/src/event/events.rs +++ b/crates/kas-core/src/event/events.rs @@ -183,7 +183,7 @@ pub enum Event { /// Since popups may be removed directly by the [`EventCx`], the parent should /// clean up any associated state here. #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] PopupClosed(WindowId), /// Notification that a widget has gained navigation focus /// diff --git a/crates/kas-core/src/layout/mod.rs b/crates/kas-core/src/layout/mod.rs index fbc8c077d..71f5c4e5f 100644 --- a/crates/kas-core/src/layout/mod.rs +++ b/crates/kas-core/src/layout/mod.rs @@ -57,7 +57,11 @@ pub use size_rules::SizeRules; pub use size_types::*; pub use sizer::{solve_size_rules, RulesSetter, RulesSolver, SolveCache}; pub use storage::*; -pub use visitor::{FrameStorage, PackStorage, Visitable, VisitableList, Visitor}; +pub use visitor::{FrameStorage, PackStorage}; + +#[cfg_attr(not(feature = "internal_doc"), doc(hidden))] +#[cfg_attr(docsrs, doc(cfg(internal_doc)))] +pub use visitor::{Visitable, VisitableList, Visitor}; /// Information on which axis is being resized /// diff --git a/crates/kas-core/src/layout/size_rules.rs b/crates/kas-core/src/layout/size_rules.rs index 16bcd1185..2bc8647f3 100644 --- a/crates/kas-core/src/layout/size_rules.rs +++ b/crates/kas-core/src/layout/size_rules.rs @@ -354,7 +354,7 @@ impl SizeRules { /// revert to the previous solution. (The reverse may not hold if widths /// had previously been affected by a different agent.) #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub fn solve_seq(out: &mut [i32], rules: &[Self], target: i32) { let total = SizeRules::sum(rules); Self::solve_seq_total(out, rules, total, target); @@ -365,7 +365,7 @@ impl SizeRules { /// This is the same as [`SizeRules::solve_seq`] except that the rules' sum /// is passed explicitly. #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] #[allow( clippy::comparison_chain, clippy::needless_range_loop, diff --git a/crates/kas-core/src/layout/visitor.rs b/crates/kas-core/src/layout/visitor.rs index 078874575..cb2e7928d 100644 --- a/crates/kas-core/src/layout/visitor.rs +++ b/crates/kas-core/src/layout/visitor.rs @@ -23,8 +23,6 @@ use crate::{dir::Directional, dir::Directions, Layout}; /// /// Unlike when implementing a widget, all methods of this trait must be /// implemented directly. -#[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] #[crate::autoimpl(for &'_ mut T, Box)] pub trait Visitable { /// Get size rules for the given axis @@ -59,8 +57,6 @@ pub trait Visitable { /// This is templated over `cell_info: C` where `C = ()` for lists or /// `C = GridCellInfo` for grids. #[allow(clippy::len_without_is_empty)] -#[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] pub trait VisitableList { /// List length fn len(&self) -> usize; @@ -93,8 +89,6 @@ impl VisitableList for () { pub struct Visitor(V); /// These methods would be free functions, but `Visitable` is a useful namespace -#[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] impl<'a> Visitor> { /// Construct a single-item layout pub fn single(widget: &'a mut dyn Layout) -> Visitor { diff --git a/crates/kas-core/src/lib.rs b/crates/kas-core/src/lib.rs index c3692bee4..10cfc0110 100644 --- a/crates/kas-core/src/lib.rs +++ b/crates/kas-core/src/lib.rs @@ -12,7 +12,7 @@ //! re-implementations of [`impl-tools`](https://crates.io/crates/impl-tools) macros #![cfg_attr(docsrs, feature(doc_auto_cfg))] -#![cfg_attr(doc_cfg, feature(doc_cfg))] +#![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(feature = "spec", feature(specialization))] extern crate self as kas; @@ -47,7 +47,7 @@ pub mod draw; pub mod event; pub mod geom; #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] +#[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub mod hidden; pub mod layout; pub mod messages; diff --git a/crates/kas-core/src/theme/draw.rs b/crates/kas-core/src/theme/draw.rs index 926ccf42b..d13d4b8b0 100644 --- a/crates/kas-core/src/theme/draw.rs +++ b/crates/kas-core/src/theme/draw.rs @@ -81,7 +81,7 @@ impl<'a> DrawCx<'a> { /// Construct from a [`DrawCx`] and [`EventState`] #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub fn new(h: &'a mut dyn ThemeDraw, id: Id) -> Self { DrawCx { h, id } } @@ -384,8 +384,6 @@ impl<'a> DrawCx<'a> { /// } /// ``` /// -#[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] #[autoimpl(for Box)] pub trait ThemeDraw { /// Access components: [`ThemeSize`], [`Draw`], [`EventState`] diff --git a/crates/kas-core/src/theme/mod.rs b/crates/kas-core/src/theme/mod.rs index e40814572..38a1788ef 100644 --- a/crates/kas-core/src/theme/mod.rs +++ b/crates/kas-core/src/theme/mod.rs @@ -25,7 +25,7 @@ mod theme_dst; mod traits; #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] +#[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub mod dimensions; pub use colors::{Colors, ColorsLinear, ColorsSrgb, InputState}; @@ -38,5 +38,7 @@ pub use style::*; pub use text::{SizableText, Text}; pub use theme_dst::ThemeDst; pub use traits::{Theme, Window}; + #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] +#[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub use {draw::ThemeDraw, size::ThemeSize}; diff --git a/crates/kas-core/src/theme/size.rs b/crates/kas-core/src/theme/size.rs index 01b621359..bbab6b849 100644 --- a/crates/kas-core/src/theme/size.rs +++ b/crates/kas-core/src/theme/size.rs @@ -31,7 +31,7 @@ pub struct SizeCx<'a>(&'a dyn ThemeSize); impl<'a> SizeCx<'a> { /// Construct from a [`ThemeSize`] #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] - #[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] + #[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub fn new(h: &'a dyn ThemeSize) -> Self { SizeCx(h) } @@ -194,8 +194,6 @@ impl<'a> SizeCx<'a> { } /// Theme sizing implementation -#[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] #[autoimpl(for> R)] pub trait ThemeSize { /// Get the scale factor diff --git a/crates/kas-core/src/util.rs b/crates/kas-core/src/util.rs index 067304391..f5c330390 100644 --- a/crates/kas-core/src/util.rs +++ b/crates/kas-core/src/util.rs @@ -140,7 +140,7 @@ pub fn load_icon_from_path>( /// Log a warning regarding an error message #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] -#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))] +#[cfg_attr(docsrs, doc(cfg(internal_doc)))] pub fn warn_about_error(msg: &str, mut error: &dyn std::error::Error) { log::warn!("{msg}: {error}"); while let Some(source) = error.source() { From 845e3733109b9b396c898098d380c623da78cbfd Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Mon, 20 May 2024 11:37:59 +0100 Subject: [PATCH 6/9] Un-hide RowTemp::set_len (Other removed annotations do nothing.) --- crates/kas-core/src/layout/storage.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/crates/kas-core/src/layout/storage.rs b/crates/kas-core/src/layout/storage.rs index f4c4229e4..55139bea5 100644 --- a/crates/kas-core/src/layout/storage.rs +++ b/crates/kas-core/src/layout/storage.rs @@ -95,7 +95,6 @@ impl RowStorage for DynRowStorage { /// For dynamic-length rows and fixed-length rows with more than 16 items use /// `Vec`. For fixed-length rows up to 16 items, use `[i32; rows]`. pub trait RowTemp: AsMut<[i32]> + Default + Debug + sealed::Sealed { - #[doc(hidden)] fn set_len(&mut self, len: usize); } @@ -186,14 +185,12 @@ impl_scope! { assert_eq!(self.heights.len(), rows); } - #[doc(hidden)] fn widths_and_rules(&mut self) -> (&mut [i32], &mut [SizeRules]) { ( self.widths.as_mut(), self.width_rules.as_mut(), ) } - #[doc(hidden)] fn heights_and_rules(&mut self) -> (&mut [i32], &mut [SizeRules]) { ( self.heights.as_mut(), @@ -220,11 +217,9 @@ impl GridStorage for DynGridStorage { self.heights.resize(rows, 0); } - #[doc(hidden)] fn widths_and_rules(&mut self) -> (&mut [i32], &mut [SizeRules]) { (self.widths.as_mut(), self.width_rules.as_mut()) } - #[doc(hidden)] fn heights_and_rules(&mut self) -> (&mut [i32], &mut [SizeRules]) { (self.heights.as_mut(), self.height_rules.as_mut()) } From 38723d8a48e9d9f7cb57b4e291721ae9e55cc24d Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Mon, 20 May 2024 11:51:09 +0100 Subject: [PATCH 7/9] Rename AppAssoc -> ApplicationInherent --- crates/kas-core/src/app/app.rs | 6 +++--- crates/kas-core/src/app/mod.rs | 2 +- examples/clock.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/kas-core/src/app/app.rs b/crates/kas-core/src/app/app.rs index 7630c8a3e..532a4b7f2 100644 --- a/crates/kas-core/src/app/app.rs +++ b/crates/kas-core/src/app/app.rs @@ -100,15 +100,15 @@ impl_scope! { } } -/// Application associated types +/// Inherenet associated types of [`Application`] /// /// Note: these could be inherent associated types of [`Application`] when Rust#8995 is stable. -pub trait AppAssoc { +pub trait ApplicationInherent { /// Shared draw state type type DrawShared: DrawSharedImpl; } -impl AppAssoc for Application +impl ApplicationInherent for Application where T: Theme + 'static, T::Window: theme::Window, diff --git a/crates/kas-core/src/app/mod.rs b/crates/kas-core/src/app/mod.rs index ecea75b0c..0ac6f8e67 100644 --- a/crates/kas-core/src/app/mod.rs +++ b/crates/kas-core/src/app/mod.rs @@ -20,7 +20,7 @@ use crate::messages::MessageStack; pub(crate) use window::{Window, WindowDataErased}; #[cfg(winit)] -pub use app::{AppAssoc, AppBuilder, Application, ClosedError, Proxy}; +pub use app::{AppBuilder, Application, ApplicationInherent, ClosedError, Proxy}; pub use common::{Error, Platform, Result}; #[cfg_attr(not(feature = "internal_doc"), doc(hidden))] diff --git a/examples/clock.rs b/examples/clock.rs index 52bec47d2..d4be80501 100644 --- a/examples/clock.rs +++ b/examples/clock.rs @@ -18,7 +18,7 @@ use std::f32::consts::PI; use std::str::FromStr; use std::time::Duration; -use kas::app::AppAssoc; +use kas::app::ApplicationInherent; use kas::draw::color::{Rgba, Rgba8Srgb}; use kas::draw::{Draw, DrawRounded}; use kas::geom::{Quad, Vec2}; @@ -80,7 +80,7 @@ impl_scope! { // We use the low-level draw device to draw our clock. This means it is // not themeable, but gives us much more flexible draw routines. - let mut draw = draw.draw_iface::<::DrawShared>().unwrap(); + let mut draw = draw.draw_iface::<::DrawShared>().unwrap(); let rect = self.core.rect; let quad = Quad::conv(rect); From a6f05164aacdaff3881301e9a118ea20a5eeca28 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Mon, 20 May 2024 11:53:49 +0100 Subject: [PATCH 8/9] Doc fix --- crates/kas-core/src/theme/size.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/crates/kas-core/src/theme/size.rs b/crates/kas-core/src/theme/size.rs index bbab6b849..d46a4a829 100644 --- a/crates/kas-core/src/theme/size.rs +++ b/crates/kas-core/src/theme/size.rs @@ -171,9 +171,6 @@ impl<'a> SizeCx<'a> { /// The [`TextClass`] is used to select a font and controls whether line /// wrapping is enabled. /// - /// Alignment is set from [`AxisInfo::align_or_default`]. If other alignment - /// is desired, modify `axis` before calling this method. - /// /// Horizontal size without wrapping is simply the size the text. /// Horizontal size with wrapping is bounded to some width dependant on the /// theme, and may have non-zero [`Stretch`] depending on the size. From b1ade87b52582861ba6786bcbc3bfde3fef87a06 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Mon, 20 May 2024 11:53:51 +0100 Subject: [PATCH 9/9] Fix feature name --- crates/kas-dylib/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/kas-dylib/src/lib.rs b/crates/kas-dylib/src/lib.rs index 0c85a8709..6ac132ec0 100644 --- a/crates/kas-dylib/src/lib.rs +++ b/crates/kas-dylib/src/lib.rs @@ -12,6 +12,6 @@ #![allow(clippy::single_component_path_imports)] use kas_core; -#[cfg(feature = "kas-resvg")] use kas_resvg; +#[cfg(feature = "resvg")] use kas_resvg; use kas_wgpu; use kas_widgets;