clean up
Some checks failed
CI / Check / Test (push) Successful in 3m6s
Architecture Docs / Generate diagrams (push) Has been cancelled

This commit is contained in:
2026-06-17 11:28:54 +02:00
parent 0e77ee623a
commit a7e466011b
35 changed files with 174 additions and 2131 deletions

View File

@@ -1,8 +1,7 @@
use std::path::PathBuf;
use archlens_domain::{
BoundaryRule, DomainError, NormalizedGraph, RenderedFile, RenderOutput,
check_boundary_rules,
BoundaryRule, DomainError, NormalizedGraph, RenderOutput, RenderedFile, check_boundary_rules,
ports::DiagramRenderer,
};
@@ -72,9 +71,7 @@ pub fn write_split(
output_dir: &Option<PathBuf>,
ext: &str,
) -> Result<(), DomainError> {
let dir = output_dir
.clone()
.unwrap_or_else(|| PathBuf::from("."));
let dir = output_dir.clone().unwrap_or_else(|| PathBuf::from("."));
let overview = renderer.render(graph.as_graph())?;
let overview_file = RenderedFile::new(
@@ -89,7 +86,11 @@ pub fn write_split(
let module_output = renderer.render_for_module(&subgraph, &module, &cross_deps)?;
let module_file = RenderedFile::new(
&format!("{}.{ext}", module.as_str().to_lowercase()),
module_output.files().first().map(|f| f.content()).unwrap_or(""),
module_output
.files()
.first()
.map(|f| f.content())
.unwrap_or(""),
)?;
write_file_to_dir(&dir, module_file)?;
}
@@ -99,10 +100,8 @@ pub fn write_split(
fn write_file_to_dir(dir: &PathBuf, file: RenderedFile) -> Result<(), DomainError> {
let path = dir.join(file.name());
std::fs::create_dir_all(dir)
.map_err(|e| DomainError::IoError(e.to_string()))?;
std::fs::write(&path, file.content())
.map_err(|e| DomainError::IoError(e.to_string()))?;
std::fs::create_dir_all(dir).map_err(|e| DomainError::IoError(e.to_string()))?;
std::fs::write(&path, file.content()).map_err(|e| DomainError::IoError(e.to_string()))?;
Ok(())
}
@@ -111,11 +110,9 @@ fn write_to_output(rendered: RenderOutput, output: &Option<PathBuf>) -> Result<(
match output {
Some(path) => {
if let Some(parent) = path.parent() {
std::fs::create_dir_all(parent)
.map_err(|e| DomainError::IoError(e.to_string()))?;
std::fs::create_dir_all(parent).map_err(|e| DomainError::IoError(e.to_string()))?;
}
std::fs::write(path, content)
.map_err(|e| DomainError::IoError(e.to_string()))
std::fs::write(path, content).map_err(|e| DomainError::IoError(e.to_string()))
}
None => {
print!("{content}");