-
Notifications
You must be signed in to change notification settings - Fork 0
Flag stale narratives on model-set change; mark section pages as sections #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,6 +17,31 @@ | |||||||||||||||
|
|
||||||||||||||||
| _STYLE_RE = re.compile(r"<style>(.*?)</style>", re.S) | ||||||||||||||||
| _MAIN_RE = re.compile(r"<main[^>]*>(.*)</main>", re.S) | ||||||||||||||||
| _BODY_RE = re.compile(r"(<body[^>]*>)", re.I) | ||||||||||||||||
|
|
||||||||||||||||
| _SECTION_BANNER_MARK = "This is one section of a larger report" | ||||||||||||||||
| _SECTION_BANNER = ( | ||||||||||||||||
| "<div style=\"max-width:1040px;margin:12px auto;padding:10px 14px;border:1px solid #f0c36d;" | ||||||||||||||||
| "background:#fef7e6;border-radius:8px;font:14px/1.45 -apple-system,BlinkMacSystemFont,Segoe UI,sans-serif;" | ||||||||||||||||
| "color:#664d03\"><strong>" + _SECTION_BANNER_MARK + ".</strong> " | ||||||||||||||||
| "Open the <a href=\"{index_href}\">full report</a> for all sections, the table of contents, " | ||||||||||||||||
| "and the executive summary.</div>" | ||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
|
|
||||||||||||||||
| def mark_intermediate_page_html(html: str, index_href: str = "index.html") -> str: | ||||||||||||||||
| """Insert a 'this is a section' banner after ``<body>``. | ||||||||||||||||
|
|
||||||||||||||||
| Placed outside ``<main>`` so :func:`render_consolidated_report` (which lifts | ||||||||||||||||
| only the ``<main>`` body) never pulls it into the combined report. Idempotent. | ||||||||||||||||
| """ | ||||||||||||||||
| if _SECTION_BANNER_MARK in html: | ||||||||||||||||
| return html | ||||||||||||||||
| match = _BODY_RE.search(html) | ||||||||||||||||
| if not match: | ||||||||||||||||
| return html | ||||||||||||||||
| banner = _SECTION_BANNER.format(index_href=escape(index_href)) | ||||||||||||||||
| return html[: match.end()] + "\n" + banner + html[match.end() :] | ||||||||||||||||
|
|
||||||||||||||||
| _CONSOLIDATED_CSS = """ | ||||||||||||||||
|
Comment on lines
+44
to
46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||||||||||||
| .report-shell { max-width: 1180px; margin: 0 auto; padding: 0 16px 4rem; } | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both new tests call
build_executive_summarywith a hand-craftedgeneration={"stale": True, …}dict. They confirm the HTML banner appears when told to, but the code inbuild_report_bundlethat computes whether staleness should be set (comparingnarrative_model_labelsvs the current model set) has no direct test. If, for example, the key name mismatched —narrative_model_labelsvsmodel_labels— or theNone-guard accidentally fired on an empty list, the detection would silently skip marking and neither test would catch it.