pub use stoffellang::docs::{
code_spans, coverage, link_aliases, lint, module_name_from_path, AliasOf, Coverage, DocIndex,
DocItem, DocItemKind, DocWarning, DocWarningKind, FunctionSignature, ItemRef, ModuleDoc,
ParamDoc, ParamSignature, ParsedDoc, Section, WarningSeverity,
};
use crate::error::{format_compiler_errors, Error, Result};
pub fn extract_module(name: &str, path: &str, source: &str) -> Result<ModuleDoc> {
stoffellang::docs::extract_module(name, path, source)
.map_err(|errors| Error::Compilation(format_compiler_errors(&errors)))
}
pub fn extract_stdlib() -> Result<Vec<ModuleDoc>> {
stoffellang::docs::extract_stdlib()
.map_err(|errors| Error::Compilation(format_compiler_errors(&errors)))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn extraction_errors_become_compilation_errors() {
let error = extract_module("broken", "broken.stfl", "def main(:\n pass\n").unwrap_err();
assert!(matches!(error, Error::Compilation(message) if message.contains("broken.stfl")));
}
#[test]
fn stdlib_extracts_through_the_sdk() {
let modules = extract_stdlib().unwrap();
assert!(modules.iter().any(|module| module.name == "std.mpc"));
}
}