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