Skip to content

Port website dev docs generated content scripts from JS to Rust to avoid intermediate formats#3909

Open
Keavon wants to merge 4 commits intomasterfrom
simplify-dev-docs-viz-gen
Open

Port website dev docs generated content scripts from JS to Rust to avoid intermediate formats#3909
Keavon wants to merge 4 commits intomasterfrom
simplify-dev-docs-viz-gen

Conversation

@Keavon
Copy link
Member

@Keavon Keavon commented Mar 17, 2026

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the website's documentation generation process by migrating key build scripts from JavaScript to Rust. This change aims to improve efficiency and simplify the build pipeline by allowing the Rust tools to directly produce the final output formats (SVG, HTML, and plain text), thereby removing the need for intermediate files and reducing the project's reliance on Node.js for these specific tasks.

Highlights

  • Migration to Rust: The website's documentation generation scripts, previously implemented in JavaScript, have been ported to Rust.
  • Streamlined SVG Generation: The crate-hierarchy-viz tool now directly converts DOT graphs to SVG using a Node.js subprocess, eliminating an intermediate DOT file.
  • Dual Output for Message Tree: The editor-message-tree tool now generates both plain text and HTML representations of the message hierarchy directly.
  • Removed JavaScript Build Scripts: The old TypeScript scripts responsible for these generation tasks have been removed, along with their Node.js dependencies.
Changelog
  • tools/crate-hierarchy-viz/src/main.rs
    • Added std::io::Write and std::process::Command imports for external process execution.
    • Modified the main function to accept an output directory and produce an SVG file directly.
    • Introduced a new dot_to_svg function that leverages Node.js and @viz-js/viz to convert DOT graph strings to SVG.
    • Updated error handling and path construction for output files.
  • tools/editor-message-tree/src/main.rs
    • Modified the main function to accept an output directory.
    • Implemented new functions (write_tree_txt, write_tree_txt_node) to generate a plain text hierarchical representation of messages.
    • Implemented new functions (write_tree_html, write_tree_html_children, write_tree_html_node, write_field_html, write_handler_or_data_html) to generate an HTML representation of the message tree, including GitHub links and naming convention warnings.
    • Updated file creation to output both .txt and .html files.
    • Replaced the previous print_tree_node function with the new write_tree_txt_node.
  • website/.build-scripts/generate-crate-hierarchy.ts
    • Removed the TypeScript script previously responsible for converting DOT to SVG.
  • website/.build-scripts/generate-editor-structure.ts
    • Removed the TypeScript script previously responsible for generating the editor structure HTML.
  • website/content/volunteer/guide/codebase-overview/editor-structure.md
    • Updated the documentation to include a link to the newly generated plain text hierarchical message system tree.
  • website/package-lock.json
    • Removed the @viz-js/viz dependency entry.
  • website/package.json
    • Removed the generate-editor-structure and generate-crate-hierarchy npm scripts.
    • Removed the @viz-js/viz development dependency.
  • website/templates/macros/replacements.html
    • Updated the hierarchical_message_system_tree and crate_hierarchy macros to reflect the new output file names and simplified local testing instructions, removing references to the old Node.js scripts.
Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/build.yml
    • .github/workflows/website.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request is a great improvement, porting two JavaScript build scripts to Rust. This change simplifies the build process by removing intermediate file formats and generating the final SVG and HTML files directly. The new Rust code is well-structured, but I've identified a few areas for improvement regarding panic safety, code duplication, and idiomatic Rust for string and I/O operations.

}
}

fn write_tree_html(tree: &DebugMessageTree, out: &mut String) {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The HTML generation functions (write_tree_html, write_tree_html_children, etc.) build a String using multiple push_str calls. A more idiomatic and potentially more efficient approach is to use a type that implements std::fmt::Write along with the write!/writeln! macros. This would also make the functions more generic and robust. You could change their signatures to return a std::fmt::Result and write to a &mut impl std::fmt::Write.

}
}

const FRONTEND_MESSAGE_STR: &str = "FrontendMessage";
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The constant FRONTEND_MESSAGE_STR is defined locally here, but it's also defined in write_tree_txt_node. To avoid this duplication and improve maintainability, consider defining it once at the module level.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 10 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="tools/crate-hierarchy-viz/src/main.rs">

<violation number="1" location="tools/crate-hierarchy-viz/src/main.rs:195">
P2: Check for the actual `@viz-js/viz` package directory here, not just the `@viz-js` scope folder, or this can skip installation and fail at runtime.</violation>
</file>

<file name="tools/editor-message-tree/src/main.rs">

<violation number="1" location="tools/editor-message-tree/src/main.rs:32">
P2: Propagate `write_all` errors instead of discarding them, or this generator can succeed after producing a partial `.txt` file.</violation>
</file>

<file name=".github/workflows/website.yml">

<violation number="1" location=".github/workflows/website.yml:68">
P2: This generator now writes the downloadable `.txt` file under `website/static`, but the workflow only caches/restores `website/generated`. On cache hits the step is skipped, so the linked `hierarchical-message-system-tree.txt` will be missing from the built site.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@Keavon Keavon force-pushed the simplify-dev-docs-viz-gen branch from dfdc512 to 179937e Compare March 17, 2026 11:59
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.

1 participant