fix summaries
This commit is contained in:
parent
4b9a7acd20
commit
b07d70c769
@ -2,4 +2,6 @@
|
|||||||
|
|
||||||
# Action
|
# Action
|
||||||
|
|
||||||
|
An atomic human action assigned to an response stage.
|
||||||
|
|
||||||
{{ macros::summary_table(instances=instances) }}
|
{{ macros::summary_table(instances=instances) }}
|
||||||
|
@ -247,17 +247,18 @@ async fn render_indexes(
|
|||||||
summary: &[SummaryItem],
|
summary: &[SummaryItem],
|
||||||
) -> Result<(), MDBookEngineError> {
|
) -> Result<(), MDBookEngineError> {
|
||||||
let mut last_i = 0;
|
let mut last_i = 0;
|
||||||
let mut last_kind = None;
|
let mut last_item = if let Some(item) = summary.get(0) {
|
||||||
|
item
|
||||||
|
} else {
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
for (i, item) in summary.iter().enumerate() {
|
for (i, item) in summary.iter().enumerate() {
|
||||||
if Some(item.id.kind) != last_kind {
|
if item.id.kind != last_item.id.kind || i + 1 == summary.len() {
|
||||||
let (domain, model) = item.id.kind.parts();
|
let (domain, model) = last_item.id.kind.parts();
|
||||||
|
|
||||||
let domain_dir = src.join(domain);
|
let domain_dir = src.join(domain);
|
||||||
let model_dir = domain_dir.join(model);
|
let model_dir = domain_dir.join(model);
|
||||||
|
|
||||||
let mut context = Context::new();
|
|
||||||
context.insert("instances", &summary[last_i..i]);
|
|
||||||
|
|
||||||
if !domain_dir.is_dir() {
|
if !domain_dir.is_dir() {
|
||||||
fs::create_dir(&domain_dir).await?;
|
fs::create_dir(&domain_dir).await?;
|
||||||
}
|
}
|
||||||
@ -265,13 +266,16 @@ async fn render_indexes(
|
|||||||
fs::create_dir(&model_dir).await?;
|
fs::create_dir(&model_dir).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut context = Context::new();
|
||||||
|
context.insert("instances", &summary[last_i..i]);
|
||||||
|
|
||||||
let model_index = model_dir.with_extension("md");
|
let model_index = model_dir.with_extension("md");
|
||||||
let template_path = format!("{}/{}.tera", domain, model);
|
let template_path = format!("{}/{}.tera", domain, model);
|
||||||
let contents = templates.render(&template_path, &context)?;
|
let contents = templates.render(&template_path, &context)?;
|
||||||
fs::write(model_index, contents).await?;
|
fs::write(model_index, contents).await?;
|
||||||
|
|
||||||
last_i = i;
|
last_i = i;
|
||||||
last_kind = Some(item.id.kind);
|
last_item = item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user