Skip to content

Commit 92ab186

Browse files
authored
Merge pull request #36 from azriel91/feature/node-sep-and-rank-sep
Support `nodesep` and `ranksep`
2 parents 3a90c45 + 1467aa3 commit 92ab186

File tree

9 files changed

+105
-17
lines changed

9 files changed

+105
-17
lines changed

.cargo/audit.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[advisories]
2+
ignore = [
3+
# `proc-macro-error` is Unmaintained.
4+
#
5+
# Transitive dependency of `syn_derive`.
6+
# Pending https://github.com/Kyuuhachi/syn_derive/issues/4.
7+
"RUSTSEC-2024-0370",
8+
]

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
* Support inline images ([#33]).
66
* Support `splines` in `GraphvizAttrs`.
7+
* Support `nodesep` in `GraphvizAttrs`.
8+
* Support `ranksep` in `GraphvizAttrs`.
79

810

911
[#33]: https://github.com/azriel91/dot_ix/issues/33

Cargo.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,36 +62,36 @@ dot_ix_static_check_macros = { version = "0.8.0", path = "crate/static_check_mac
6262
dot_ix_web_components = { version = "0.8.0", path = "crate/web_components" }
6363

6464
# external crates
65-
axum = "0.7.5"
65+
axum = "0.7.6"
6666
console_error_panic_hook = "0.1"
6767
console_log = "1"
6868
cfg-if = "1"
6969
gloo-net = "0.6.0"
70-
indexmap = "2.4.0"
70+
indexmap = "2.5.0"
7171
indoc = "2.0.5"
7272
js-sys = "0.3.70"
7373
web-sys = "0.3.70"
7474
leptos = { version = "0.6" }
7575
leptos_axum = "0.6"
7676
leptos_meta = { version = "0.6" }
7777
leptos_router = { version = "0.6" }
78-
leptos-use = "0.12.0"
78+
leptos-use = "0.13.5"
7979
log = "0.4"
8080
log4rs = { version = "1.3.0", default-features = false }
8181
monaco = "0.4.0"
82-
serde = "1.0.207"
82+
serde = "1.0.210"
8383
tempfile = "3.12.0"
84-
tokio = "1.39.2"
85-
tower = "0.5.0"
84+
tokio = "1.40.0"
85+
tower = "0.5.1"
8686
wasm-bindgen = "0.2.93"
8787
tailwind-css = "0.13.0"
88-
thiserror = "1.0.63"
88+
thiserror = "1.0.64"
8989
tracing = "0.1.40"
9090
http = "1.1.0"
9191
proc-macro2 = "1.0.86"
92-
quote = "1.0.36"
93-
reqwest = "0.12.5"
94-
syn = "2.0.74"
92+
quote = "1.0.37"
93+
reqwest = "0.12.7"
94+
syn = "2.0.77"
9595
serde_yaml = "0.9.34"
9696

9797
[workspace.lints.rust]

crate/model/src/common/graphviz_attrs.rs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@ mod splines;
1717
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
1818
#[serde(default)]
1919
pub struct GraphvizAttrs {
20+
/// Minimum space between two adjacent nodes in the same rank, in
21+
/// inches. Also controls the spacing between multiple edges between the
22+
/// same pair of nodes.
23+
///
24+
/// Defaults to `0.25`. Minimum `0.02`.
25+
///
26+
/// See [`nodesep`].
27+
///
28+
/// [`nodesep`]: https://graphviz.org/docs/attrs/nodesep/
29+
pub nodesep: f64,
30+
/// The desired separation between nodes of different ranks, in inches. See
31+
/// [`ranksep`].
32+
///
33+
/// Defaults to `0.25`. Minimum `0.02`.
34+
///
35+
/// This does not support the `equally` string (yet). I'm not sure if it is
36+
/// used.
37+
///
38+
/// [`ranksep`]: https://graphviz.org/docs/attrs/ranksep/
39+
pub ranksep: f64,
2040
/// How to render edge lines. See [`splines`].
2141
///
2242
/// [`splines`]: https://graphviz.org/docs/attrs/splines/
@@ -55,6 +75,34 @@ impl GraphvizAttrs {
5575
Self::default()
5676
}
5777

78+
/// Sets the minimum space between two adjacent nodes in the same rank, in
79+
/// inches. Also controls the spacing between multiple edges between the
80+
/// same pair of nodes.
81+
///
82+
/// Defaults to `0.25`. Minimum `0.02`.
83+
///
84+
/// See [`nodesep`].
85+
///
86+
/// [`nodesep`]: https://graphviz.org/docs/attrs/nodesep/
87+
pub fn with_nodesep(mut self, nodesep: f64) -> Self {
88+
self.nodesep = nodesep;
89+
self
90+
}
91+
92+
/// Sets the desired separation between nodes of different ranks, in inches.
93+
/// See [`ranksep`].
94+
///
95+
/// Defaults to `0.25`. Minimum `0.02`.
96+
///
97+
/// This does not support the `equally` string (yet). I'm not sure if it is
98+
/// used.
99+
///
100+
/// [`ranksep`]: https://graphviz.org/docs/attrs/ranksep/
101+
pub fn with_ranksep(mut self, ranksep: f64) -> Self {
102+
self.ranksep = ranksep;
103+
self
104+
}
105+
58106
/// Sets how to render edge lines. See [`splines`].
59107
///
60108
/// [`splines`]: https://graphviz.org/docs/attrs/splines/
@@ -111,6 +159,29 @@ impl GraphvizAttrs {
111159
self
112160
}
113161

162+
/// Returns the minimum space between two adjacent nodes in the same rank,
163+
/// in inches. Also controls the spacing between multiple edges between
164+
/// the same pair of nodes.
165+
///
166+
/// Defaults to `0.25`. Minimum `0.02`.
167+
///
168+
/// See [`nodesep`].
169+
///
170+
/// [`nodesep`]: https://graphviz.org/docs/attrs/nodesep/
171+
pub fn nodesep(&self) -> f64 {
172+
self.nodesep
173+
}
174+
175+
/// Returns the desired separation between nodes of different ranks, in
176+
/// inches. See [`ranksep`].
177+
///
178+
/// Defaults to `0.25`. Minimum `0.02`.
179+
///
180+
/// [`ranksep`]: https://graphviz.org/docs/attrs/ranksep/
181+
pub fn ranksep(&self) -> f64 {
182+
self.ranksep
183+
}
184+
114185
/// Returns how to render edge lines. See [`splines`].
115186
///
116187
/// [`splines`]: https://graphviz.org/docs/attrs/splines/
@@ -164,6 +235,8 @@ impl GraphvizAttrs {
164235
impl Default for GraphvizAttrs {
165236
fn default() -> Self {
166237
Self {
238+
nodesep: 0.25,
239+
ranksep: 0.25,
167240
splines: Splines::default(),
168241
edge_constraint_default: true,
169242
edge_constraints: EdgeConstraints::default(),

crate/model/src/common/id_newtype.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ macro_rules! id_newtype {
4444
/// compile time checks and returns a `const` value.
4545
///
4646
#[doc = concat!("[`", stringify!($macro_name), "!`]: dot_ix_static_check_macros::profile")]
47-
pub fn new(s: &'static str) -> Result<Self, $ty_err_name> {
47+
pub fn new(s: &'static str) -> Result<Self, $ty_err_name<'static>> {
4848
Self::try_from(s)
4949
}
5050

crate/rt/src/into_graphviz_dot_src/info_graph.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ fn graph_attrs(
234234
GraphDir::Vertical => "TB",
235235
};
236236

237+
let nodesep = graphviz_attrs.nodesep();
238+
let ranksep = graphviz_attrs.ranksep();
237239
let splines = graphviz_attrs.splines();
238240
let splines = match splines {
239241
Splines::Unset => Cow::Borrowed(""),
@@ -250,9 +252,8 @@ fn graph_attrs(
250252
compound = true
251253
graph [
252254
margin = 0.1
253-
penwidth = 0
254-
nodesep = 0.0
255-
ranksep = 0.02
255+
nodesep = {nodesep}
256+
ranksep = {ranksep}
256257
bgcolor = "transparent"
257258
fontname = "helvetica"
258259
packmode = "{pack_mode}"

deny.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ yanked = "warn"
7070
# A list of advisory IDs to ignore. Note that ignored advisories will still
7171
# output a note when they are encountered.
7272
ignore = [
73-
#"RUSTSEC-0000-0000",
73+
# `proc-macro-error` is Unmaintained.
74+
#
75+
# Transitive dependency of `syn_derive`.
76+
# Pending https://github.com/Kyuuhachi/syn_derive/issues/4.
77+
"RUSTSEC-2024-0370",
7478
]
7579

7680
# If this is true, then cargo deny will use the git executable to fetch advisory database.

playground/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ reqwest = { workspace = true, optional = true }
3434
serde = { workspace = true, features = ["derive"] }
3535
tokio = { workspace = true, optional = true }
3636
tower = { workspace = true, optional = true }
37-
tower-http = { version = "0.5", features = ["fs"], optional = true }
37+
tower-http = { version = "0.6", features = ["fs"], optional = true }
3838
tracing = { workspace = true, optional = true }
3939
http = { workspace = true }
4040
serde_yaml = { workspace = true }

rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ use_field_init_shorthand = true
44
format_code_in_doc_comments = true
55
wrap_comments = true
66
edition = "2021"
7-
version = "Two"
7+
style_edition = "2021"

0 commit comments

Comments
 (0)