Rust SVG diagram generation library with a dioxus web frontend.
- The main
dispositioncrate is a wrapper around sub-crates. - Subcrates (e.g.
disposition_input_model) are placed incrate/input_model. - The
disposition_playgroundcrate is inapp/playground, a dioxus 0.7 application.
- Variable names should usually be the snake case version of their type, e.g. for the
NodeId, usenode_id. - When working with multiple variables of the same type, favour a common prefix so that they are grouped when sorted by name, e.g.
node_id_from,node_id_to. - When creating functions, favour naming them in
noun_verborder, so they are discoverable when searching by name, and grouped together when sorted. e.g.thing_rename,thing_delete. - When creating functions, favour adding them within a type's
implblock instead of a non-scoped function, This helps group related functions together. e.g.impl ThingBuilder { fn node_coordinates(thing: &Thing) -> Point<f32, f32> { .. } }. - When extracting functions to keep function bodies small, if it is in the same type, the calling function name should be a prefix of the called function name, so that it is easy to identify functions that are easy to extract. If the extracted function is used by multiple calling functions, often that indicates it should be extracted to a separate type.
- Favour using strong types, e.g.
NodeIdwhen handling Node IDs, butIdwhen handling different kinds of IDs (e.g.NodeId,EdgeId, etc.), instead of usingString/&str, so that it is clear what concept the variable should represent, and the constraints built into those types are guaranteed. - This means do NOT map a type into a
String/&strunless necessary to compile. - If you must use "stringly typed" / standard data types (e.g. primitive types,
String,Map,Vec,Set, etc.), then instead of using tuples, create a new type with field names that indicate what information those types hold. e.g. instead of(String, Vec<String>), usestruct NodeIdToCssClasses { node_id: String, css_classes: Vec<String>, } - Each type usually is defined in its own snake_case module, e.g.
NodeIdwould be innode_id.rs. - "Data model" types are usually separate from "logic" types -- so data models can be published without publishing logic. Sometimes logic modules contain supporting data types to pass parameters.
- Try and keep functions under 200 lines by extracting logic / components with meaningful names.
- Avoid non-ascii characters, e.g. "—". Use "--" for elaboration or "
param: description" in parameter documentation. - Section comments should be written as
// === Section Name === //instead of a 3 line comment. - Documentation should include example valid values.
- Unless a type / component is small, it should be placed in its own module -- often a submodule of the current module.
- A module and its submodules would be
foo.rsandfoo/bar.rs, notfoo/mod.rsandfoo/bar.rs.
- When editing the
disposition_playgroundcrate, see <@agent/dioxus.md> if you need context on working with dioxus0.7. - See
<@doc/src/diagram_generation.md>for a high level overview of the diagram generation process. - See
<@doc/src/edge_descriptions.md>for how edge labels are computed from theInputDiagramthrough to theSvgElements. - See
<@doc/src/edge_paths.md>for context about how edge paths are calculated, including node rank concepts and offset/protrusion routing. - See
<@doc/src/node_nesting_info.md>for howNodeNestingInfoandNodeNestingInfosare built -- coversNodeNestingInfosBuilder, theancestor_chain/nesting_pathfields, and how they are used by rank computation and edge spacer insertion. - See
<@doc/src/node_ranks.md>for howNodeRankandNodeRanksNestedare computed per hierarchy level -- coversNodeRanksCalculator, LCA edge lifting, SCC-based cycle handling, and the full worked example. - See
<@doc/src/taffy_node_hierarchy.md>for how thetaffylayout node tree is structured -- covers inbuilt containers, rank containers, leaf and container diagram nodes (rect and circle shapes), taffy node styles, andTaffyNodeCtxvariants. - See
<@doc/src/edge_spacers.md>for how edge spacer taffy nodes are inserted to help route edges around diagram nodes -- covers same-level cross-rank spacers and cross-container spacers, including theEdgeSpacerBuildDeciderdecision logic and insertion-index accounting. - See
<@doc/src/edge_description_containers_plan.md>for the step-by-step plan to render edge descriptions as container nodes interleaved between rank containers. - See
<@doc/src/md_node_content_plan.md>for the step-by-step plan to render node and edge description text as syntax-highlighted markdown with inline images. - See
<@doc/src/process_step_graph.md>for the git-graph layout of process steps -- coversProcessStepGraphCalculatorlane packing, the lane/text-column taffy grid, and theProcessStepGraphEdgesBuilderconnector router.
To diagnose / check the values generated at each stage of the diagram generation
pipeline, run the disposition_cli and output the desired intermediate data to
stdout:
cargo run -q -p disposition_cli -- --structure-only --data $intermediate_data --stdout $input_diagram_yaml_file 2>&1$intermediate_datais one ofir-diagram,taffy-tree,edge-routing,svg-elements, orsvg. The pipeline only computes up to the requested stage.--structure-onlyomits styles / colors so the structural values are easier to read; drop it to see styled values.--stdoutwrites the selected data straight to stdout instead of files, and2>&1merges any mapping issues (written to stderr) into the output.$input_diagram_yaml_fileis the input diagram, e.g.workspace_tests/src/input_diagram/0018_images_animated.yaml.
Omit --data / --stdout and pass an output directory to instead write all
stages (ir_diagram.yaml, taffy_tree.txt, edge_routing.yaml, svg_elements.yaml, diagram.svg)
to files.
Tests for all crates are placed inside the workspace_tests crate, and are run using the command:
cargo nextest run --workspace --all-features --no-tests warndocumentation is checked using the commands:
cargo test --doc --workspace --all-features
cargo doc --workspace --all-features --no-deps