Skip to content

Move DOT visualization to the Ruby CLI - #966

Open
Morriar wants to merge 4 commits into
mainfrom
port-dot-to-ruby
Open

Move DOT visualization to the Ruby CLI#966
Morriar wants to merge 4 commits into
mainfrom
port-dot-to-ruby

Conversation

@Morriar

@Morriar Morriar commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

What

Move graph visualization from the internal Rust CLI to the public Ruby CLI.

  • Expose Rubydex::Graph#to_dot(show_builtins: false) through the Rust/C/Ruby boundary.
  • Add rdx dot [PATH].
  • Add rdx dot --show-builtins [PATH].
  • Remove --dot and --show-builtins from the Rust CLI.
  • Keep the existing Rust DotBuilder as the underlying renderer.
  • Add Ruby API and CLI integration coverage.
  • Extract shared helpers for invoking rdx from integration tests.
  • Document the Ruby API and CLI usage.

Why

We want to remove the Rust CLI and keep the Ruby rdx executable as Rubydex's only CLI entry point. Before removing the Rust CLI, its user-facing features need to be available through rdx.

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:

bundle exec rdx dot > graph.dot

Render another workspace:

bundle exec rdx dot path/to/workspace > graph.dot

Include Rubydex's built-in declarations:

bundle exec rdx dot --show-builtins path/to/workspace > graph.dot

The same output is available through the Ruby API:

graph.to_dot
graph.to_dot(show_builtins: true)

Indexing progress is written to stderr so stdout contains only DOT output.

Testing

  • bundle exec rake test
  • bundle exec rake lint
  • cargo fmt --check
  • Ruby DOT API tests
  • rdx dot integration tests
  • MCP integration tests after extracting the shared executable helper

@Morriar
Morriar requested a review from a team as a code owner July 30, 2026 16:20
Comment thread rust/rubydex/src/main.rs
Comment thread exe/rdx
abort_with_usage(e.message)
end

workspace_path = ARGV.shift || Dir.pwd

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be streamlined on latest main now, since we have the infrastructure to test rdx invocations through calls to the CLI class.

Comment thread README.md
Comment on lines +156 to +157
# Index another workspace and include Rubydex's built-in declarations
bundle exec rdx dot --show-builtins path/to/workspace > graph.dot

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're really going to allow the path argument, we should be explicit that it cannot include dependencies.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants