1mod claims;
12pub mod layout;
13pub mod manifest;
14mod parse;
15pub mod report;
16mod schema;
17
18pub use layout::{LayoutOptions, LayoutResult, NodePosition, Point, Rect};
19pub use manifest::{
20 Binding, BindingRole, Claim, ClaimId, Link, LinkKind, Manifest, Node, NodeFields, NodeId,
21 NodeKind,
22};
23pub use report::{Diagnostic, ParseReport, Severity};
24
25#[cfg(feature = "native")]
26pub use parse::parse_dir;
27pub use parse::parse_sources;
28
29pub fn parse_and_layout(
34 tree_yaml: &str,
35 claims_md: Option<&str>,
36 opts: &LayoutOptions,
37) -> Result<(Manifest, ParseReport), ParseReport> {
38 let (mut manifest, report) = parse_sources(tree_yaml, claims_md)?;
39 let result = layout::layout(&manifest, opts);
40 for np in result.positions {
41 if let Some(node) = manifest.nodes.iter_mut().find(|n| n.id == np.id) {
42 node.pos = Some(np.pos);
43 }
44 }
45 manifest.bounds = Some(result.bounds);
46 Ok((manifest, report))
47}
48
49#[cfg(feature = "native")]
51pub fn parse_and_layout_dir(
52 dir: &std::path::Path,
53 opts: &LayoutOptions,
54) -> Result<(Manifest, ParseReport), ParseReport> {
55 let (mut manifest, report) = parse_dir(dir)?;
56 let result = layout::layout(&manifest, opts);
57 for np in result.positions {
58 if let Some(node) = manifest.nodes.iter_mut().find(|n| n.id == np.id) {
59 node.pos = Some(np.pos);
60 }
61 }
62 manifest.bounds = Some(result.bounds);
63 Ok((manifest, report))
64}
65
66pub fn version() -> &'static str {
68 env!("CARGO_PKG_VERSION")
69}
70
71#[cfg(test)]
72mod tests {
73 use super::*;
74
75 #[test]
76 fn version_is_reported() {
77 assert_eq!(version(), env!("CARGO_PKG_VERSION"));
78 }
79}