Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support nodesep and ranksep #36

Merged
merged 10 commits into from
Sep 27, 2024
Merged
8 changes: 8 additions & 0 deletions .cargo/audit.toml
Original file line number Diff line number Diff line change
@@ -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",
]
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,36 +62,36 @@ 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"
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]
Expand Down
73 changes: 73 additions & 0 deletions crate/model/src/common/graphviz_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,26 @@
#[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/
Expand Down Expand Up @@ -55,6 +75,34 @@
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
}

Check warning on line 90 in crate/model/src/common/graphviz_attrs.rs

View check run for this annotation

Codecov / codecov/patch

crate/model/src/common/graphviz_attrs.rs#L87-L90

Added lines #L87 - L90 were not covered by tests

/// 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
}

Check warning on line 104 in crate/model/src/common/graphviz_attrs.rs

View check run for this annotation

Codecov / codecov/patch

crate/model/src/common/graphviz_attrs.rs#L101-L104

Added lines #L101 - L104 were not covered by tests

/// Sets how to render edge lines. See [`splines`].
///
/// [`splines`]: https://graphviz.org/docs/attrs/splines/
Expand Down Expand Up @@ -111,6 +159,29 @@
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
}

Check warning on line 173 in crate/model/src/common/graphviz_attrs.rs

View check run for this annotation

Codecov / codecov/patch

crate/model/src/common/graphviz_attrs.rs#L171-L173

Added lines #L171 - L173 were not covered by tests

/// 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
}

Check warning on line 183 in crate/model/src/common/graphviz_attrs.rs

View check run for this annotation

Codecov / codecov/patch

crate/model/src/common/graphviz_attrs.rs#L181-L183

Added lines #L181 - L183 were not covered by tests

/// Returns how to render edge lines. See [`splines`].
///
/// [`splines`]: https://graphviz.org/docs/attrs/splines/
Expand Down Expand Up @@ -164,6 +235,8 @@
impl Default for GraphvizAttrs {
fn default() -> Self {
Self {
nodesep: 0.25,
ranksep: 0.25,

Check warning on line 239 in crate/model/src/common/graphviz_attrs.rs

View check run for this annotation

Codecov / codecov/patch

crate/model/src/common/graphviz_attrs.rs#L238-L239

Added lines #L238 - L239 were not covered by tests
splines: Splines::default(),
edge_constraint_default: true,
edge_constraints: EdgeConstraints::default(),
Expand Down
2 changes: 1 addition & 1 deletion crate/model/src/common/id_newtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
/// 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<Self, $ty_err_name> {
pub fn new(s: &'static str) -> Result<Self, $ty_err_name<'static>> {

Check warning on line 47 in crate/model/src/common/id_newtype.rs

View check run for this annotation

Codecov / codecov/patch

crate/model/src/common/id_newtype.rs#L47

Added line #L47 was not covered by tests
Self::try_from(s)
}

Expand Down
7 changes: 4 additions & 3 deletions crate/rt/src/into_graphviz_dot_src/info_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@
GraphDir::Vertical => "TB",
};

let nodesep = graphviz_attrs.nodesep();
let ranksep = graphviz_attrs.ranksep();

Check warning on line 238 in crate/rt/src/into_graphviz_dot_src/info_graph.rs

View check run for this annotation

Codecov / codecov/patch

crate/rt/src/into_graphviz_dot_src/info_graph.rs#L237-L238

Added lines #L237 - L238 were not covered by tests
let splines = graphviz_attrs.splines();
let splines = match splines {
Splines::Unset => Cow::Borrowed(""),
Expand All @@ -250,9 +252,8 @@
compound = true
graph [
margin = 0.1
penwidth = 0
nodesep = 0.0
ranksep = 0.02
nodesep = {nodesep}
ranksep = {ranksep}

Check warning on line 256 in crate/rt/src/into_graphviz_dot_src/info_graph.rs

View check run for this annotation

Codecov / codecov/patch

crate/rt/src/into_graphviz_dot_src/info_graph.rs#L255-L256

Added lines #L255 - L256 were not covered by tests
bgcolor = "transparent"
fontname = "helvetica"
packmode = "{pack_mode}"
Expand Down
6 changes: 5 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion playground/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"