55 lines
1.2 KiB
Rust
55 lines
1.2 KiB
Rust
|
mod archive;
|
||
|
mod posts;
|
||
|
|
||
|
use compute_graph::{
|
||
|
builder::GraphBuilder,
|
||
|
rule::{Input, InputVisitable, Rule},
|
||
|
AsyncGraph,
|
||
|
};
|
||
|
|
||
|
pub async fn generate() -> anyhow::Result<()> {
|
||
|
std::fs::create_dir_all("out").expect("creating output dir");
|
||
|
|
||
|
// TODO: file watching
|
||
|
|
||
|
let mut graph = make_graph()?;
|
||
|
|
||
|
graph.evaluate_async().await;
|
||
|
|
||
|
println!("{}", graph.as_dot_string());
|
||
|
|
||
|
Ok(())
|
||
|
}
|
||
|
|
||
|
fn make_graph() -> anyhow::Result<AsyncGraph<GraphOutput>> {
|
||
|
let mut builder = GraphBuilder::<GraphOutput, _>::new_async();
|
||
|
|
||
|
let posts = posts::list_post_files()?;
|
||
|
let posts = posts
|
||
|
.into_iter()
|
||
|
.map(|path| builder.add_rule(posts::ParsePost(path)))
|
||
|
.collect::<Vec<_>>();
|
||
|
// let post_metadatas = posts
|
||
|
// .iter()
|
||
|
// .map(|post| builder.add_rule(posts::ExtractMetadata(post.clone())))
|
||
|
// .collect::<Vec<_>>();
|
||
|
|
||
|
let archive = archive::make_graph(&mut builder, &posts);
|
||
|
|
||
|
builder.set_output(Output { archive });
|
||
|
Ok(builder.build()?)
|
||
|
}
|
||
|
|
||
|
type GraphOutput = ();
|
||
|
|
||
|
#[derive(InputVisitable)]
|
||
|
struct Output {
|
||
|
archive: Input<()>,
|
||
|
}
|
||
|
impl Rule for Output {
|
||
|
type Output = GraphOutput;
|
||
|
fn evaluate(&mut self) -> Self::Output {
|
||
|
()
|
||
|
}
|
||
|
}
|