coursemap/
lib.rs

1//! Course Map - A tool to visualize course dependencies from Quarto/Markdown documents
2//!
3//! This library provides functionality to parse Quarto/Markdown documents and generate
4//! visual dependency graphs showing the relationships between courses.
5//!
6//! # Examples
7//!
8//! ```rust,no_run
9//! use coursemap::{Config, App};
10//!
11//! // Load configuration
12//! let config = Config::load_default().unwrap();
13//!
14//! // Create app instance
15//! let app = App::new(config);
16//!
17//! // Generate course map
18//! app.run("./courses", "course_map.svg", "svg").unwrap();
19//! ```
20
21pub mod cli;
22pub mod config;
23pub mod graph;
24pub mod parser;
25pub mod renderer;
26
27pub use anyhow::{Error, Result};
28pub use config::Config;
29
30/// The main application structure
31pub struct App {
32    pub config: config::Config,
33}
34
35impl App {
36    /// Create a new App instance with the given configuration
37    pub fn new(config: config::Config) -> Self {
38        Self { config }
39    }
40
41    /// Run the course map generation process
42    pub fn run(&self, input_dir: &str, output_path: &str, format: &str) -> Result<()> {
43        // Parse all documents in the input directory
44        let documents = parser::parse_directory(input_dir, &self.config)?;
45
46        // Build the dependency graph
47        let graph = graph::build_graph(documents)?;
48
49        // Render the graph to the specified format
50        renderer::render_graph(&graph, output_path, format, &self.config)?;
51
52        Ok(())
53    }
54}