/// Prints our top-level schema "recursively" (ie, prints child nodes)
Prints our top-level schema "recursively"
Prints our top - level schema " recursively "
fn print_schema(schema: Schema, lookup: HashMap<String, SchemaUnion>) -> String {
    let mut out = StringWriter::new();
    let namespaces: Vec<String> = sorted_keys(&schema.ns);
    for ns in namespaces {
        if ns == "" { continue; }
        let namespace = schema.ns.get(&ns).unwrap();
        if let Some(comment) = Namespace::comment(&ns) {
            comment.split("\n").for_each(|x| {
                out.line(format!("/// {}", x));
            });
        }
        out.line(format!("pub mod {} {{", ns));
        out.inc_indent();
        out.line("use super::*;");
        for range_union in &namespace.unions {
            out.nl();
            print_range_union(&mut out, &lookup, range_union);
        }
        for class in &namespace.classes {
            out.nl();
            if class.is_enum() {
                print_enum(&mut out, &lookup, class);
            } else {
                print_struct(&mut out, &lookup, class);
            }
        }
        out.nl();
        out.line(format!("/// Holds the supporting builder structs for our {} types. Create a builder via `SomeType::builder()`.", ns));
        out.line("pub mod builders {");
        out.inc_indent();
        for class in &namespace.classes {
            if class.is_enum() { continue; }
            out.line(format!("pub use super::{}::{}Builder;", class.name.to_snake_case(), class.name.to_camel_case()));
        }
        out.dec_indent();
        out.line("}");
        out.dec_indent();
        out.line("}");
        out.nl();
    }
    out.to_string()
}
fn print_schema ( schema : Schema , lookup : HashMap < String , SchemaUnion > ) -> String { let mut out = StringWriter :: new ( ) ; let namespaces : Vec < String > = sorted_keys ( & schema . ns ) ; for ns in namespaces { if ns == " " { continue ; } let namespace = schema . ns . get ( & ns ) . unwrap ( ) ; if let Some ( comment ) = Namespace :: comment ( & ns ) { comment . split ( " \n " ) . for_each ( | x | { out . line ( format ! ( " " x ) ) ; } ) ; } out . line ( format ! ( " " ns ) ) ; out . inc_indent ( ) ; out . line ( " " ) ; for range_union in & namespace . unions { out . nl ( ) ; print_range_union ( & mut out , & lookup , range_union ) ; } for class in & namespace . classes { out . nl ( ) ; if class . is_enum ( ) { print_enum ( & mut out , & lookup , class ) ; } else { print_struct ( & mut out , & lookup , class ) ; } } out . nl ( ) ; out . line ( format ! ( " " ns ) ) ; out . line ( " " ) ; out . inc_indent ( ) ; for class in & namespace . classes { if class . is_enum ( ) { continue ; } out . line ( format ! ( " " class name to_snake_case ( ) class name to_camel_case ( ) ) ) ; } out . dec_indent ( ) ; out . line ( " " ) ; out . dec_indent ( ) ; out . line ( " " ) ; out . nl ( ) ; } out . to_string ( ) }
Prints our top-level schema "recursively" (ie, prints child nodes)
Prints our top - level schema " recursively " ( ie prints child nodes )
schema
Schema
lookup
HashMap<String, SchemaUnion>