Refactor AsciiDocExporter emitting using the MarkupExporter trait

This commit is contained in:
Philipp Paulweber authored and David Peter committed 2022-05-26 22:38:25 +02:00
1 parent 546f504067
commit 5e655032bc
2 files changed
+190 -219

No files matched your search

+28 -11
View File
@@ -15,24 +15,30 @@ pub trait MarkupExporter {
// prepare table header strings
let notation = format!("[{}]", unit.short_name());
// emit header
let mut table = self.table_row(&[
"Command",
&format!("Mean {}", notation),
&format!("Min {}", notation),
&format!("Max {}", notation),
"Relative",
]);
// emit horizontal line
table.push_str(&self.table_divider(&[
// prepare table cells alignment
let cells_alignment = [
Alignment::Left,
Alignment::Right,
Alignment::Right,
Alignment::Right,
Alignment::Right,
];
// emit table header format
let mut table = self.table_header(&cells_alignment);
// emit table header data
table.push_str(&self.table_row(&[
"Command",
&format!("Mean {}", notation),
&format!("Min {}", notation),
&format!("Max {}", notation),
"Relative",
]));
// emit horizontal line
table.push_str(&self.table_divider(&cells_alignment));
for entry in entries {
let measurement = &entry.result;
// prepare data row strings
@@ -64,6 +70,9 @@ pub trait MarkupExporter {
]))
}
// emit table footer format
table.push_str(&self.table_footer(&cells_alignment));
table
}
@@ -71,6 +80,14 @@ pub trait MarkupExporter {
fn table_divider(&self, cell_aligmnents: &[Alignment]) -> String;
fn table_header(&self, _cell_aligmnents: &[Alignment]) -> String {
"".to_string()
}
fn table_footer(&self, _cell_aligmnents: &[Alignment]) -> String {
"".to_string()
}
fn command(&self, size: &str) -> String;
}