mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
Add the auto-generated node catalog to the website's user manual (#3662)
* Generate the MVP node catalog in the manual (with some placeholders) * Implement nearly the rest of everything * Move to the tools directory and make it generate nicer default values * Add category descriptions * Organize file structure and improve type naming * Improve book table of contents code * Add collapsing chapter navigation to the book template * Add to build workflow * Clean up site structure
This commit is contained in:
43
tools/node-docs/src/main.rs
Normal file
43
tools/node-docs/src/main.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
mod page_catalog;
|
||||
mod page_category;
|
||||
mod page_node;
|
||||
mod utility;
|
||||
|
||||
use crate::utility::*;
|
||||
use convert_case::{Case, Casing};
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn main() {
|
||||
// TODO: Also obtain document nodes, not only proto nodes
|
||||
let nodes = graphene_std::registry::NODE_METADATA.lock().unwrap();
|
||||
|
||||
// Group nodes by category
|
||||
let mut nodes_by_category: HashMap<_, Vec<_>> = HashMap::new();
|
||||
for (id, metadata) in nodes.iter() {
|
||||
nodes_by_category.entry(metadata.category.to_string()).or_default().push((id, metadata));
|
||||
}
|
||||
|
||||
// Sort the categories
|
||||
let mut categories = nodes_by_category.keys().cloned().collect::<Vec<_>>();
|
||||
categories.sort();
|
||||
|
||||
// Create _index.md for the node catalog page
|
||||
page_catalog::write_catalog_index_page(&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() {
|
||||
// Get nodes in this category
|
||||
let mut nodes = nodes_by_category.remove(if !OMIT_HIDDEN && category == "Hidden" { "" } else { category }).unwrap();
|
||||
nodes.sort_by_key(|(_, metadata)| metadata.display_name.to_string());
|
||||
|
||||
// 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}");
|
||||
page_category::write_category_index_page(index, category, &nodes, &category_path);
|
||||
|
||||
// Create individual node pages
|
||||
for (index, (id, metadata)) in nodes.into_iter().enumerate() {
|
||||
page_node::write_node_page(index, id, metadata, &category_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user