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