Skip to content

Commit 8413e8a

Browse files
committed
Refactor summary generation to include both api and types
1 parent a4279af commit 8413e8a

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/generator.rs

+6-13
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ enum TemplateKind {
2020
#[default]
2121
ApiResource,
2222
OperationOptions,
23-
ApiSummary,
2423
Type,
25-
TypeSummary,
24+
Summary,
2625
}
2726

2827
pub(crate) fn generate(
@@ -46,12 +45,11 @@ pub(crate) fn generate(
4645
let tpl_kind = match tpl_base_name {
4746
"api_resource" => TemplateKind::ApiResource,
4847
"operation_options" => TemplateKind::OperationOptions,
49-
"api_summary" => TemplateKind::ApiSummary,
48+
"api_summary" | "component_type_summary" | "summary" => TemplateKind::Summary,
5049
"component_type" => TemplateKind::Type,
51-
"component_type_summary" => TemplateKind::TypeSummary,
5250
_ => bail!(
5351
"template file basename must be one of 'api_resource', 'api_summary', \
54-
'component_type', 'component_type_summary'",
52+
'component_type', 'component_type_summary', 'summary'",
5553
),
5654
};
5755

@@ -78,9 +76,8 @@ pub(crate) fn generate(
7876
match tpl_kind {
7977
TemplateKind::OperationOptions => generator.generate_api_resources_options(api)?,
8078
TemplateKind::ApiResource => generator.generate_api_resources(api)?,
81-
TemplateKind::ApiSummary => generator.generate_api_summary(api)?,
8279
TemplateKind::Type => generator.generate_types(types)?,
83-
TemplateKind::TypeSummary => generator.generate_type_summary(types)?,
80+
TemplateKind::Summary => generator.generate_summary(types, api)?,
8481
}
8582

8683
if !no_postprocess {
@@ -155,12 +152,8 @@ impl Generator<'_> {
155152
Ok(())
156153
}
157154

158-
fn generate_api_summary(&self, api: Api) -> anyhow::Result<()> {
159-
self.render_tpl(None, context! { api })
160-
}
161-
162-
fn generate_type_summary(&self, Types(types): Types) -> anyhow::Result<()> {
163-
self.render_tpl(None, context! { types })
155+
fn generate_summary(&self, Types(types): Types, api: Api) -> anyhow::Result<()> {
156+
self.render_tpl(None, context! { types, api })
164157
}
165158

166159
fn render_tpl(&self, output_name: Option<&str>, ctx: minijinja::Value) -> anyhow::Result<()> {

0 commit comments

Comments
 (0)