Shape Fill: the gradient help lists every kind and key the command takes

The shape.fill params doc listed only linear and radial gradients with
stops, angle and kind. The command also takes the rectangular and path
kinds, focus and rotateWithShape. The doc now names them, and a test
checks the doc's gradient keys and kinds against what the command reads.
This commit is contained in:
dotCooCoo
2026-10-30 22:02:08 -07:00
parent 4ce2944630
commit e747bff425
2 changed files with 33 additions and 1 deletions
+1 -1
View File
@@ -103,7 +103,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Shape Fill",
["Shape Format", "Shape Styles"],
None,
"{color? | none?: true | background?: true (the slide background shows through; shapes and text boxes only) | gradient?: {stops: [[pos, color]], angle?, kind?: linear|radial} | picture?: base64 | pattern?: {preset, fg, bg} | transparency?: 0..1 | reset?: true, ids?}; pictureProps?: {tile?: bool, offsetX?, offsetY?: pt, scaleX?, scaleY?: 0..10, align?: tl|t|tr|l|ctr|r|bl|b|br, mirror?: none|x|y|xy, stretch?: [l, t, r, b] fractions, rotateWithShape?: bool} adjusts a picture fill; a group also formats its members",
"{color? | none?: true | background?: true (the slide background shows through; shapes and text boxes only) | gradient?: {stops: [[pos 0..1, color]], kind?: linear|radial|rectangular|path, angle?: deg (linear), focus?: [l, t, r, b] fractions (radial, rectangular and path: where the first stop sits), rotateWithShape?: bool} | picture?: base64 | pattern?: {preset, fg, bg} | transparency?: 0..1 | reset?: true, ids?}; pictureProps?: {tile?: bool, offsetX?, offsetY?: pt, scaleX?, scaleY?: 0..10, align?: tl|t|tr|l|ctr|r|bl|b|br, mirror?: none|x|y|xy, stretch?: [l, t, r, b] fractions, rotateWithShape?: bool} adjusts a picture fill; a group also formats its members",
has_selection,
fill
),
+32
View File
@@ -4281,6 +4281,38 @@ fn a_params_doc_spells_out_each_parameter() {
);
}
/// `shape.fill`'s params doc names each key and kind its `gradient` takes.
#[test]
fn shape_fill_documents_each_gradient_key_and_kind() {
use deckcraft_model::style::GradientShape;
let params = cmd::parse_params(find_command("shape.fill").unwrap().params).unwrap();
let about = params.iter().find(|p| p.name == "gradient").unwrap().about;
assert_eq!(cmd::param_keys(about).unwrap(), ["stops", "kind", "angle", "focus", "rotateWithShape"]);
for kind in ["linear", "radial", "rectangular", "path"] {
assert!(about.contains(kind), "{kind}: {about}");
let g = cmd::shape::gradient_param(&json!({
"stops": [[0, "#ffffff"], [1, "#000000"]],
"kind": kind,
"angle": 30,
"focus": [0, 0, 1, 1],
"rotateWithShape": false
}))
.unwrap();
assert!(!g.rotate_with_shape, "{kind}");
match g.shape {
GradientShape::Linear { angle, .. } => assert_eq!((kind, angle), ("linear", 30.0)),
GradientShape::Path { path, focus } => {
let expected = match kind {
"radial" => "circle",
"rectangular" => "rect",
_ => "shape",
};
assert_eq!((path.as_str(), focus), (expected, [0.0, 0.0, 1.0, 1.0]), "{kind}");
}
}
}
}
#[test]
fn what_a_command_acts_on_names_only_keys_it_takes() {
for c in command_specs() {