Skip to content

Conversation

@reivilibre
Copy link
Contributor

Gives template samples a stable identifier that we can use to track them across different sample render invocations.

Then allow saving rendered samples to a directory using the --out-dir flag.

Note: rendered pages contain unstable data like subresource integrity and asset hashes.
A future PR will add a feature to strip these out so the renders can be compared across different versions of MAS.


Commit-by-commit review.

@reivilibre reivilibre requested a review from sandhose October 24, 2025 16:17
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 24, 2025

Deploying matrix-authentication-service-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: f633e42
Status: ✅  Deploy successful!
Preview URL: https://04c5fe12.matrix-authentication-service-docs.pages.dev
Branch Preview URL: https://rei-templatecheck-todisk.matrix-authentication-service-docs.pages.dev

View logs

@reivilibre reivilibre marked this pull request as ready for review October 24, 2025 16:27
pub locale: Option<String>,

/// A stable identifier for the session that was used in this sample.
pub session_index: Option<usize>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

little bit confused on what a session is yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we call this "browser-session" as part of the rework below

}

#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct SampleIdentifier {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this feels like it could be a Vec<(Key, Value)> instead? (with Key probably being &'static str and Value being a String?)

and then the various stages push in that stack, e.g. at the end you get [("lang", "en"), ("user", "alice"), ("index", "1")], and when you reconstruct the file name you get lang:en-user:alice-index:1?

On why a Vec and not a btreemap: it allows duplicate key, and probably that the various levels of encapsulation will have some semantic meaning

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have changed to this approach. Example filename is pages_upstream_oauth2_suggest_link-index:0-browser-session:0-locale:fr.html. Are we happy with that?

Though I am not sure : is allowed on Windows, maybe it'd be better to find something else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might be right, = would also work I suppose

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let's go with this, just on the off chance it actually bites someone.

};

let locale_dir = if let Some(locale) = &sample_identifier.locale {
out_dir.join(locale)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not convinced that we should do one directory per locale

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it'd make it easier for a German deployment to only care about the German outputs, for example. Maybe there are better ways of doing that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels like the kind of post-processing a consumer could do themselves?

@reivilibre reivilibre requested a review from a team as a code owner October 29, 2025 17:20
@reivilibre reivilibre requested a review from sandhose October 29, 2025 17:20
@reivilibre reivilibre force-pushed the rei/templatecheck_todisk branch from 64997ef to 16ec04e Compare October 30, 2025 12:06
@reivilibre reivilibre enabled auto-merge October 30, 2025 13:57
@reivilibre reivilibre merged commit ab52f7e into main Oct 30, 2025
20 checks passed
@reivilibre reivilibre deleted the rei/templatecheck_todisk branch October 30, 2025 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants