f8-engine 0.3.2__tar.gz → 0.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {f8_engine-0.3.2 → f8_engine-0.3.3}/Cargo.lock +2 -2
- {f8_engine-0.3.2 → f8_engine-0.3.3}/Cargo.toml +1 -1
- {f8_engine-0.3.2 → f8_engine-0.3.3}/PKG-INFO +1 -1
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/emission/format.rs +17 -2
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/emission/workbook.rs +2 -1
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/layout/mod.rs +103 -54
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/model/error.rs +8 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/model/theme.rs +14 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-python/src/error.rs +1 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/python/f8/skills/f8-modeling/references/syntax-and-grid.md +1 -1
- {f8_engine-0.3.2 → f8_engine-0.3.3}/LICENSE +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/README.md +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/Cargo.toml +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/compiled/error.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/compiled/mod.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/compiled/model.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/emission/error.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/emission/mod.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/error.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/eval/context.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/eval/error.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/eval/expr.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/eval/mod.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/eval/model.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/graph/cycle.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/graph/dependency.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/graph/error.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/graph/mod.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/graph/resolve.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/ir/cell.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/ir/error.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/ir/expand.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/ir/id.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/ir/mod.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/ir/symbol.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/layout/a1.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/layout/error.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/lowering/address.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/lowering/error.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/lowering/mod.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/compiler/mod.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/expr/ast.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/expr/error.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/expr/mod.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/expr/parser.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/common.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/date/constructors.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/date/mod.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/date/parts.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/date/serial.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/date/yearfrac.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/error.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/financial/annuity.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/financial/discounting.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/financial/irr.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/financial/mod.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/logical/boolean.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/logical/branching.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/logical/error_handling.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/logical/mod.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/lookup/index.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/lookup/mod.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/lookup/search.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/lookup/xlookup.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/lookup/xmatch.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/math/aggregation.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/math/basic.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/math/conditional.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/math/criteria.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/math/mod.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/math/product.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/math/rounding.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/mod.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/registry.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/functions/traits.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/lib.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/model/format.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/model/id.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/model/manifest.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/model/mod.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/model/table.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/value/error.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/value/format.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-core/src/value/mod.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-python/Cargo.toml +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-python/src/lib.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/crates/f8-python/src/model.rs +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/pyproject.toml +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/python/f8/__init__.py +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/python/f8/__main__.py +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/python/f8/_core.pyi +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/python/f8/audit.py +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/python/f8/builder.py +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/python/f8/cli.py +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/python/f8/py.typed +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/python/f8/skills/f8-modeling/SKILL.md +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/python/f8/skills/f8-modeling/references/auditing-and-repair.md +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/python/f8/skills/f8-modeling/references/functions.md +0 -0
- {f8_engine-0.3.2 → f8_engine-0.3.3}/python/f8/types.py +0 -0
|
@@ -37,7 +37,7 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
|
|
|
37
37
|
|
|
38
38
|
[[package]]
|
|
39
39
|
name = "f8-core"
|
|
40
|
-
version = "0.3.
|
|
40
|
+
version = "0.3.3"
|
|
41
41
|
dependencies = [
|
|
42
42
|
"indexmap",
|
|
43
43
|
"petgraph",
|
|
@@ -50,7 +50,7 @@ dependencies = [
|
|
|
50
50
|
|
|
51
51
|
[[package]]
|
|
52
52
|
name = "f8-python"
|
|
53
|
-
version = "0.3.
|
|
53
|
+
version = "0.3.3"
|
|
54
54
|
dependencies = [
|
|
55
55
|
"f8-core",
|
|
56
56
|
"pyo3",
|
|
@@ -3,7 +3,7 @@ resolver = "3"
|
|
|
3
3
|
members = ["crates/f8-core", "crates/f8-python"]
|
|
4
4
|
|
|
5
5
|
[workspace.package]
|
|
6
|
-
version = "0.3.
|
|
6
|
+
version = "0.3.3"
|
|
7
7
|
edition = "2024"
|
|
8
8
|
description = "Financial modeling engine with compiler verification and live Excel formulas"
|
|
9
9
|
authors = ["Michael (Chencheng) Hu, CFA"]
|
|
@@ -153,6 +153,8 @@ pub struct CellFormatKey {
|
|
|
153
153
|
pub is_descriptor: bool,
|
|
154
154
|
/// Descriptor indentation level.
|
|
155
155
|
pub indent: u8,
|
|
156
|
+
/// Whether the cell requires multi-line text wrapping.
|
|
157
|
+
pub wrap_text: bool,
|
|
156
158
|
}
|
|
157
159
|
|
|
158
160
|
impl CellFormatKey {
|
|
@@ -175,8 +177,16 @@ impl CellFormatKey {
|
|
|
175
177
|
is_input,
|
|
176
178
|
is_descriptor,
|
|
177
179
|
indent,
|
|
180
|
+
wrap_text: false,
|
|
178
181
|
}
|
|
179
182
|
}
|
|
183
|
+
|
|
184
|
+
/// Builder method enabling or disabling text wrapping on the cell format.
|
|
185
|
+
#[must_use]
|
|
186
|
+
pub const fn with_wrap_text(mut self, wrap_text: bool) -> Self {
|
|
187
|
+
self.wrap_text = wrap_text;
|
|
188
|
+
self
|
|
189
|
+
}
|
|
180
190
|
}
|
|
181
191
|
|
|
182
192
|
/// Format synthesizer and deduplication cache mapping semantic cell keys and structural headers
|
|
@@ -328,7 +338,7 @@ impl FormatCache {
|
|
|
328
338
|
format = format.set_bold();
|
|
329
339
|
}
|
|
330
340
|
|
|
331
|
-
// 2. Alignment
|
|
341
|
+
// 2. Alignment, Indentation, and Wrapping (Descriptor Left with optional indent, Measure Right, VerticalCenter)
|
|
332
342
|
format = if key.is_descriptor {
|
|
333
343
|
let mut fmt = format.set_align(FormatAlign::Left);
|
|
334
344
|
if key.indent > 0 {
|
|
@@ -337,7 +347,12 @@ impl FormatCache {
|
|
|
337
347
|
fmt
|
|
338
348
|
} else {
|
|
339
349
|
format.set_align(FormatAlign::Right)
|
|
340
|
-
}
|
|
350
|
+
}
|
|
351
|
+
.set_align(FormatAlign::VerticalCenter);
|
|
352
|
+
|
|
353
|
+
if key.wrap_text {
|
|
354
|
+
format = format.set_text_wrap();
|
|
355
|
+
}
|
|
341
356
|
|
|
342
357
|
// 3. Background Fill Precedence:
|
|
343
358
|
// is_highlight > total (or shade) > subtotal (or shade) > shade > data
|
|
@@ -20,7 +20,7 @@ use crate::model::format::{CurrencyCode, FormatPreset, SemanticStyle, Shade};
|
|
|
20
20
|
use crate::model::id::{SheetId, TableId};
|
|
21
21
|
use crate::model::manifest::{FreezePanes, ProjectManifest};
|
|
22
22
|
use crate::model::table::{ColumnSpec, PlacementSpec, RowSpec, TableSpec, ValueLiteral};
|
|
23
|
-
use crate::model::theme::Theme;
|
|
23
|
+
use crate::model::theme::{MetricsConfig, Theme};
|
|
24
24
|
use crate::value::{CellValue, format_accounting_number};
|
|
25
25
|
|
|
26
26
|
/// Semantic styling role assigned to a physical coordinate.
|
|
@@ -72,6 +72,9 @@ pub struct PhysicalCoordinate {
|
|
|
72
72
|
pub style_role: StyleRole,
|
|
73
73
|
/// Descriptor text indentation level.
|
|
74
74
|
pub indent: u8,
|
|
75
|
+
/// Whether this cell requires multi-line text wrapping.
|
|
76
|
+
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
|
77
|
+
pub wrap_text: bool,
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
/// Physical bounding box and structural row offsets for a table on a worksheet.
|
|
@@ -464,6 +467,7 @@ impl LayoutPlanner {
|
|
|
464
467
|
a1,
|
|
465
468
|
style_role,
|
|
466
469
|
indent,
|
|
470
|
+
wrap_text: false,
|
|
467
471
|
},
|
|
468
472
|
);
|
|
469
473
|
}
|
|
@@ -524,11 +528,11 @@ impl LayoutPlanner {
|
|
|
524
528
|
tables: &sheet_tables,
|
|
525
529
|
placements: &sheet_placements,
|
|
526
530
|
grid,
|
|
527
|
-
layout_cells: &layout_cells,
|
|
531
|
+
layout_cells: &mut layout_cells,
|
|
528
532
|
theme,
|
|
529
533
|
evaluated,
|
|
530
534
|
}
|
|
531
|
-
.arbitrate(sheet_max_end_col, &mut col_widths);
|
|
535
|
+
.arbitrate(sheet_max_end_col, &mut col_widths, &mut row_heights);
|
|
532
536
|
|
|
533
537
|
layout_sheets.insert(
|
|
534
538
|
sheet_id.clone(),
|
|
@@ -597,19 +601,24 @@ fn resolve_placement_target<'a>(
|
|
|
597
601
|
})
|
|
598
602
|
}
|
|
599
603
|
|
|
600
|
-
/// Context and
|
|
604
|
+
/// Context and inputs for arbitrating sheet-wide column widths and cell text wrapping across placed tables.
|
|
601
605
|
struct ColumnArbitrationContext<'a> {
|
|
602
606
|
tables: &'a [&'a TableSpec],
|
|
603
607
|
placements: &'a IndexMap<TableId, TablePlacement>,
|
|
604
608
|
grid: &'a CellGrid,
|
|
605
|
-
layout_cells: &'a IndexMap<CellId, PhysicalCoordinate>,
|
|
609
|
+
layout_cells: &'a mut IndexMap<CellId, PhysicalCoordinate>,
|
|
606
610
|
theme: &'a Theme,
|
|
607
611
|
evaluated: Option<&'a EvaluatedModel>,
|
|
608
612
|
}
|
|
609
613
|
|
|
610
614
|
impl ColumnArbitrationContext<'_> {
|
|
611
|
-
/// Arbitrates sheet-wide column widths across all tables sharing worksheet columns.
|
|
612
|
-
fn arbitrate(
|
|
615
|
+
/// Arbitrates sheet-wide column widths, cell text wrapping, and multi-line row heights across all tables sharing worksheet columns.
|
|
616
|
+
fn arbitrate(
|
|
617
|
+
&mut self,
|
|
618
|
+
sheet_max_end_col: u32,
|
|
619
|
+
col_widths: &mut IndexMap<u32, f64>,
|
|
620
|
+
row_heights: &mut IndexMap<u32, f64>,
|
|
621
|
+
) {
|
|
613
622
|
for physical_col in 1..=sheet_max_end_col {
|
|
614
623
|
let has_data_col = self.tables.iter().any(|t| {
|
|
615
624
|
let Some(placement) = self.placements.get(&t.id) else {
|
|
@@ -647,7 +656,7 @@ impl ColumnArbitrationContext<'_> {
|
|
|
647
656
|
let header_len = data_col.max_header_chars();
|
|
648
657
|
table_max_chars = table_max_chars.max(header_len);
|
|
649
658
|
|
|
650
|
-
// 2. Row cells text length
|
|
659
|
+
// 2. Row cells text length and multi-line wrapping
|
|
651
660
|
for row in &table.rows {
|
|
652
661
|
let RowSpec::Data(data_row) = row else {
|
|
653
662
|
continue;
|
|
@@ -660,25 +669,41 @@ impl ColumnArbitrationContext<'_> {
|
|
|
660
669
|
format.and_then(|f| self.theme.number_formats.default_decimals(f))
|
|
661
670
|
});
|
|
662
671
|
let currency = cell_node.and_then(|n| n.currency);
|
|
672
|
+
let indent = self.layout_cells.get(&cell_id).map_or(0, |c| c.indent);
|
|
663
673
|
|
|
664
|
-
let
|
|
674
|
+
let (char_len, lines) =
|
|
665
675
|
match (self.evaluated.and_then(|e| e.get_cell(&cell_id)), cell_node) {
|
|
666
|
-
(Some(val), _) =>
|
|
667
|
-
|
|
668
|
-
|
|
676
|
+
(Some(val), _) => measure_cell_value(
|
|
677
|
+
val,
|
|
678
|
+
format,
|
|
679
|
+
decimals,
|
|
680
|
+
currency,
|
|
681
|
+
indent,
|
|
682
|
+
&self.theme.metrics,
|
|
683
|
+
),
|
|
669
684
|
(None, Some(node)) => match &node.payload {
|
|
670
|
-
CellPayload::Literal(lit) =>
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
685
|
+
CellPayload::Literal(lit) => measure_literal_value(
|
|
686
|
+
lit,
|
|
687
|
+
format,
|
|
688
|
+
decimals,
|
|
689
|
+
currency,
|
|
690
|
+
indent,
|
|
691
|
+
&self.theme.metrics,
|
|
692
|
+
),
|
|
693
|
+
CellPayload::Formula(_) => (usize::from(indent) * 2, 1),
|
|
674
694
|
},
|
|
675
|
-
(None, None) =>
|
|
695
|
+
(None, None) => (usize::from(indent) * 2, 1),
|
|
676
696
|
};
|
|
677
697
|
|
|
678
|
-
if
|
|
679
|
-
&& coord
|
|
698
|
+
if lines > 1
|
|
699
|
+
&& let Some(coord) = self.layout_cells.get_mut(&cell_id)
|
|
680
700
|
{
|
|
681
|
-
|
|
701
|
+
coord.wrap_text = true;
|
|
702
|
+
record_row_height(
|
|
703
|
+
row_heights,
|
|
704
|
+
coord.row,
|
|
705
|
+
(lines as f64) * self.theme.metrics.data_row_height,
|
|
706
|
+
);
|
|
682
707
|
}
|
|
683
708
|
|
|
684
709
|
table_max_chars = table_max_chars.max(char_len);
|
|
@@ -687,11 +712,14 @@ impl ColumnArbitrationContext<'_> {
|
|
|
687
712
|
max_chars_across_tables = max_chars_across_tables.max(table_max_chars);
|
|
688
713
|
}
|
|
689
714
|
|
|
690
|
-
// Apply theme font multiplier and padding,
|
|
715
|
+
// Apply theme font multiplier and padding, clamping to [min_col_width, max_col_width]
|
|
691
716
|
let computed_width = (max_chars_across_tables as f64
|
|
692
717
|
* self.theme.metrics.char_width_multiplier
|
|
693
718
|
+ self.theme.metrics.col_padding)
|
|
694
|
-
.
|
|
719
|
+
.clamp(
|
|
720
|
+
self.theme.metrics.min_col_width,
|
|
721
|
+
self.theme.metrics.max_col_width,
|
|
722
|
+
);
|
|
695
723
|
|
|
696
724
|
let final_width = (computed_width * 100.0).round() / 100.0;
|
|
697
725
|
let existing = col_widths.get(&physical_col).copied().unwrap_or(0.0);
|
|
@@ -700,51 +728,72 @@ impl ColumnArbitrationContext<'_> {
|
|
|
700
728
|
}
|
|
701
729
|
}
|
|
702
730
|
|
|
703
|
-
fn
|
|
731
|
+
fn measure_text_segments(
|
|
732
|
+
s: &str,
|
|
733
|
+
format: Option<FormatPreset>,
|
|
734
|
+
indent: u8,
|
|
735
|
+
metrics: &MetricsConfig,
|
|
736
|
+
) -> (usize, usize) {
|
|
737
|
+
let trailing_pad = usize::from(format == Some(FormatPreset::Text));
|
|
738
|
+
let indent_chars = usize::from(indent) * 2;
|
|
739
|
+
let mut max_chars = 0;
|
|
740
|
+
let mut total_lines = 0;
|
|
741
|
+
|
|
742
|
+
for segment in s.split('\n') {
|
|
743
|
+
let seg_chars = segment.chars().count() + trailing_pad + indent_chars;
|
|
744
|
+
max_chars = max_chars.max(seg_chars);
|
|
745
|
+
let seg_lines = if seg_chars == 0 {
|
|
746
|
+
1
|
|
747
|
+
} else {
|
|
748
|
+
let seg_width =
|
|
749
|
+
(seg_chars as f64) * metrics.char_width_multiplier + metrics.col_padding;
|
|
750
|
+
((seg_width / metrics.max_col_width).ceil() as usize).max(1)
|
|
751
|
+
};
|
|
752
|
+
total_lines += seg_lines;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
(max_chars, total_lines)
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
fn measure_literal_value(
|
|
704
759
|
lit: &ValueLiteral,
|
|
705
760
|
format: Option<FormatPreset>,
|
|
706
761
|
decimals: Option<u32>,
|
|
707
762
|
currency: Option<CurrencyCode>,
|
|
708
|
-
|
|
763
|
+
indent: u8,
|
|
764
|
+
metrics: &MetricsConfig,
|
|
765
|
+
) -> (usize, usize) {
|
|
766
|
+
let indent_chars = usize::from(indent) * 2;
|
|
709
767
|
match lit {
|
|
710
|
-
ValueLiteral::String(s) =>
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
ValueLiteral::Boolean(b) => {
|
|
716
|
-
|
|
717
|
-
4
|
|
718
|
-
} else {
|
|
719
|
-
5
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
ValueLiteral::Null => 0,
|
|
768
|
+
ValueLiteral::String(s) => measure_text_segments(s, format, indent, metrics),
|
|
769
|
+
ValueLiteral::Number(n) => (
|
|
770
|
+
formatted_number_estimate(*n, format, decimals, currency) + indent_chars,
|
|
771
|
+
1,
|
|
772
|
+
),
|
|
773
|
+
ValueLiteral::Boolean(b) => ((if *b { 4 } else { 5 }) + indent_chars, 1),
|
|
774
|
+
ValueLiteral::Null => (indent_chars, 1),
|
|
723
775
|
}
|
|
724
776
|
}
|
|
725
777
|
|
|
726
|
-
/// Computes the
|
|
727
|
-
fn
|
|
778
|
+
/// Computes the horizontal character demand and wrapped line count of an evaluated `CellValue`.
|
|
779
|
+
fn measure_cell_value(
|
|
728
780
|
val: &CellValue,
|
|
729
781
|
format: Option<FormatPreset>,
|
|
730
782
|
decimals: Option<u32>,
|
|
731
783
|
currency: Option<CurrencyCode>,
|
|
732
|
-
|
|
784
|
+
indent: u8,
|
|
785
|
+
metrics: &MetricsConfig,
|
|
786
|
+
) -> (usize, usize) {
|
|
787
|
+
let indent_chars = usize::from(indent) * 2;
|
|
733
788
|
match val {
|
|
734
|
-
CellValue::Text(s) =>
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
CellValue::Boolean(b) => {
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
} else {
|
|
743
|
-
5
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
CellValue::Error(e) => e.to_string().chars().count(),
|
|
747
|
-
CellValue::Empty => 0,
|
|
789
|
+
CellValue::Text(s) => measure_text_segments(s, format, indent, metrics),
|
|
790
|
+
CellValue::Number(n) => (
|
|
791
|
+
formatted_number_estimate(*n, format, decimals, currency) + indent_chars,
|
|
792
|
+
1,
|
|
793
|
+
),
|
|
794
|
+
CellValue::Boolean(b) => ((if *b { 4 } else { 5 }) + indent_chars, 1),
|
|
795
|
+
CellValue::Error(e) => (e.to_string().chars().count() + indent_chars, 1),
|
|
796
|
+
CellValue::Empty => (indent_chars, 1),
|
|
748
797
|
}
|
|
749
798
|
}
|
|
750
799
|
|
|
@@ -118,6 +118,14 @@ pub enum ModelError {
|
|
|
118
118
|
#[error("Invalid theme metric '{metric}': expected positive finite value, found {value}")]
|
|
119
119
|
InvalidThemeMetric { metric: String, value: f64 },
|
|
120
120
|
|
|
121
|
+
#[error(
|
|
122
|
+
"Invalid theme column width bounds: max_col_width ({max_col_width}) must be greater than or equal to min_col_width ({min_col_width})"
|
|
123
|
+
)]
|
|
124
|
+
InvalidColWidthBounds {
|
|
125
|
+
min_col_width: f64,
|
|
126
|
+
max_col_width: f64,
|
|
127
|
+
},
|
|
128
|
+
|
|
121
129
|
#[error("Theme format template for '{preset}' must contain '{{dec}}' placeholder")]
|
|
122
130
|
MissingDecimalPlaceholder { preset: FormatPreset },
|
|
123
131
|
|
|
@@ -104,6 +104,10 @@ impl Default for TypographyConfig {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
fn default_max_col_width() -> f64 {
|
|
108
|
+
50.0
|
|
109
|
+
}
|
|
110
|
+
|
|
107
111
|
/// Physical row heights, column character widths, gutters, and margins.
|
|
108
112
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
|
109
113
|
pub struct MetricsConfig {
|
|
@@ -117,6 +121,8 @@ pub struct MetricsConfig {
|
|
|
117
121
|
pub char_width_multiplier: f64,
|
|
118
122
|
pub col_padding: f64,
|
|
119
123
|
pub min_col_width: f64,
|
|
124
|
+
#[serde(default = "default_max_col_width")]
|
|
125
|
+
pub max_col_width: f64,
|
|
120
126
|
}
|
|
121
127
|
|
|
122
128
|
impl Default for MetricsConfig {
|
|
@@ -132,6 +138,7 @@ impl Default for MetricsConfig {
|
|
|
132
138
|
char_width_multiplier: 1.0,
|
|
133
139
|
col_padding: 0.0,
|
|
134
140
|
min_col_width: 12.0,
|
|
141
|
+
max_col_width: default_max_col_width(),
|
|
135
142
|
}
|
|
136
143
|
}
|
|
137
144
|
}
|
|
@@ -329,6 +336,13 @@ impl MetricsConfig {
|
|
|
329
336
|
validate_metric("char_width_multiplier", self.char_width_multiplier)?;
|
|
330
337
|
validate_non_negative_metric("col_padding", self.col_padding)?;
|
|
331
338
|
validate_metric("min_col_width", self.min_col_width)?;
|
|
339
|
+
validate_metric("max_col_width", self.max_col_width)?;
|
|
340
|
+
if self.max_col_width < self.min_col_width {
|
|
341
|
+
return Err(ModelError::InvalidColWidthBounds {
|
|
342
|
+
min_col_width: self.min_col_width,
|
|
343
|
+
max_col_width: self.max_col_width,
|
|
344
|
+
});
|
|
345
|
+
}
|
|
332
346
|
Ok(())
|
|
333
347
|
}
|
|
334
348
|
}
|
|
@@ -264,6 +264,7 @@ pub fn map_compiler_error(py: Python<'_>, err: &CompilerError) -> PyErr {
|
|
|
264
264
|
| ModelError::ThemeNotFound { .. }
|
|
265
265
|
| ModelError::InvalidThemeColor { .. }
|
|
266
266
|
| ModelError::InvalidThemeMetric { .. }
|
|
267
|
+
| ModelError::InvalidColWidthBounds { .. }
|
|
267
268
|
| ModelError::MissingDecimalPlaceholder { .. }
|
|
268
269
|
| ModelError::MissingCurrencySymbolPlaceholder
|
|
269
270
|
| ModelError::ThemePrecisionOutOfBounds { .. } => None,
|
{f8_engine-0.3.2 → f8_engine-0.3.3}/python/f8/skills/f8-modeling/references/syntax-and-grid.md
RENAMED
|
@@ -283,7 +283,7 @@ table.add_column_gutter() -> Table
|
|
|
283
283
|
- Table banners and collapsing:
|
|
284
284
|
- Non-empty `title` emits a full-width title banner row (`start_col..=end_col`). `subtitle` emits a subtitle row beneath `title` (passing an empty or whitespace-only `subtitle=""` raises `SpecificationError`; use `subtitle=None` to omit). If either `title` or `subtitle` is present, a 1-row buffer gutter is inserted before column headers; passing `title=""` (with `subtitle=None`) omits both banner and buffer gutter so column headers start at `start_row`.
|
|
285
285
|
- `collapsible=True`: Groups physical rows `start_row + 1..=end_row` in Excel outline with summary symbols above (`group_symbols_above(True)`).
|
|
286
|
-
- Column width arbitration: Each physical worksheet column takes the maximum width across all tables spanning that column, computed as `round(
|
|
286
|
+
- Column width arbitration & text wrapping: Each physical worksheet column takes the maximum width across all tables spanning that column, computed as `round(clamp(max_chars * char_width_multiplier + col_padding, min_col_width, max_col_width), 2)` (default `col_padding=0.0`, `min_col_width=12.0`, `max_col_width=50.0`, where `max_chars` spans per-column header lines—excluding spanning `group`—and `\n`-delimited data cell segments with `indent * 2` plus `+1` alignment-space character on formatted values with trailing alignment spaces; gutter-only columns use `gutter_col_width=3.0`). Cells whose effective width exceeds `max_col_width` or that contain `\n` newlines enable OpenXML `wrapText="1"` (`FormatAlign::VerticalCenter` on all data cells) and scale `SheetLayout.row_heights` to `lines * data_row_height` while leaving `.xlsx` row heights automatic for Excel font auto-fitting.
|
|
287
287
|
|
|
288
288
|
---
|
|
289
289
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{f8_engine-0.3.2 → f8_engine-0.3.3}/python/f8/skills/f8-modeling/references/auditing-and-repair.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|