sdml_generate/draw/
mod.rs

1/*!
2This module provides the generators for *concept*, *entity-relationship*, and *UML class* diagrams. It also provides a
3common [`OutputFormat`] type that describes the image format.
4
5- `concepts` -- A simple diagram showing only the entities and their relationships.
6- `erd` -- An Entity-Relationship diagram.
7- `uml` -- A detailed UML Class diagram.
8*/
9
10use crate::exec::CommandArg;
11
12// ------------------------------------------------------------------------------------------------
13// Public Types
14// ------------------------------------------------------------------------------------------------
15
16///
17/// The format for image output.
18///
19#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
20pub enum OutputFormat {
21    Source,
22    ImageJpeg,
23    ImagePng,
24    #[default]
25    ImageSvg,
26}
27
28/// Name of the command-line tool for GraphViz generation.
29pub const DOT_PROGRAM: &str = "dot";
30
31/// Name of the command-line tool for PlantUML generation.
32pub const UML_PROGRAM: &str = "plantuml";
33
34// ------------------------------------------------------------------------------------------------
35// Implementations
36// ------------------------------------------------------------------------------------------------
37
38impl From<OutputFormat> for CommandArg {
39    fn from(value: OutputFormat) -> Self {
40        CommandArg::new_option(
41            "-T",
42            match value {
43                OutputFormat::ImageJpeg => "jpg",
44                OutputFormat::ImagePng => "png",
45                OutputFormat::ImageSvg => "svg",
46                _ => unreachable!(),
47            },
48        )
49    }
50}
51
52// ------------------------------------------------------------------------------------------------
53// Modules
54// ------------------------------------------------------------------------------------------------
55
56pub mod concepts;
57
58pub mod erd;
59
60pub mod uml;
61
62pub mod filter;