Skip to content

Commit

Permalink
Add --custom-header-html to add some extra test on page (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
ezyang authored May 1, 2024
1 parent 9cfe1d0 commit 29c11dd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ pub struct Cli {
/// Don't open browser at the end
#[arg(long)]
no_browser: bool,
/// Some custom HTML to append to the top of report
#[arg(long)]
custom_header_html: String,
}

fn main() -> anyhow::Result<()> {
Expand All @@ -49,6 +52,7 @@ fn main() -> anyhow::Result<()> {
strict: cli.strict,
strict_compile_id: cli.strict_compile_id,
custom_parsers: Vec::new(),
custom_header_html: cli.custom_header_html,
};

let output = parse_path(&path, config)?;
Expand Down
13 changes: 13 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ pub struct ParseConfig {
pub strict: bool,
pub strict_compile_id: bool,
pub custom_parsers: Vec<Box<dyn crate::parsers::StructuredLogParser>>,
pub custom_header_html: String,
}

impl Default for ParseConfig {
fn default() -> Self {
Self {
strict: false,
strict_compile_id: false,
custom_parsers: Vec::default(),
custom_header_html: String::default(),
}
}
}

fn maybe_remove_suffix(frames: &mut Vec<FrameSummary>) {
Expand Down Expand Up @@ -323,6 +335,7 @@ pub fn parse_path(path: &PathBuf, config: ParseConfig) -> anyhow::Result<ParseOu
let index_context = IndexContext {
css: CSS,
javascript: JAVASCRIPT,
custom_header_html: config.custom_header_html,
directory: directory
.drain(..)
.map(|(x, y)| (x.map_or("(unknown)".to_string(), |e| e.to_string()), y))
Expand Down
1 change: 1 addition & 0 deletions src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub static TEMPLATE_INDEX: &str = r#"
</script>
<body>
<div>
{custom_header_html | format_unescaped}
<h2>Stack trie</h2>
<p>
The <strong>stack trie</strong> is a way of getting a quick orientation on where all the
Expand Down
1 change: 1 addition & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,5 @@ pub struct IndexContext {
pub unknown_stack_trie_html: String,
pub has_unknown_stack_trie: bool,
pub num_breaks: usize,
pub custom_header_html: String,
}

0 comments on commit 29c11dd

Please sign in to comment.