Function axon_parser::format[][src]

pub fn format(axon: &str, desired_width: usize) -> Result<String, Error>
Expand description

If the axon input represents a function or comp, parse it and return a String which contains formatted code.

The axon argument to this function should be a string containing the output of running <some code>.parseAst.toAxonCode in SkySpark.

Example

use axon_parser::format;

let desired_width = 80;
let axon = r###"{type:"func", params:[], body:{type:"block", exprs:[{type:"literal", val:"hello world"}]}}"###;
let formatted_code = format(axon, desired_width).unwrap();
let expected_code = "() => do\n    \"hello world\"\nend";
assert_eq!(formatted_code, expected_code);