diff --git a/.cargo/audit.toml b/.cargo/audit.toml new file mode 100644 index 0000000..8445275 --- /dev/null +++ b/.cargo/audit.toml @@ -0,0 +1,8 @@ +[advisories] +ignore = [ + # `proc-macro-error` is Unmaintained. + # + # Transitive dependency of `syn_derive`. + # Pending https://github.com/Kyuuhachi/syn_derive/issues/4. + "RUSTSEC-2024-0370", +] diff --git a/CHANGELOG.md b/CHANGELOG.md index 38744f3..a999b55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ * Support inline images ([#33]). * Support `splines` in `GraphvizAttrs`. +* Support `nodesep` in `GraphvizAttrs`. +* Support `ranksep` in `GraphvizAttrs`. [#33]: https://github.com/azriel91/dot_ix/issues/33 diff --git a/Cargo.toml b/Cargo.toml index 6885e3d..2e6fb66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,12 +62,12 @@ dot_ix_static_check_macros = { version = "0.8.0", path = "crate/static_check_mac dot_ix_web_components = { version = "0.8.0", path = "crate/web_components" } # external crates -axum = "0.7.5" +axum = "0.7.6" console_error_panic_hook = "0.1" console_log = "1" cfg-if = "1" gloo-net = "0.6.0" -indexmap = "2.4.0" +indexmap = "2.5.0" indoc = "2.0.5" js-sys = "0.3.70" web-sys = "0.3.70" @@ -75,23 +75,23 @@ leptos = { version = "0.6" } leptos_axum = "0.6" leptos_meta = { version = "0.6" } leptos_router = { version = "0.6" } -leptos-use = "0.12.0" +leptos-use = "0.13.5" log = "0.4" log4rs = { version = "1.3.0", default-features = false } monaco = "0.4.0" -serde = "1.0.207" +serde = "1.0.210" tempfile = "3.12.0" -tokio = "1.39.2" -tower = "0.5.0" +tokio = "1.40.0" +tower = "0.5.1" wasm-bindgen = "0.2.93" tailwind-css = "0.13.0" -thiserror = "1.0.63" +thiserror = "1.0.64" tracing = "0.1.40" http = "1.1.0" proc-macro2 = "1.0.86" -quote = "1.0.36" -reqwest = "0.12.5" -syn = "2.0.74" +quote = "1.0.37" +reqwest = "0.12.7" +syn = "2.0.77" serde_yaml = "0.9.34" [workspace.lints.rust] diff --git a/crate/model/src/common/graphviz_attrs.rs b/crate/model/src/common/graphviz_attrs.rs index 30af9a6..a3c62ce 100644 --- a/crate/model/src/common/graphviz_attrs.rs +++ b/crate/model/src/common/graphviz_attrs.rs @@ -17,6 +17,26 @@ mod splines; #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] #[serde(default)] pub struct GraphvizAttrs { + /// Minimum space between two adjacent nodes in the same rank, in + /// inches. Also controls the spacing between multiple edges between the + /// same pair of nodes. + /// + /// Defaults to `0.25`. Minimum `0.02`. + /// + /// See [`nodesep`]. + /// + /// [`nodesep`]: https://graphviz.org/docs/attrs/nodesep/ + pub nodesep: f64, + /// The desired separation between nodes of different ranks, in inches. See + /// [`ranksep`]. + /// + /// Defaults to `0.25`. Minimum `0.02`. + /// + /// This does not support the `equally` string (yet). I'm not sure if it is + /// used. + /// + /// [`ranksep`]: https://graphviz.org/docs/attrs/ranksep/ + pub ranksep: f64, /// How to render edge lines. See [`splines`]. /// /// [`splines`]: https://graphviz.org/docs/attrs/splines/ @@ -55,6 +75,34 @@ impl GraphvizAttrs { Self::default() } + /// Sets the minimum space between two adjacent nodes in the same rank, in + /// inches. Also controls the spacing between multiple edges between the + /// same pair of nodes. + /// + /// Defaults to `0.25`. Minimum `0.02`. + /// + /// See [`nodesep`]. + /// + /// [`nodesep`]: https://graphviz.org/docs/attrs/nodesep/ + pub fn with_nodesep(mut self, nodesep: f64) -> Self { + self.nodesep = nodesep; + self + } + + /// Sets the desired separation between nodes of different ranks, in inches. + /// See [`ranksep`]. + /// + /// Defaults to `0.25`. Minimum `0.02`. + /// + /// This does not support the `equally` string (yet). I'm not sure if it is + /// used. + /// + /// [`ranksep`]: https://graphviz.org/docs/attrs/ranksep/ + pub fn with_ranksep(mut self, ranksep: f64) -> Self { + self.ranksep = ranksep; + self + } + /// Sets how to render edge lines. See [`splines`]. /// /// [`splines`]: https://graphviz.org/docs/attrs/splines/ @@ -111,6 +159,29 @@ impl GraphvizAttrs { self } + /// Returns the minimum space between two adjacent nodes in the same rank, + /// in inches. Also controls the spacing between multiple edges between + /// the same pair of nodes. + /// + /// Defaults to `0.25`. Minimum `0.02`. + /// + /// See [`nodesep`]. + /// + /// [`nodesep`]: https://graphviz.org/docs/attrs/nodesep/ + pub fn nodesep(&self) -> f64 { + self.nodesep + } + + /// Returns the desired separation between nodes of different ranks, in + /// inches. See [`ranksep`]. + /// + /// Defaults to `0.25`. Minimum `0.02`. + /// + /// [`ranksep`]: https://graphviz.org/docs/attrs/ranksep/ + pub fn ranksep(&self) -> f64 { + self.ranksep + } + /// Returns how to render edge lines. See [`splines`]. /// /// [`splines`]: https://graphviz.org/docs/attrs/splines/ @@ -164,6 +235,8 @@ impl GraphvizAttrs { impl Default for GraphvizAttrs { fn default() -> Self { Self { + nodesep: 0.25, + ranksep: 0.25, splines: Splines::default(), edge_constraint_default: true, edge_constraints: EdgeConstraints::default(), diff --git a/crate/model/src/common/id_newtype.rs b/crate/model/src/common/id_newtype.rs index 44d1a7c..c18c27d 100644 --- a/crate/model/src/common/id_newtype.rs +++ b/crate/model/src/common/id_newtype.rs @@ -44,7 +44,7 @@ macro_rules! id_newtype { /// compile time checks and returns a `const` value. /// #[doc = concat!("[`", stringify!($macro_name), "!`]: dot_ix_static_check_macros::profile")] - pub fn new(s: &'static str) -> Result { + pub fn new(s: &'static str) -> Result> { Self::try_from(s) } diff --git a/crate/rt/src/into_graphviz_dot_src/info_graph.rs b/crate/rt/src/into_graphviz_dot_src/info_graph.rs index 8d3cd76..cf49486 100644 --- a/crate/rt/src/into_graphviz_dot_src/info_graph.rs +++ b/crate/rt/src/into_graphviz_dot_src/info_graph.rs @@ -234,6 +234,8 @@ fn graph_attrs( GraphDir::Vertical => "TB", }; + let nodesep = graphviz_attrs.nodesep(); + let ranksep = graphviz_attrs.ranksep(); let splines = graphviz_attrs.splines(); let splines = match splines { Splines::Unset => Cow::Borrowed(""), @@ -250,9 +252,8 @@ fn graph_attrs( compound = true graph [ margin = 0.1 - penwidth = 0 - nodesep = 0.0 - ranksep = 0.02 + nodesep = {nodesep} + ranksep = {ranksep} bgcolor = "transparent" fontname = "helvetica" packmode = "{pack_mode}" diff --git a/deny.toml b/deny.toml index 4e52f3f..55cf7b9 100644 --- a/deny.toml +++ b/deny.toml @@ -70,7 +70,11 @@ yanked = "warn" # A list of advisory IDs to ignore. Note that ignored advisories will still # output a note when they are encountered. ignore = [ - #"RUSTSEC-0000-0000", + # `proc-macro-error` is Unmaintained. + # + # Transitive dependency of `syn_derive`. + # Pending https://github.com/Kyuuhachi/syn_derive/issues/4. + "RUSTSEC-2024-0370", ] # If this is true, then cargo deny will use the git executable to fetch advisory database. diff --git a/playground/Cargo.toml b/playground/Cargo.toml index 03d8dbe..3b74e36 100644 --- a/playground/Cargo.toml +++ b/playground/Cargo.toml @@ -34,7 +34,7 @@ reqwest = { workspace = true, optional = true } serde = { workspace = true, features = ["derive"] } tokio = { workspace = true, optional = true } tower = { workspace = true, optional = true } -tower-http = { version = "0.5", features = ["fs"], optional = true } +tower-http = { version = "0.6", features = ["fs"], optional = true } tracing = { workspace = true, optional = true } http = { workspace = true } serde_yaml = { workspace = true } diff --git a/rustfmt.toml b/rustfmt.toml index b7e1fa5..008ee43 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -4,4 +4,4 @@ use_field_init_shorthand = true format_code_in_doc_comments = true wrap_comments = true edition = "2021" -version = "Two" +style_edition = "2021"