Select UI suite items through explicit registries

This commit is contained in:
FredApps
2026-11-19 12:20:08 +01:00
parent f8dddb2a55
commit b04d18a735
570 changed files with 2273 additions and 1605 deletions
Generated
+1
View File
@@ -4251,6 +4251,7 @@ dependencies = [
"serde",
"serde_json",
"syn 2.0.119",
"toml",
"wasm-bindgen-futures",
"web-time",
]
+1 -1
View File
@@ -20,7 +20,7 @@ mod model;
mod player;
mod recording;
#[cfg(test)]
mod tests;
pub(crate) mod tests;
pub use file::{ActionsFile, ActionsFileError};
pub use list::{ActionList, ActionListError, LibraryEdit, MergedFile, moved_index};
+1 -1
View File
@@ -27,7 +27,7 @@
//!
//! The Agents page of Preferences is [`crate::ui::agents`].
mod settings;
pub(crate) mod settings;
pub use settings::{AgentSettings, WhenAppClosed, agents_allowed, folder};
#[cfg(all(feature = "agents", not(target_arch = "wasm32")))]
+1 -1
View File
@@ -95,7 +95,7 @@ pub fn agents_allowed(mcp_flag: bool, launcher: bool, legacy: bool) -> bool {
}
#[cfg(test)]
mod tests {
pub(crate) mod tests {
use super::*;
use craft_ui::testing::trial;
+1 -1
View File
@@ -89,4 +89,4 @@ enum Failure {
#[cfg(all(test, feature = "ui"))]
#[path = "client_tests.rs"]
mod client_tests;
pub(crate) mod client_tests;
+4 -3
View File
@@ -57,17 +57,18 @@ pub use security::AutomationError;
/// The trials this crate registers, for its integration binary.
#[cfg(feature = "screen-testing")]
pub mod testing {
#[cfg(feature = "suite")]
craft_ui::testing_registered!();
craft_ui::registry!();
}
#[cfg(all(test, feature = "screen-testing"))]
extern crate self as craft_automation;
#[cfg(all(test, feature = "screen-testing"))]
#[path = "../tests/it/main.rs"]
mod integration;
pub(crate) mod integration;
#[cfg(test)]
fn main() {
craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME")));
craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register]));
}
+1 -1
View File
@@ -473,4 +473,4 @@ impl std::io::Read for AuthDeadlineStream {
#[cfg(test)]
#[path = "security_tests.rs"]
mod security_tests;
pub(crate) mod security_tests;
+2 -2
View File
@@ -14,11 +14,11 @@ mod footer;
mod menu;
#[cfg(feature = "screen-testing")]
pub mod mock;
mod panel;
pub(crate) mod panel;
mod prompt;
mod rows;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
mod words;
pub use body::{ActionMove, ActionPlace};
+1 -1
View File
@@ -1,7 +1,7 @@
//! `AgentsPage`: the Agents page of Preferences, over the agent settings in the Preferences draft.
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
mod words;
pub use words::AgentsWords;
+6 -6
View File
@@ -2,9 +2,9 @@
// Unwrapping, expecting and panicking on failure is fine in tests, unlike in shipped code.
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
mod actions;
mod agents;
mod control;
mod dialogs;
mod screenshot;
mod synthetic;
pub(crate) mod actions;
pub(crate) mod agents;
pub(crate) mod control;
pub(crate) mod dialogs;
pub(crate) mod screenshot;
pub(crate) mod synthetic;
+2 -2
View File
@@ -20,9 +20,9 @@ pub mod ui;
extern crate self as craft_browse;
#[cfg(all(test, feature = "screen-testing"))]
#[path = "../tests/it/main.rs"]
mod integration;
pub(crate) mod integration;
#[cfg(test)]
fn main() {
craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME")));
craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::ui::testing::register]));
}
+1 -1
View File
@@ -13,7 +13,7 @@
//! ```
#[cfg(test)]
mod tests;
pub(crate) mod tests;
use std::collections::HashMap;
use std::hash::Hash;
+1 -1
View File
@@ -17,7 +17,7 @@
mod cache;
mod directories;
#[cfg(test)]
mod tests;
pub(crate) mod tests;
use std::path::{Path, PathBuf};
+1 -1
View File
@@ -24,7 +24,7 @@ mod icon;
mod list;
mod search;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
use std::cell::RefCell;
use std::hash::Hash;
+3 -3
View File
@@ -13,11 +13,11 @@
mod arrange;
mod caption;
mod pill;
pub(crate) mod pill;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
mod style;
mod tile;
pub(crate) mod tile;
pub use arrange::{ArrangeSpace, ComparePair, survey_cell, survey_columns};
pub use caption::CompareCaption;
+1 -1
View File
@@ -6,7 +6,7 @@
//! move gesture into the cards' new positions.
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
use std::cell::RefCell;
use std::collections::HashMap;
+2 -1
View File
@@ -21,6 +21,7 @@ pub use relink::{LinkList, LinkListWords, RelinkDialog, RelinkWords, StatusBadge
/// The stories and trials this crate registers for the integration binary.
#[cfg(feature = "screen-testing")]
pub mod testing {
#[cfg(feature = "suite")]
craft_ui::testing_registered!();
craft_ui::registry!();
}
+1 -1
View File
@@ -16,7 +16,7 @@
//! ```
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
use std::path::{Path, PathBuf};
+3 -3
View File
@@ -16,10 +16,10 @@
//! ```
mod badge;
mod dialog;
mod list;
pub(crate) mod dialog;
pub(crate) mod list;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
pub use badge::StatusBadge;
pub use dialog::{CandidateChecker, RelinkCriterion, RelinkDialog, RelinkLayout, RelinkOptions, RelinkOutcome, RelinkRow, RelinkWords};
+5 -5
View File
@@ -1,7 +1,7 @@
//! The screen tests of craft-browse, folded into the lib's test target.
mod bin;
mod freebin;
mod places;
mod relink;
mod thumbs;
pub(crate) mod bin;
pub(crate) mod freebin;
pub(crate) mod places;
pub(crate) mod relink;
pub(crate) mod thumbs;
+1 -1
View File
@@ -298,7 +298,7 @@ impl DisplayCaches {
}
#[cfg(test)]
mod tests {
pub(crate) mod tests {
use super::*;
use craft_ui::testing::trial;
+2 -2
View File
@@ -27,9 +27,9 @@ pub use web::{not_web_safe, web_safe};
extern crate self as craft_color_ui;
#[cfg(all(test, feature = "screen-testing"))]
#[path = "../tests/it/main.rs"]
mod integration;
pub(crate) mod integration;
#[cfg(test)]
fn main() {
craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME")));
craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::ui::testing::register]));
}
+1 -1
View File
@@ -490,7 +490,7 @@ mod aco;
mod ase;
mod reader;
#[cfg(test)]
mod tests;
pub(crate) mod tests;
mod text;
use aco::{AcoColor, act_used, from_aco, parse_aco, to_aco, write_aco};
+1 -1
View File
@@ -14,7 +14,7 @@ use craft_ui::value_drag::{PointMark, PointPicker};
use egui::{Mesh, Pos2, Rect, Vec2, pos2};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
/// Vertices along each side of the area's colour mesh (PhotoCraft's 32).
const MESH: usize = 32;
+1 -1
View File
@@ -2,7 +2,7 @@
//! (Preferences, Interface), the Crop shield colour and the Note colour.
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
use craft_theme::Srgba;
use craft_ui::contract::{Bind, Entry, NoValue, Outcome, Props as _, Show as _};
+1 -1
View File
@@ -13,7 +13,7 @@ use super::picker::ColorPickerWords;
use super::warning::{ColorWarning, ColorWarningChip};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
/// The style of a compare block: the size of the block and of each half, the edge round it and the gap between a
/// caption and the block.
+1 -1
View File
@@ -17,7 +17,7 @@ use craft_ui::style::{ComponentStyle, FocusLook, MarkerLook, StyleColor, StyleCx
use egui::{Color32, Mesh, Pos2, Response, Vec2};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
/// The disc: a press on it grabs the nearest marker within reach.
const DISC: PartKey = PartKey::new("disc");
+1 -1
View File
@@ -32,7 +32,7 @@ use craft_ui::runtime::requests::EyedropperRequest;
use egui::{Pos2, Response, Ui, Vec2};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
/// The pipette icon's tip, in the icon's own 24-unit box.
const HOTSPOT: [f32; 2] = [2.0, 22.0];
+1 -1
View File
@@ -36,7 +36,7 @@ use craft_ui::style::DataColor;
use egui::{Color32, Pos2, Response, Ui, Vec2, vec2};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
craft_ui::words! {
/// The Eyedropper options bar's words, English by default.
+1 -1
View File
@@ -18,7 +18,7 @@ use crate::gradient::{GradientStops, Sampler, StopRules};
mod bar;
mod fields;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
use bar::GradientBar;
pub use bar::StopDrop;
+1 -1
View File
@@ -3,7 +3,7 @@
//! The model and the stop rules ([`GradientStops`], [`stops`]) need no egui and live in [`crate::gradient`]; they are
//! re-exported here so a widget user imports the editor and its model from one path.
mod editor;
pub(crate) mod editor;
mod ramp;
mod value;
mod words;
+1 -1
View File
@@ -20,7 +20,7 @@ use crate::harmony::{Guide, GuideOptions, Harmony, Variation};
use craft_ui::choice::{SwatchTable, SwatchTableOutput};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
craft_ui::words! {
/// The words of the harmony controls and of the Color Guide panel menu.
+1 -1
View File
@@ -18,7 +18,7 @@ use craft_ui::style::{ComponentStyle, StyleCx, UiTokens};
use egui::{Pos2, Rect, Response, Ui, Vec2, pos2, vec2};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
/// The model the HUD picks in: saturation and brightness across and down, hue in the strip.
const MODE: AreaMode = AreaMode::Hue;
+1 -1
View File
@@ -14,7 +14,7 @@ use egui::{Response, Ui};
use super::SamplerReadout;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
/// What a missing value shows.
const DASH: &str = "–";
+1 -1
View File
@@ -20,7 +20,7 @@ use craft_ui::style::{ComponentStyle, StyleCx};
use egui::{Response, Vec2};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
craft_ui::words! {
/// The LUT picker's rows, English by default, and the built-in looks' names in
+26 -26
View File
@@ -11,39 +11,39 @@
//! Colour edits are values of a colour model ([`ModelValues`](craft_theme::ModelValues)) or of [`PickedColor`], and
//! report through the edit lifecycle of the contract.
mod area;
pub(crate) mod area;
mod channels;
mod choice;
mod compare;
mod disc;
mod droppers;
mod eyedropper;
pub(crate) mod choice;
pub(crate) mod compare;
pub(crate) mod disc;
pub(crate) mod droppers;
pub(crate) mod eyedropper;
pub mod gradient;
mod harmony;
pub(crate) mod harmony;
mod hex;
mod hud;
mod info;
mod lut_picker;
mod paint_chip;
mod pair;
mod palette;
mod panel;
mod picker;
pub(crate) mod hud;
pub(crate) mod info;
pub(crate) mod lut_picker;
pub(crate) mod paint_chip;
pub(crate) mod pair;
pub(crate) mod palette;
pub(crate) mod panel;
pub(crate) mod picker;
mod picker_dialog;
mod popover;
mod profile_prompts;
mod ramp;
mod readout;
mod sample_size;
mod samplers;
mod screen_picker;
mod strip;
mod swatches;
pub(crate) mod popover;
pub(crate) mod profile_prompts;
pub(crate) mod ramp;
pub(crate) mod readout;
pub(crate) mod sample_size;
pub(crate) mod samplers;
pub(crate) mod screen_picker;
pub(crate) mod strip;
pub(crate) mod swatches;
/// The stories and trials this crate registers for the integration binary.
#[cfg(feature = "screen-testing")]
pub mod testing;
mod warning;
mod wheel;
pub(crate) mod warning;
pub(crate) mod wheel;
pub use crate::AreaMode;
pub use area::{AreaShape, ColorArea, ColorAreaStyle};
+2 -2
View File
@@ -33,9 +33,9 @@ use super::popover::compact_picker;
use super::{PickedColor, ScreenPickGesture, SwatchKey, SwatchPalette, SwatchesWords, swatch_rows};
use crate::palette::{SwatchColor, SwatchGroup};
mod paint_list;
pub(crate) mod paint_list;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
pub use paint_list::{PaintLink, PaintLinkKind, PaintList, PaintListEvent, PaintListOptions, PaintListOutput, PaintRow};
+1 -1
View File
@@ -19,7 +19,7 @@ use super::popover::compact_picker;
use super::{ColorPicker, PickedColor, ScreenPickGesture};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
/// One of the wells, `WELL.at(0)` the primary and `WELL.at(1)` the secondary.
const WELL: PartKey = PartKey::new("well");
+1 -1
View File
@@ -11,7 +11,7 @@ use egui::{Response, Ui};
use std::sync::Arc;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
/// What a [`SwatchPalette`] reports.
#[derive(Debug)]
+2 -2
View File
@@ -30,7 +30,7 @@ use super::{
use crate::{CmykModel, GrayModel, not_web_safe};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
craft_ui::words! {
/// The Color panel's words.
@@ -821,7 +821,7 @@ impl Body<'_> {
const WEB_STEP: f64 = 51.0;
#[cfg(test)]
mod tests {
pub(crate) mod tests {
use craft_ui::testing::trial;
use super::*;
+3 -3
View File
@@ -2,12 +2,12 @@
//! host adds. A container: its body lays the parts out with the form layouts, the "Field shows" choice is a
//! `RadioGroup` and the channel rows share one label column.
mod channel;
pub(crate) mod channel;
mod compact;
mod full;
mod screen_pick;
pub(crate) mod screen_pick;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
mod value;
use std::sync::Arc;
+1 -1
View File
@@ -12,7 +12,7 @@ use egui::{Response, Ui};
use super::{ColorPicker, ColorPickerLayout, ColorPickerOutput, PickedColor, ScreenPickGesture};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
/// The setup closure of the picker in the popover.
type Setup<'a> = Box<dyn for<'b> Fn(ColorPicker<'b>) -> ColorPicker<'b> + 'a>;
+1 -1
View File
@@ -19,7 +19,7 @@ use serde_json::{Value, json};
use crate::display::MonitorProblem;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
craft_ui::words! {
/// The profile prompts' words, English by default.
+1 -1
View File
@@ -18,7 +18,7 @@ use std::hash::{DefaultHasher, Hash, Hasher};
use std::sync::Arc;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
/// The bar: a press picks the colour under the pointer.
const BAR: PartKey = PartKey::new("bar");
+1 -1
View File
@@ -1,7 +1,7 @@
//! `ColorReadout`: a colour as a hex field and editable R, G and B fields (the readout of a Color panel).
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
use craft_behavior::{EditEvent, EditEvents, Mixed};
use craft_theme::{ColorModel as _, RgbModel, Rgba};
+1 -1
View File
@@ -35,7 +35,7 @@ use craft_ui::style::{ComponentStyle, StyleColor, StyleCx};
use egui::{Pos2, Response, Ui, Vec2, vec2};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
craft_ui::words! {
/// The colour samplers' words, English by default.
+2 -2
View File
@@ -32,9 +32,9 @@ use egui::{Color32, Context, Pos2, Rect, Ui, pos2, vec2};
use super::ScreenPickGesture;
mod capture;
pub(crate) mod capture;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
use capture::{CaptureView, CaptureWindow};
+1 -1
View File
@@ -16,7 +16,7 @@ use craft_ui::style::{ComponentStyle, DataColor, FocusLook, StyleColor, StyleCx}
use egui::{CornerRadius, Mesh, Pos2, Rect, Vec2, pos2};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
/// The strip itself: a press on it sets the value there.
const STRIP: PartKey = PartKey::new("strip");
+3 -3
View File
@@ -3,11 +3,11 @@
//! change as a resolved [`SwatchEdit`] (new, rename, delete, move, group edits, import) that the host runs, with
//! [`SwatchLibrary::apply`] for an in-memory host.
mod library;
pub(crate) mod library;
mod menu;
mod panel;
pub(crate) mod panel;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
pub use library::{SwatchAt, SwatchEdit, SwatchKey, SwatchLibrary, SwatchesState, swatch_rows};
pub use menu::{SwatchesCommand, SwatchesFileOutput, SwatchesMenu, SwatchesMenuOutput};
+1 -1
View File
@@ -569,7 +569,7 @@ pub fn swatch_rows(groups: &[SwatchGroup], words: &SwatchesWords) -> Vec<PresetR
}
#[cfg(test)]
mod tests {
pub(crate) mod tests {
use super::*;
use craft_ui::testing::trial;
+1 -1
View File
@@ -1,2 +1,2 @@
#[cfg(feature = "suite")]
craft_ui::testing_registered!();
craft_ui::registry!();
+1 -1
View File
@@ -12,7 +12,7 @@ use craft_ui::style::{ComponentStyle, StyleCx};
use egui::{Rect, Response, Vec2};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
/// A warning the host shows beside a colour's swatch, as the out-of-gamut and web-colour warnings of Photoshop's Color
/// Picker and Color panel: an icon and a chip of the nearest colour that passes. A click on it sets that colour;
+1 -1
View File
@@ -16,7 +16,7 @@ use egui::{Mesh, Pos2, Rect, Vec2, vec2};
use std::f32::consts::TAU;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
/// The hue ring: a press on it sets the hue to the pointer's angle.
const RING: PartKey = PartKey::new("ring");
+8 -8
View File
@@ -1,10 +1,10 @@
//! The screen tests of craft-color-ui, folded into the lib's test target.
mod color_parts;
mod gradient_bar;
mod paint_list;
mod pair;
mod panels;
mod picker;
mod profile_prompts;
mod sampling;
pub(crate) mod color_parts;
pub(crate) mod gradient_bar;
pub(crate) mod paint_list;
pub(crate) mod pair;
pub(crate) mod panels;
pub(crate) mod picker;
pub(crate) mod profile_prompts;
pub(crate) mod sampling;
+5 -2
View File
@@ -19,6 +19,7 @@ mod pipeline_only;
mod platform;
mod pointer;
mod props;
mod registry_expansion;
mod runtime_egui;
mod scope;
mod shape;
@@ -39,7 +40,7 @@ use crate::report::Finding;
use sites::Site;
/// Every rule id of this module, for the marker and exemption validation in [`crate::RULES`].
pub(crate) const IDS: [&str; 39] = [
pub(crate) const IDS: [&str; 40] = [
egui_import::ID,
runtime_egui::ID,
text_edit::ID,
@@ -79,12 +80,13 @@ pub(crate) const IDS: [&str; 39] = [
shape::OVERLAY_FLAG,
shape::REGISTRATION,
unsafe_allow::ID,
registry_expansion::ID,
];
type Check = fn(&Cx<'_>, &mut Vec<Finding>);
/// REGISTRY: add a rule by adding its `check` here and its ids to [`IDS`].
const REGISTRY: [Check; 21] = [
const REGISTRY: [Check; 22] = [
egui_import::check,
runtime_egui::check,
text_edit::check,
@@ -106,6 +108,7 @@ const REGISTRY: [Check; 21] = [
entry::check,
shape::check,
unsafe_allow::check,
registry_expansion::check,
];
/// One file as the rules see it.
@@ -0,0 +1,121 @@
//! Reject suite registrations hidden from the source-tree registry walker.
use proc_macro2::{Delimiter, TokenStream, TokenTree};
use std::str::FromStr as _;
use syn::spanned::Spanned as _;
use syn::visit::{self, Visit};
use super::Cx;
use crate::report::Finding;
/// Suite items inside expansions cannot be discovered by `registry!`.
pub const ID: &str = "registry/expansion";
fn attribute(tree: &TokenTree) -> Option<String> {
match tree {
TokenTree::Group(group) if group.delimiter() == Delimiter::Bracket => Some(group.stream().to_string()),
_ => None,
}
}
fn words(attr: &str) -> Vec<&str> {
attr.split(|c: char| !c.is_alphanumeric() && c != '_').filter(|s| !s.is_empty()).collect()
}
fn has_registration(tokens: TokenStream) -> bool {
let trees: Vec<_> = tokens.into_iter().collect();
let mut i = 0;
while i < trees.len() {
if matches!(&trees[i], TokenTree::Punct(p) if p.as_char() == '#') {
let mut attrs = Vec::new();
while i + 1 < trees.len() && matches!(&trees[i], TokenTree::Punct(p) if p.as_char() == '#') {
let Some(attr) = attribute(&trees[i + 1]) else { break };
attrs.push(attr);
i += 2;
}
if attrs.iter().any(|attr| words(attr).first().is_some_and(|word| *word == "story" || *word == "trial")) {
return true;
}
let unregistered = attrs.iter().any(|attr| {
let words = words(attr);
words.first() == Some(&"component") && words.contains(&"unregistered")
});
if !unregistered
&& attrs.iter().any(|attr| {
let words = words(attr);
words.first() == Some(&"derive") && (words.contains(&"Component") || words.contains(&"Pattern"))
})
{
return true;
}
let story_set = attrs.iter().any(|attr| {
let words = words(attr);
words.first() == Some(&"command") && words.contains(&"story")
});
if story_set
&& attrs.iter().any(|attr| {
let words = words(attr);
words.first() == Some(&"derive") && words.contains(&"CommandSet")
})
{
return true;
}
continue;
}
if let TokenTree::Ident(ident) = &trees[i] {
if ident == "register_contract" && trees.get(i + 1).is_some_and(|t| matches!(t, TokenTree::Punct(p) if p.as_char() == '!')) {
return true;
}
}
if let TokenTree::Group(group) = &trees[i] {
if has_registration(group.stream()) {
return true;
}
}
i += 1;
}
false
}
struct Walk<'a, 'b> {
cx: &'a Cx<'b>,
out: &'a mut Vec<Finding>,
}
impl<'ast> Visit<'ast> for Walk<'_, '_> {
fn visit_item_macro(&mut self, item: &'ast syn::ItemMacro) {
let hidden = if item.mac.path.is_ident("macro_rules") {
has_registration(item.mac.tokens.clone())
} else if item.mac.path.is_ident("include") {
syn::parse2::<syn::LitStr>(item.mac.tokens.clone())
.ok()
.and_then(|path| self.cx.path.parent().map(|parent| parent.join(path.value())))
.and_then(|path| std::fs::read_to_string(path).ok())
.and_then(|source| TokenStream::from_str(&source).ok())
.is_some_and(has_registration)
} else {
false
};
if hidden {
self.cx.flag_span(self.out, ID, ID, item.span(), "suite registration inside a macro or include is invisible to registry!".to_owned());
}
visit::visit_item_macro(self, item);
}
}
pub(super) fn check(cx: &Cx<'_>, out: &mut Vec<Finding>) {
Walk { cx, out }.visit_file(cx.file);
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn detects_hidden_registrations_and_allows_unregistered_derive() {
let hidden = TokenStream::from_str("#[derive(Component)] struct A; #[trial] fn t() {} ").unwrap_or_default();
let ordinary = TokenStream::from_str("#[derive(Component)] #[component(unregistered)] struct A; ").unwrap_or_default();
assert!(has_registration(hidden));
assert!(!has_registration(ordinary));
}
}
+8 -7
View File
@@ -22,11 +22,11 @@
mod filter;
mod native;
#[cfg(target_os = "linux")]
mod portal;
mod probe;
pub(crate) mod portal;
pub(crate) mod probe;
pub mod save;
#[cfg(test)]
mod save_tests;
pub(crate) mod save_tests;
pub mod service;
#[cfg(feature = "ui")]
pub mod ui;
@@ -34,15 +34,16 @@ pub mod ui;
/// The registrations of this crate's UI types, for its integration binary.
#[cfg(feature = "screen-testing")]
pub mod testing {
#[cfg(feature = "suite")]
craft_ui::testing_registered!();
craft_ui::registry!();
}
#[cfg(target_os = "macos")]
mod macos;
#[cfg(test)]
mod tests;
pub(crate) mod tests;
use std::collections::VecDeque;
use std::panic::{AssertUnwindSafe, catch_unwind};
@@ -395,9 +396,9 @@ fn panic_text(panic: &(dyn std::any::Any + Send)) -> Option<&str> {
extern crate self as craft_dialogs;
#[cfg(all(test, feature = "screen-testing"))]
#[path = "../tests/it/main.rs"]
mod integration;
pub(crate) mod integration;
#[cfg(test)]
fn main() {
craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME")));
craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register]));
}
+1 -1
View File
@@ -261,4 +261,4 @@ pub(crate) fn save_as(mut req: SaveRequest) -> Result<Option<PathBuf>, String> {
}
#[cfg(test)]
mod tests;
pub(crate) mod tests;
+1 -1
View File
@@ -186,4 +186,4 @@ fn classify_error(e: &zbus::Error) -> Option<bool> {
}
#[cfg(test)]
mod tests;
pub(crate) mod tests;
+1 -1
View File
@@ -569,7 +569,7 @@ impl Files for FileService {
}
#[cfg(test)]
mod service_tests {
pub(crate) mod service_tests {
//! Behaviour tests with `Dialogs::set_override` standing in for the panels.
use craft_ui::testing::trial;
+2 -2
View File
@@ -1,8 +1,8 @@
//! The file service's UI part: [`PathField`], and the words of the service's native boxes.
mod path_field;
pub(crate) mod path_field;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
pub use path_field::{PathField, PathFieldOutput, PathFieldWords};
+1 -1
View File
@@ -2,4 +2,4 @@
// Expecting on failure is fine here, unlike in shipped code.
#![allow(clippy::expect_used)]
mod files;
pub(crate) mod files;
+4 -4
View File
@@ -2,16 +2,16 @@
pub mod artboard;
#[cfg(test)]
mod artboard_tests;
pub(crate) mod artboard_tests;
pub mod connector;
#[cfg(test)]
mod connector_tests;
pub(crate) mod connector_tests;
pub mod curvature;
#[cfg(test)]
mod curvature_tests;
pub(crate) mod curvature_tests;
pub mod fillet;
#[cfg(test)]
mod fillet_tests;
pub(crate) mod fillet_tests;
pub mod presets;
pub mod shape;
pub mod slice;
+4 -3
View File
@@ -9,17 +9,18 @@ pub mod ui;
#[cfg(feature = "screen-testing")]
pub mod testing {
//! The registrations of this crate's stories, for the `tests/it` harness.
#[cfg(feature = "suite")]
craft_ui::testing_registered!();
craft_ui::registry!();
}
#[cfg(all(test, feature = "screen-testing"))]
extern crate self as craft_draw;
#[cfg(all(test, feature = "screen-testing"))]
#[path = "../tests/it/main.rs"]
mod integration;
pub(crate) mod integration;
#[cfg(test)]
fn main() {
craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::registered_in(env!("CARGO_PKG_NAME")));
craft_ui::testing::run(module_path!(), env!("CARGO_PKG_NAME"), &craft_ui::testing::Registry::of(&[crate::testing::register]));
}
+1 -1
View File
@@ -12,7 +12,7 @@ use kurbo::{BezPath, CubicBez, Line, ParamCurve, ParamCurveArclen, PathEl, PathS
use serde::{Deserialize, Serialize};
#[cfg(test)]
mod dash_tests;
pub(crate) mod dash_tests;
/// The shortest run (between corners and path ends) and the smallest pattern total `Corners` fits.
const MIN_RUN: f64 = 1e-6;
+4 -4
View File
@@ -16,11 +16,11 @@ use craft_theme::Srgba;
use std::sync::Arc;
mod background;
mod bar;
mod overlay;
mod properties;
pub(crate) mod bar;
pub(crate) mod overlay;
pub(crate) mod properties;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
mod tool;
mod words;
+2 -2
View File
@@ -10,8 +10,8 @@
//! The app paints the tip and stroke images from its engine; the library never sees an engine type. Presets are
//! keyed by the app's key type (PhotoCraft: `PresetKey<String>`, by name).
mod panel;
mod picker;
pub(crate) mod panel;
pub(crate) mod picker;
mod rows;
mod settings;
#[cfg(feature = "suite")]
+6 -6
View File
@@ -13,12 +13,12 @@
//! draws the frame and the shared rows, and every control reports edit events the app sends to its
//! tool options host.
mod ellipse;
mod panel;
mod preview;
mod rows;
mod sections;
mod size_field;
pub(crate) mod ellipse;
pub(crate) mod panel;
pub(crate) mod preview;
pub(crate) mod rows;
pub(crate) mod sections;
pub(crate) mod size_field;
#[cfg(feature = "suite")]
pub(crate) mod stories;
mod words;
+3 -3
View File
@@ -7,15 +7,15 @@
//! on an object, the handles (a canvas control) take a press on the selected connector's ends and
//! bends before the tool sees it.
mod bar;
mod handles;
pub(crate) mod bar;
pub(crate) mod handles;
mod overlay;
mod place;
mod tool;
mod words;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
use craft_behavior::EditEvent;
use kurbo::{Point, Rect};
+1 -1
View File
@@ -9,7 +9,7 @@ mod geometry;
#[cfg(feature = "suite")]
pub(crate) mod stories;
mod style;
mod widgets;
pub(crate) mod widgets;
mod words;
use kurbo::Point;
+1 -1
View File
@@ -22,7 +22,7 @@ use craft_ui::text::NumberField;
use egui::{Response, Ui};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
/// The ratio, a ratio field, a preset or W × H × Resolution changed.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+6 -6
View File
@@ -8,17 +8,17 @@
//! The tool reports events and never crops the document: the app crops on [`CropEvent::Apply`] with the
//! [`CropCommit`] it carries.
mod bar;
pub(crate) mod bar;
mod bar_words;
mod menus;
pub(crate) mod menus;
mod options;
mod perspective_bar;
mod perspective_crop;
pub(crate) mod perspective_bar;
pub(crate) mod perspective_crop;
mod perspective_tool;
mod preset_list;
pub(crate) mod preset_list;
mod session;
mod size_cells;
mod tool;
pub(crate) mod tool;
mod words;
pub use bar::{CropBar, CropBarOutput, CropRatioChange};
+1 -1
View File
@@ -12,7 +12,7 @@ use craft_ui::runtime::env::Env;
use egui::{Response, Ui};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
/// The Perspective Crop options: W × H × Resolution, Front Image, Clear, a divider and Show Grid.
///
+1 -1
View File
@@ -488,4 +488,4 @@ pub fn grid_lines(view: &CanvasView, q: &[Point; 4], step: f32) -> Vec<[Pos2; 2]
}
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
+1 -1
View File
@@ -789,4 +789,4 @@ pub fn crop_to_form(words: &CropWords, frame: &CropBox) -> ParamDialog<'static>
}
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
+1 -1
View File
@@ -223,4 +223,4 @@ impl<'a> GradientFillEditor<'a> {
}
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
@@ -6,7 +6,7 @@ mod keys;
mod parts;
mod pointer;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
use std::sync::Arc;
+1 -1
View File
@@ -5,7 +5,7 @@
//! [`GradientGroup`] presets, and a family crate depends on no other family crate but craft-color-ui.
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
use craft_behavior::{EditEvent, Mixed};
use craft_ui::buttons::Button;
+3 -3
View File
@@ -8,12 +8,12 @@
//! there.
mod fill;
mod fill_editor;
pub(crate) mod fill_editor;
pub mod gradient_line;
pub mod gradient_overlay;
pub mod map;
mod palette;
mod swatch;
pub(crate) mod palette;
pub(crate) mod swatch;
pub use fill::{GradientFill, GradientStyle};
pub use fill_editor::{GradientFillEditor, GradientFillEditorOutput, GradientFillWords};
+1 -1
View File
@@ -8,7 +8,7 @@ use craft_ui::runtime::env::{Env, Label};
use egui::{Response, Ui};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
use craft_color_ui::ui::gradient::{GradientRamp, GradientStops, Sampler, StopRows, default_sampler};
+1 -1
View File
@@ -11,7 +11,7 @@ use egui::{CornerRadius, Response, Vec2};
use craft_color_ui::ui::gradient::{GradientRamp, GradientStops, Sampler, StopRows, default_sampler};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
/// The style of a gradient swatch: the colour swatch's height, corners and ring.
#[derive(Clone, Debug, PartialEq, ComponentStyle)]
+3 -3
View File
@@ -5,12 +5,12 @@
//! The Ruler line is document state outside the undo history: the tool reports `EditEvent<Option<RulerLine>>` and the
//! app stores the line.
mod bar;
pub(crate) mod bar;
mod distances;
mod model;
mod overlay;
pub(crate) mod overlay;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
mod tool;
mod words;
+1 -1
View File
@@ -21,7 +21,7 @@ use craft_ui::text::{NumberField, RangeAlert};
use egui::{Response, Ui};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
mod words;
pub use words::PaintBarWords;
+1 -1
View File
@@ -4,7 +4,7 @@
mod footer;
mod menu;
mod model;
mod panel;
pub(crate) mod panel;
mod rows;
#[cfg(feature = "suite")]
pub(crate) mod stories;
+1 -1
View File
@@ -5,7 +5,7 @@
use craft_theme::Srgba;
mod dialog;
mod editor;
pub(crate) mod editor;
#[cfg(feature = "suite")]
pub(crate) mod stories;
mod words;
+1 -1
View File
@@ -6,7 +6,7 @@ mod mark;
mod model;
mod ops;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
mod style;
mod tools;
mod words;
+1 -1
View File
@@ -8,7 +8,7 @@ mod auto;
pub(crate) mod bezier;
mod curvature_mode;
mod mode;
mod options;
pub(crate) mod options;
#[cfg(feature = "suite")]
pub(crate) mod stories;
mod tool;
+2 -2
View File
@@ -7,9 +7,9 @@
//! if let Some(request) = out.requests.take_path() { /* open the file dialog, store the picture, set `fill.source` */ }
//! ```
mod editor;
pub(crate) mod editor;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
mod words;
pub use editor::{PICTURE_FILL_KEY, PictureFillEditor, PictureFillOutput};
+6 -6
View File
@@ -10,14 +10,14 @@ use crate::stroke::StrokeStyle;
use super::shape_drag::{BoxConstraints, ShapeDragOptions, ShapeKind};
mod arrowheads;
mod bar;
mod gear;
mod mode_select;
mod panel;
pub(crate) mod arrowheads;
pub(crate) mod bar;
pub(crate) mod gear;
pub(crate) mod mode_select;
pub(crate) mod panel;
#[cfg(feature = "suite")]
pub(crate) mod stories;
mod stroke_cells;
pub(crate) mod stroke_cells;
mod words;
pub use arrowheads::{ArrowheadsOutput, ArrowheadsPopover};
+1 -1
View File
@@ -12,7 +12,7 @@ use egui::{Color32, Mesh, Painter, Pos2, Rect, Shape, Stroke, Ui, pos2};
use kurbo::{BezPath, PathEl};
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
/// The error bound, in points, when the glyph's curves are flattened.
const FLATTEN_TOLERANCE: f64 = 0.1;
+3 -3
View File
@@ -35,11 +35,11 @@ use craft_behavior::{Axis, CancelReason, EditEvent, GestureId, Mixed};
use craft_keymap::Mods;
use std::sync::Arc;
mod bar;
pub(crate) mod bar;
mod dialogs;
mod overlay;
pub(crate) mod overlay;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
mod tool;
mod words;
+2 -2
View File
@@ -5,8 +5,8 @@
//! and named stroke types. The editor edits geometry only; width, colour and paint are the host's
//! controls. The value is [`StrokeStyle`], re-exported here.
mod button;
mod editor;
pub(crate) mod button;
pub(crate) mod editor;
mod preview;
#[cfg(feature = "suite")]
pub(crate) mod stories;
+4 -4
View File
@@ -5,12 +5,12 @@
//! Stroke reflection, path symmetry and the brush engine stay in the app's paint engine; the library carries only the
//! axis geometry the screens need.
mod handles;
mod menu;
pub(crate) mod handles;
pub(crate) mod menu;
mod model;
mod overlay;
pub(crate) mod overlay;
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
mod transform;
pub use handles::{SymmetryHandles, SymmetryHandlesOutput, SymmetryHandlesStyle};
+4 -4
View File
@@ -2,10 +2,10 @@
//! the open session around them ([`TransformSession`], [`TransformOverlay`], [`TransformTool`], [`TransformBar`]).
mod session;
mod session_bar;
mod session_overlay;
mod transform_box;
mod transform_fields;
pub(crate) mod session_bar;
pub(crate) mod session_overlay;
pub(crate) mod transform_box;
pub(crate) mod transform_fields;
pub use session::{
Interpolation, TransformChoice, TransformEdit, TransformMenuWords, TransformPhase, TransformPreset, TransformRequest, TransformResult,
+1 -1
View File
@@ -1,7 +1,7 @@
//! `TransformBar`: the options bar of an open Free Transform session.
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
use super::session::{TransformEdit, TransformPhase, TransformSession, TransformSettings, TransformWarp};
use super::transform_fields::{TransformFields, TransformGroups, TransformRow, size_unit_of};
@@ -2,7 +2,7 @@
//! and turns its reports into [`TransformEdit`]s, and `TransformTool`: the canvas tool of the open session.
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
use craft_behavior::CancelReason;
use craft_behavior::geometry::SnapLine;
@@ -3,7 +3,7 @@
//! document units.
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
use craft_behavior::geometry::quad::{self, BoxAllow, BoxDrag, BoxPart, BoxRules, BoxState, ScaleRule, TransformMode};
use craft_behavior::geometry::{SNAP_PX, SnapKind, SnapKinds, SnapLine};
@@ -2,7 +2,7 @@
//! rows.
#[cfg(feature = "suite")]
mod stories;
pub(crate) mod stories;
mod units;
use self::units::Conversion;
+28 -28
View File
@@ -1,59 +1,59 @@
//! The screen tests of craft-draw, folded into the lib's test target.
// draw-shape
mod add_beside;
mod corner;
mod shape_cells;
pub(crate) mod add_beside;
pub(crate) mod corner;
pub(crate) mod shape_cells;
// draw-gradient-b
mod gradient_fill;
mod gradient_overlay;
pub(crate) mod gradient_fill;
pub(crate) mod gradient_overlay;
// draw-connector
mod connector;
mod shape_drag;
pub(crate) mod connector;
pub(crate) mod shape_drag;
// draw-paths
mod paths_panel;
pub(crate) mod paths_panel;
// draw-pen-a
mod bezier;
pub(crate) mod bezier;
// draw-pen-b
mod pen;
pub(crate) mod pen;
// draw-crop-b
mod crop_size;
mod crop_tool;
mod perspective_crop;
pub(crate) mod crop_size;
pub(crate) mod crop_tool;
pub(crate) mod perspective_crop;
// draw-artboard
mod artboard;
pub(crate) mod artboard;
// draw-bars
mod measure;
mod slice;
mod slice_divide;
pub(crate) mod measure;
pub(crate) mod slice;
pub(crate) mod slice_divide;
// draw-stroke
mod stroke_button;
mod stroke_editor;
pub(crate) mod stroke_button;
pub(crate) mod stroke_editor;
// draw-brush-presets
mod brush_presets;
mod brush_size;
mod paint_bar;
pub(crate) mod brush_presets;
pub(crate) mod brush_size;
pub(crate) mod paint_bar;
// draw-transform-a
mod transform_box;
mod transform_session;
pub(crate) mod transform_box;
pub(crate) mod transform_session;
// draw-transform-b
mod symmetry;
mod transform_fields;
pub(crate) mod symmetry;
pub(crate) mod transform_fields;
// draw-presets
mod presets;
pub(crate) mod presets;
// dialogs-w13
mod pattern_fill;
pub(crate) mod pattern_fill;
+1 -1
View File
@@ -3,7 +3,7 @@
//! and reading them from a font are always available; the sliders are on `ui`.
#[cfg(feature = "ui")]
mod sliders;
pub(crate) mod sliders;
#[cfg(feature = "ui")]
pub use sliders::*;

Some files were not shown because too many files have changed in this diff Show More