expand_proto/
expand_proto.rs1use std::error::Error;
2use std::path::PathBuf;
3use webots_proto_ast::Proto;
4use webots_proto_resolver::{ProtoResolver, ResolveOptions};
5
6fn main() -> Result<(), Box<dyn Error>> {
7 let fixtures_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
8 .join("../../fixtures")
9 .join("resolve");
10 let input_path = fixtures_dir.join("ParentUsesChildDefaults.proto");
11 let input = std::fs::read_to_string(&input_path)?;
12
13 let expanded_node = ProtoResolver::new(ResolveOptions::new().with_max_depth(8))
14 .to_root_node(&input, Some(&fixtures_dir))?;
15
16 let expanded_document = Proto::new().with_root_nodes(vec![expanded_node]);
17 println!("{}", expanded_document.to_canonical_string()?);
18
19 Ok(())
20}