Move DOT visualization to the Ruby CLI - #966
Conversation
| abort_with_usage(e.message) | ||
| end | ||
|
|
||
| workspace_path = ARGV.shift || Dir.pwd |
There was a problem hiding this comment.
Note: passing an explicit argument here won't include that workspace's dependencies without setting up the Bundle based on its Gemfile, so this has difference behaviour than pwd.
| require "open3" | ||
| require "rbconfig" | ||
|
|
||
| module Test |
There was a problem hiding this comment.
Testing behaviour through executables feels weird. I think this is a result of us not having a proper CLI object that can be unit tested yet, which forces us to reach into actually shelling out.
Since we already need to refactor the CLI for the linter, can we avoid adding this? We can add the dot scenarios as unit tests for the CLI as soon as we add it.
There was a problem hiding this comment.
This should be streamlined on latest main now, since we have the infrastructure to test rdx invocations through calls to the CLI class.
| # Index another workspace and include Rubydex's built-in declarations | ||
| bundle exec rdx dot --show-builtins path/to/workspace > graph.dot |
There was a problem hiding this comment.
If we're really going to allow the path argument, we should be explicit that it cannot include dependencies.
There was a problem hiding this comment.
I also find it interesting that we are indexing a workspace using the gemfile of some other workspace. Do we really need the workspace option?
What
Move graph visualization from the internal Rust CLI to the public Ruby CLI.
Rubydex::Graph#to_dot(show_builtins: false)through the Rust/C/Ruby boundary.rdx dot [PATH].rdx dot --show-builtins [PATH].--dotand--show-builtinsfrom the Rust CLI.DotBuilderas the underlying renderer.rdxfrom integration tests.Why
We want to remove the Rust CLI and keep the Ruby
rdxexecutable as Rubydex's only CLI entry point. Before removing the Rust CLI, its user-facing features need to be available throughrdx.DOT visualization was only exposed by the Rust CLI. This PR moves that feature to the Ruby API and CLI while preserving the existing Rust renderer and output format.
Usage
Render the current workspace:
Render another workspace:
Include Rubydex's built-in declarations:
The same output is available through the Ruby API:
Indexing progress is written to stderr so stdout contains only DOT output.
Testing
bundle exec rake testbundle exec rake lintcargo fmt --checkrdx dotintegration tests