3 releases
0.1.2 | Jul 10, 2024 |
---|---|
0.1.1 | Jul 10, 2024 |
0.1.0 | Jul 10, 2024 |
#1584 in Parser implementations
13KB
100 lines
dependency-tree-svg
This crate generates self-contained SVG files based on given JSON file with dependencies.
Dependencies must have the following format:
{
"root": [
"packageName1"
],
"packageName1": [
"dependency1",
"dependency2"
],
"dependency1": [
"sub-dependency2"
]
}
Then if you run
$ cargo run --bin run --features=lexopt -- --datafile data.json --write-to output.svg
You'll get an SVG file in output.svg
which looks like this:
This tree is interactive, by clicking on the packageName1
you'll get
This crate is a library, here's the interface:
fn generate_svg() {
let file = std::fs::File::open("dependencies.json").unwrap();
let reader = std::io::BufReader::new(file);
let input: dependency_tree_svg::Input = serde_json::from_reader(reader)?;
let box_size = 80;
let svg = dependency_tree_svg::compile_svg(input, box_size);
std::fs::write("output.svg", svg).unwrap();
}
Frontend part
npm install
npm run build:dev
to startesbuild
in watch mode- open
assets/main.svg
in the browser - modify code in
assets/
directory - run tests with
npm run test:node
Releases
To release:
npm run build:release
(to get minified JS)cargo publish --allow-dirty
(because generated JS files are not under git)
Dependencies
~0.7–1.6MB
~34K SLoC