Add the crate dependency graph visualization to the contributor guide (#3907)

* Add the crate dependency graph visualization to the contributor guide

* Code review fixes

* And more
This commit is contained in:
Keavon Chambers
2026-03-17 01:35:56 -07:00
committed by GitHub
parent df8001fca8
commit d9214c7292
21 changed files with 497 additions and 349 deletions

View File

@@ -7,7 +7,13 @@ use crate::utility::*;
use convert_case::{Case, Casing};
use std::collections::HashMap;
fn main() {
fn main() -> Result<(), Box<dyn std::error::Error>> {
let output_path = std::env::args_os()
.nth(1)
.ok_or("Usage: node-docs <output-directory>")?
.into_string()
.map_err(|_| "Output path is not valid UTF-8")?;
// TODO: Also obtain document nodes, not only proto nodes
let nodes = graphene_std::registry::NODE_METADATA.lock().unwrap();
@@ -22,7 +28,7 @@ fn main() {
categories.sort();
// Create _index.md for the node catalog page
page_catalog::write_catalog_index_page(&categories);
page_catalog::write_catalog_index_page(&output_path, &categories);
// Create node category pages and individual node pages
for (index, category) in categories.iter().map(|c| if !OMIT_HIDDEN && c.is_empty() { "Hidden" } else { c }).filter(|c| !c.is_empty()).enumerate() {
@@ -32,7 +38,7 @@ fn main() {
// Create _index.md file for category
let category_path_part = sanitize_path(&category.to_case(Case::Kebab));
let category_path = format!("{NODE_CATALOG_PATH}/{category_path_part}");
let category_path = format!("{output_path}/{category_path_part}");
page_category::write_category_index_page(index, category, &nodes, &category_path);
// Create individual node pages
@@ -40,4 +46,6 @@ fn main() {
page_node::write_node_page(index, id, metadata, &category_path);
}
}
Ok(())
}

View File

@@ -3,12 +3,12 @@ use convert_case::{Case, Casing};
use indoc::formatdoc;
use std::io::Write;
pub fn write_catalog_index_page(categories: &[String]) {
if std::path::Path::new(NODE_CATALOG_PATH).exists() {
std::fs::remove_dir_all(NODE_CATALOG_PATH).expect("Failed to remove existing node catalog directory");
pub fn write_catalog_index_page(output_path: &str, categories: &[String]) {
if std::path::Path::new(output_path).exists() {
std::fs::remove_dir_all(output_path).expect("Failed to remove existing node catalog directory");
}
std::fs::create_dir_all(NODE_CATALOG_PATH).expect("Failed to create node catalog directory");
let page_path = format!("{NODE_CATALOG_PATH}/_index.md");
std::fs::create_dir_all(output_path).expect("Failed to create node catalog directory");
let page_path = format!("{output_path}/_index.md");
let mut page = std::fs::File::create(&page_path).expect("Failed to create index file");
write_frontmatter(&mut page);

View File

@@ -1,7 +1,6 @@
use graph_craft::proto::NodeMetadata;
use indoc::indoc;
pub const NODE_CATALOG_PATH: &str = "../../website/content/learn/node-catalog";
pub const OMIT_HIDDEN: bool = true;
pub fn category_description(category: &str) -> &str {