Skip to content

Commit

Permalink
Add preamble containing a @generated stanza
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Mar 21, 2024
1 parent 7687870 commit 6384391
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions html5ever/src/tree_builder/generated.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// This code is @generated. See tests/codegen.rs for more information.

use super::*;
use crate::tendril::SliceExt;
use crate::tokenizer::states::{Plaintext, Rawtext, Rcdata, ScriptData};
Expand Down
4 changes: 3 additions & 1 deletion html5ever/tests/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn generated_code_is_fresh() {
.stack_size(stack_size * 1024 * 1024)
.spawn(move || {
let generated = expand(&input);
let formatted = reformat(&generated);
let formatted = reformat(&format!("{}{}", PREAMBLE, generated));
let current = fs::read_to_string(&output).unwrap_or_default();

if formatted == current {
Expand Down Expand Up @@ -76,6 +76,8 @@ fn reformat(code: &str) -> String {
String::from_utf8(output.stdout).unwrap()
}

const PREAMBLE: &str = "// This code is @generated. See tests/codegen.rs for more information.\n\n";

/*
Implements the `match_token!()` macro for use by the HTML tree builder
Expand Down

0 comments on commit 6384391

Please sign in to comment.