Tools that parsing Rust code into UML diagram (in dot format currently).

Overview

rudg

Rust UML Diagram Generator

Tools that parsing Rust code into UML diagram (in dot format currently).

License License: MIT

Usage

$ rudg.exe --help
rudg 0.1.0

USAGE:
    rudg.exe [file] [OPTIONS]

ARGS:
    <file>    Rust source code file path

OPTIONS:
    -h, --help            Print help information
    -o, --output <DIR>    Sets a custom output directory
    -V, --version         Print version information

Roadmap (TODO list)

  • comprehensive tests and bug fix
  • support for modelling the whole crate's source code

Contributing

  • All sorts of contributing are welcome. Please feel free to open issue and/or PR.
  • We belive that TDD(Test-Driven Development) approach is helpful not only in development, but also in communication with each other. So adding more tests might be a good way to report a bug or even suggest a new feature.

License

rudg is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

Related Project

dot_graph: A library for generating Graphviz DOT language files.

You might also like...
Sample code of Yew (0.18). Something like a PuyoPuyo.

RusRus Requirements Docker Depend on Yew ver 0.18.0 Usase docker build -t rusrus . # start serve docker run -p 8080:8080 --rm -it -v $(pwd):/app -w /

This code generate coinjoin transaction whici has two inputs and two outputs

How to create coinjoin transaction This code generate coinjoin transaction whici has two inputs and two outputs. First, we create two trasactions. The

This repository contains the sample code for Rainer Stropek's talk at Eurorust 2022.

Building Web APIs with Rust - State of the Union Introduction This repository contains the sample code for Rainer Stropek's talk at Eurorust 2022. The

Code template for a production Web Application using Axum: The AwesomeApp Blueprint for Professional Web Development.

AwesomeApp rust-web-app More info at: https://awesomeapp.dev/rust-web-app/ rust-web-app YouTube episodes: Episode 01 - Rust Web App - Course to Produc

Rust I18n is use Rust codegen for load YAML file storage translations on compile time, and give you a t! macro for simply get translation texts.

Rust I18n Rust I18n is use Rust codegen for load YAML file storage translations on compile time, and give you a t! macro for simply get translation te

lispr is a Rust macro that tries to implement a small subset of LISPs syntax in Rust

lispr lispr is a Rust macro that tries to implement a small subset of LISPs syntax in Rust. It is neither especially beautiful or efficient since it i

Rust/Axum server implementation with PCR(Prisma Client Rust)
Rust/Axum server implementation with PCR(Prisma Client Rust)

Realworld Rust Axum Prisma This project utilizes Rust with the Axum v0.7 framework along with the Prisma Client Rust to build a realworld application.

A Rust web framework

cargonauts - a Rust web framework Documentation cargonauts is a Rust web framework intended for building maintainable, well-factored web apps. This pr

A Rust library to extract useful data from HTML documents, suitable for web scraping.

select.rs A library to extract useful data from HTML documents, suitable for web scraping. NOTE: The following example only works in the upcoming rele

Comments
  • Test failures due to quotes

    Test failures due to quotes

    These look like minor failures to do with quoting of labels.

    > rpm -q graphviz
    graphviz-2.49.3-2.4.x86_64
    
    > cargo test
       Compiling rudg v0.2.0-dev (/home/jayvdb/rust/rudg)
        Finished test [unoptimized + debuginfo] target(s) in 0.74s
         Running unittests src/lib.rs (target/debug/deps/rudg-a1cdaa90caa6ae09)
    
    running 17 tests
    test graph_exporter::to_dot::tests::test_uml_class_composition ... FAILED
    test file_reader::tests::test_visit_dirs ... ok
    test graph_exporter::to_dot::tests::test_mods ... FAILED
    test graph_exporter::to_dot::tests::test_uml_class_aggregation ... FAILED
    test graph_exporter::to_dot::tests::test_uml_class_dependency ... FAILED
    test graph_exporter::to_dot::tests::test_uml_class_association ... FAILED
    test graph_exporter::to_dot::tests::test_uml_classes_fns_to_dot ... FAILED
    test graph_exporter::to_dot::tests::test_uml_fn_relations ... FAILED
    test graph_exporter::to_dot::tests::test_uml_class_realization ... FAILED
    test parser::ast_parser::tests::test_parse_fn ... ok
    test parser::ast_parser::tests::test_parse_struct ... ok
    test parser::ast_parser::tests::test_aggregation ... ok
    test parser::ast_parser::tests::test_composition ... ok
    test parser::ast_parser::tests::test_fn_dependency ... ok
    test parser::ast_parser::tests::test_class_dependency ... ok
    test parser::ast_parser::tests::test_association ... ok
    test parser::ast_parser::tests::test_realization ... ok
    
    failures:
    
    ---- graph_exporter::to_dot::tests::test_uml_class_composition stdout ----
    thread 'graph_exporter::to_dot::tests::test_uml_class_composition' panicked at 'assertion failed: `(left == right)`
      left: `"digraph ast {\n    \"Mock\"[label=\"{Mock|c: C}\"][shape=\"record\"];\n    \"C\"[label=\"C\"][shape=\"record\"];\n    \"Mock\" -> \"C\"[label=\"\"][arrowhead=\"diamond\"];\n}\n"`,
     right: `"digraph ast {\n    Mock[label=\"{Mock|c: C}\"][shape=\"record\"];\n    C[label=\"C\"][shape=\"record\"];\n    Mock -> C[label=\"\"][arrowhead=\"diamond\"];\n}\n"`', src/graph_exporter/to_dot.rs:282:9
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    
    ---- graph_exporter::to_dot::tests::test_mods stdout ----
    thread 'graph_exporter::to_dot::tests::test_mods' panicked at 'The name of the subgraph should start with "cluster_"', /home/jayvdb/.cargo/registry/src/github.com-1ecc6299db9ec823/dot_graph-0.2.3/src/subgraph.rs:144:9
    
    ---- graph_exporter::to_dot::tests::test_uml_class_aggregation stdout ----
    thread 'graph_exporter::to_dot::tests::test_uml_class_aggregation' panicked at 'assertion failed: `(left == right)`
      left: `"digraph ast {\n    \"Mock\"[label=\"{Mock|b: *mut B}\"][shape=\"record\"];\n    \"B\"[label=\"B\"][shape=\"record\"];\n    \"Mock\" -> \"B\"[label=\"\"][arrowtail=\"odiamond\"];\n}\n"`,
     right: `"digraph ast {\n    Mock[label=\"{Mock|b: *mut B}\"][shape=\"record\"];\n    B[label=\"B\"][shape=\"record\"];\n    Mock -> B[label=\"\"][arrowtail=\"odiamond\"];\n}\n"`', src/graph_exporter/to_dot.rs:264:9
    
    ---- graph_exporter::to_dot::tests::test_uml_class_dependency stdout ----
    thread 'graph_exporter::to_dot::tests::test_uml_class_dependency' panicked at 'assertion failed: `(left == right)`
      left: `"digraph ast {\n    \"Mock\"[label=\"{Mock|mock_fn()}\"][shape=\"record\"];\n    \"f1\"[label=\"f1\"];\n    \"f2\"[label=\"f2\"];\n    \"f1\" -> \"Mock\"[label=\"\"][style=\"dashed\"][arrowhead=\"vee\"];\n    \"f2\" -> \"Mock\"[label=\"\"][style=\"dashed\"][arrowhead=\"vee\"];\n}\n"`,
     right: `"digraph ast {\n    Mock[label=\"{Mock|mock_fn()}\"][shape=\"record\"];\n    f1[label=\"f1\"];\n    f2[label=\"f2\"];\n    f1 -> Mock[label=\"\"][style=\"dashed\"][arrowhead=\"vee\"];\n    f2 -> Mock[label=\"\"][style=\"dashed\"][arrowhead=\"vee\"];\n}\n"`', src/graph_exporter/to_dot.rs:246:9
    
    ---- graph_exporter::to_dot::tests::test_uml_class_association stdout ----
    thread 'graph_exporter::to_dot::tests::test_uml_class_association' panicked at 'assertion failed: `(left == right)`
      left: `"digraph ast {\n    \"Mock\"[label=\"{Mock|e2() -> E2}\"][shape=\"record\"];\n    \"E1\"[label=\"{E1|b() -> Mock}\"][shape=\"record\"];\n    \"E2\"[label=\"{E2|a() -> Mock}\"][shape=\"record\"];\n    \"E1\" -> \"Mock\"[label=\"\"][arrowhead=\"vee\"];\n    \"E2\" -> \"Mock\"[label=\"\"][arrowhead=\"none\"];\n}\n"`,
     right: `"digraph ast {\n    Mock[label=\"{Mock|e2() -> E2}\"][shape=\"record\"];\n    E1[label=\"{E1|b() -> Mock}\"][shape=\"record\"];\n    E2[label=\"{E2|a() -> Mock}\"][shape=\"record\"];\n    E1 -> Mock[label=\"\"][arrowhead=\"vee\"];\n    E2 -> Mock[label=\"\"][arrowhead=\"none\"];\n}\n"`', src/graph_exporter/to_dot.rs:322:9
    
    ---- graph_exporter::to_dot::tests::test_uml_classes_fns_to_dot stdout ----
    thread 'graph_exporter::to_dot::tests::test_uml_classes_fns_to_dot' panicked at 'assertion failed: `(left == right)`
      left: `"digraph ast {\n    \"Main\"[label=\"{Main|a: String\\lb: String|main() -> ()\\lmain1()}\"][shape=\"record\"];\n    \"MainTrait\"[label=\"{Interface\\lMainTrait|main() -> ()}\"][shape=\"record\"];\n    \"test\"[label=\"test\"];\n}\n"`,
     right: `"digraph ast {\n    Main[label=\"{Main|a: String\\lb: String|main() -> ()\\lmain1()}\"][shape=\"record\"];\n    MainTrait[label=\"{Interface\\lMainTrait|main() -> ()}\"][shape=\"record\"];\n    test[label=\"test\"];\n}\n"`', src/graph_exporter/to_dot.rs:207:9
    
    ---- graph_exporter::to_dot::tests::test_uml_fn_relations stdout ----
    thread 'graph_exporter::to_dot::tests::test_uml_fn_relations' panicked at 'assertion failed: `(left == right)`
      left: `"digraph ast {\n    \"main\"[label=\"main\"];\n    \"test\"[label=\"test\"];\n    \"main\" -> \"test\"[label=\"\"][style=\"dashed\"][arrowhead=\"vee\"];\n}\n"`,
     right: `"digraph ast {\n    main[label=\"main\"];\n    test[label=\"test\"];\n    main -> test[label=\"\"][style=\"dashed\"][arrowhead=\"vee\"];\n}\n"`', src/graph_exporter/to_dot.rs:224:9
    
    ---- graph_exporter::to_dot::tests::test_uml_class_realization stdout ----
    thread 'graph_exporter::to_dot::tests::test_uml_class_realization' panicked at 'assertion failed: `(left == right)`
      left: `"digraph ast {\n    \"Mock\"[label=\"Mock\"][shape=\"record\"];\n    \"D\"[label=\"{Interface\\lD|a(&self) -> Option<T>}\"][shape=\"record\"];\n    \"Mock\" -> \"D\"[label=\"\"][style=\"dashed\"][arrowhead=\"onormal\"];\n}\n"`,
     right: `"digraph ast {\n    Mock[label=\"Mock\"][shape=\"record\"];\n    D[label=\"{Interface\\lD|a(&self) -> Option<T>}\"][shape=\"record\"];\n    Mock -> D[label=\"\"][style=\"dashed\"][arrowhead=\"onormal\"];\n}\n"`', src/graph_exporter/to_dot.rs:300:9
    
    
    failures:
        graph_exporter::to_dot::tests::test_mods
        graph_exporter::to_dot::tests::test_uml_class_aggregation
        graph_exporter::to_dot::tests::test_uml_class_association
        graph_exporter::to_dot::tests::test_uml_class_composition
        graph_exporter::to_dot::tests::test_uml_class_dependency
        graph_exporter::to_dot::tests::test_uml_class_realization
        graph_exporter::to_dot::tests::test_uml_classes_fns_to_dot
        graph_exporter::to_dot::tests::test_uml_fn_relations
    
    test result: FAILED. 9 passed; 8 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
    
    error: test failed, to rerun pass '--lib'
    
    opened by jayvdb 1
  • Fix tests quotes

    Fix tests quotes

    The quote problem #16 is from the update of dot_graph, from v0.2.1 to v0.2.3. So I changed all nodes' names in the tests. Plus, support for parsing multi-file crate is not ready yet, so I remove the test accordingly.

    opened by SelamaAshalanore 0
  • Cargo extension

    Cargo extension

    I was wondering would it be possible to package this as a cargo extension so that it can generate the class diagram for an entire project (in the spirit of cargo-modules)?

    opened by giannissc 0
  • Project support

    Project support

    Currently the rudg tool only supports generating a diagram for a single file.

    The README does mention support is coming in next release v0.2.0 but I wanted to open an issue so I can track when this work is complete:

    Currently, this tool could only parse single .rs file, and support for parsing whole crate will be released on v0.2.0, which is under development.

    opened by Integralist 4
Owner
Zhai Yao
Zhai Yao
Scraper - HTML parsing and querying with CSS selectors

scraper HTML parsing and querying with CSS selectors. scraper is on Crates.io and GitHub. Scraper provides an interface to Servo's html5ever and selec

june 1.2k Dec 30, 2022
Rust Macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev.

Rust Embed Rust Custom Derive Macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev. Y

Peter 1k Jan 5, 2023
The [cain!] macro is a macro that rewrites sequential Rust branch statements into nested branches

Note! This crate is experimental and under development. It may include bugs that alter the behavior of your code in unexpected ways. You should review

Fredrik Østrem 2 Jan 19, 2022
Turn GitHub into an RSS reader

NotCraft::NotFeed An RSS reader running entirely from your GitHub repo. Free hosting on GitHub Pages. No ads. No third party tracking. No need for bac

NotCraft 22 Nov 30, 2022
ditch poetry for pip. converts pyproject.toml into requirements.txt.

Say No To Poetry Did you grow up using just pip or conda? Are you being forced to use poetry everywhere at work? They try to convince you poetry just

Jaivarsan 7 Nov 6, 2022
Merge multiple Juniper object definitions into a single object type.

juniper-compose Merge multiple Juniper object definitions into a single object type. crates.io | docs | github Motivation You are building a GraphQL s

Kit Isaev 3 Aug 5, 2022
Turn any web page into a desktop app (but, lightweight <1MB)

Intro Turn any web page into a desktop app (but, lightweight <1MB) The bundle will be less than 2MB Demo: https://i.imgur.com/BLr03oF.mp4 Install carg

null 9 Dec 27, 2022
Deserialize (potentially nested) environment variables into your custom structs

envious allows you to deserialize your serde enabled structs from environment variables. See it in action: use serde::{Deserialize, Serialize}; #[der

Marcel Müller 46 Feb 19, 2023
Rust Axum Full Course code.

Rust Axum Full Course source code. YouTube Full Course: https://youtube.com/watch?v=XZtlD_m59sM&list=PL7r-PXl6ZPcCIOFaL7nVHXZvBmHNhrh_Q MIT OR Apache,

null 27 Apr 19, 2023
Prettier - Prettier is an opinionated code formatter.

Opinionated Code Formatter JavaScript · TypeScript · Flow · JSX · JSON CSS · SCSS · Less HTML · Vue · Angular GraphQL · Markdown · YAML Your favorite

Prettier 44.6k Jan 7, 2023