Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/ogar-from-rails/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ serde = [
[dependencies]
ogar-vocab = { path = "../ogar-vocab" }
ogar-from-ruff = { path = "../ogar-from-ruff" }
ruff_ruby_spo = { git = "https://github.com/AdaWorldAPI/ruff", branch = "main" }
# Same exact ruff rev as ogar-from-ruff (they share ruff_spo_triplet
# internally; a rev mismatch double-checks-out ruff). Bump in lockstep.
ruff_ruby_spo = { git = "https://github.com/AdaWorldAPI/ruff", rev = "61ce2b490fc3c432d36c44eceed08125f838b405" }
serde = { workspace = true, optional = true }
11 changes: 9 additions & 2 deletions crates/ogar-from-ruff/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ serde = ["dep:serde", "ogar-vocab/serde"]

[dependencies]
ogar-vocab = { path = "../ogar-vocab" }
ruff_spo_triplet = { git = "https://github.com/AdaWorldAPI/ruff", branch = "main" }
ruff_spo_address = { git = "https://github.com/AdaWorldAPI/ruff", branch = "main" }
# ruff pinned to an exact rev (not floating `branch = "main"`): this crate
# reads `ruff_spo_triplet::Model::inherits`, added in ruff PR #40. With no
# committed Cargo.lock, a floating branch could resolve `main` to a rev
# WITHOUT that field and fail to compile. `61ce2b49` is ruff main at the #40
# merge. Both ruff crates MUST share one rev (they depend on ruff_spo_triplet
# internally; a mismatch double-checks-out ruff). Bump in lockstep with
# ogar-from-rails.
ruff_spo_triplet = { git = "https://github.com/AdaWorldAPI/ruff", rev = "61ce2b490fc3c432d36c44eceed08125f838b405" }
ruff_spo_address = { git = "https://github.com/AdaWorldAPI/ruff", rev = "61ce2b490fc3c432d36c44eceed08125f838b405" }
serde = { workspace = true, optional = true }
1 change: 1 addition & 0 deletions crates/ogar-render-askama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ description = "Build-time askama codegen harness over the canonical layer — on

[dependencies]
ogar-vocab = { path = "../ogar-vocab" }
lance-graph-contract = { git = "https://github.com/AdaWorldAPI/lance-graph", branch = "main" }
askama = "0.12"
6 changes: 3 additions & 3 deletions crates/ogar-render-askama/src/artifact_kinds/rust_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl ArtifactEmitter for RustStructEmitter {
/// 2024 strict + reserved-future); a `&str` slot from the canonical layer
/// can never need a non-identifier escape since names are sourced from
/// Rails / Odoo identifiers.
fn escape_rust_ident(name: &str) -> String {
pub(crate) fn escape_rust_ident(name: &str) -> String {
const RESERVED: &[&str] = &[
// Rust 2015+ strict keywords:
"as", "break", "const", "continue", "crate", "else", "enum", "extern",
Expand All @@ -142,7 +142,7 @@ fn escape_rust_ident(name: &str) -> String {
/// today. Each `op-*` / `rm-*` consumer is free to specialise (e.g.
/// `Decimal` vs `f64` for monetary slots) downstream. The point is the
/// canonical contract round-trips; precision is a per-consumer concern.
fn rails_to_rust_type(t: Option<&str>) -> String {
pub(crate) fn rails_to_rust_type(t: Option<&str>) -> String {
match t {
Some("string") | Some("text") => "String".into(),
Some("integer") | Some("big_integer") | Some("bigint") => "i64".into(),
Expand All @@ -155,7 +155,7 @@ fn rails_to_rust_type(t: Option<&str>) -> String {
}
}

fn edge_rust_type(a: &ogar_vocab::Association) -> String {
pub(crate) fn edge_rust_type(a: &ogar_vocab::Association) -> String {
// Coarse: `belongs_to` / `has_one` → `Option<u64>` (FK id),
// `has_many` / `habtm` → `Vec<u64>`. The concrete `op-*` / `rm-*`
// consumer can swap these for typed references downstream.
Expand Down
13 changes: 11 additions & 2 deletions crates/ogar-render-askama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
pub mod artifact_kinds;
pub mod form_view;
pub mod list_view;
pub mod rust_class;
pub mod spec;

pub use artifact_kinds::{
Expand All @@ -80,6 +81,7 @@ pub use artifact_kinds::{
};
pub use form_view::{default_input_kind_for, InputKind};
pub use list_view::{default_kind_for, ColumnKind, RenderColumn, SortOrder};
pub use rust_class::render_class_with_methods;
pub use spec::{ArtifactKind, ArtifactSpec};

use ogar_vocab::Class;
Expand Down Expand Up @@ -329,8 +331,15 @@ mod tests {
}],
block: vec![],
};
let src = render_list("By status", 0x0102, "project_work_item", &[col.clone()], &[], &[row])
.unwrap();
let src = render_list(
"By status",
0x0102,
"project_work_item",
std::slice::from_ref(&col),
&[],
&[row],
)
.unwrap();
assert!(src.contains("class=\"group open\""), "{src}");
assert!(src.contains("<span class=\"name\">Open</span>"), "{src}");
assert!(src.contains("<span class=\"badge\">5</span>"), "{src}");
Expand Down
Loading
Loading