Skip to content

Read Jinja Template Comments in the Prose Gate - #4325

Merged
ptr727 merged 3 commits into
developfrom
burndown/prose-gate-jinja
Nov 20, 2026
Merged

ptr727 merged 3 commits into
developfrom
burndown/prose-gate-jinja

Conversation

@ptr727

@ptr727 ptr727 commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Summary

The prose gate read a Jinja template as plain text, so a {# ... #} comment never met the comment rules. A wrapped or over-long comment sentence in a template passed the commit hook and CI.

  • prose-gate.json declares a jinja language over every Jinja lexer Pygments has: django, and the HTML, XML, YAML, CSS, JavaScript, and SQL template lexers. Its comments are {# ... #} blocks, plus the HTML comments an HTML template holds and the # comments a YAML template holds. A CSS, JavaScript, or SQL template's own comments stay unread, as an embedded language's are in an HTML file.
  • Pygments already names a lexer for a template whose inner suffix it knows, such as .html.j2. A bare .j2, .jinja, or .jinja2 has none, so a new files.template map names django for it. lexer_name reads that map last, after Pygments and the shebang. So a .html.j2 keeps its HTML comments, and a run.sh.j2 opening on a bash shebang keeps its shell comments checked.
  • comment_lines picks a block comment by its closer as well as its opener. So a whitespace-control - on either end, as in {#- ... #}, stays out of the comment text. A block with no matching closer still falls back to its opener, as before.

Markup and expressions stay out of scope, as with every other lexer. A Salt .sls file, which Pygments reads as a YAML template, now has its # and {# ... #} comments checked too.

Tests

tests/test_prose_lint.py gains TestJinjaLanguage. It shows that two sentences on one comment line, a wrapped sentence, and a sentence over the word cap are each violations in a bare .j2 or .jinja2 file and in each kind of template Pygments names. It shows that markup and expressions holding the same text raise nothing. It also runs the gate's CLI on a staged template with --diff-commit, as the commit hook does, and against a base with --diff, as CI does. TestLexerDispatch covers the new mappings and the shebang outranking the template suffix. It also reads Pygments' own lexer list, so a Jinja lexer a later Pygments release adds fails until the data declares it. Each new case fails on the base branch's gate. A module-level run_gate helper replaces the in-process gate run TestDiffCommitChoosesTheBaseACommitAddsTo held inline.

Local review

A finding declined on evidence: Pygments splits a host comment around a {{ }} or {% %} tag inside it, such as # Set by {{ tool }}. Two. in a YAML template, so the text after the tag goes unread. That is a missed lint finding in a rare shape, neither silent-destructive nor something an outsider triggers, so it earns no fix under the hardening-effort rule. These files were read as plain text before this change, so nothing that was checked stops being checked.

Closes on promotion: #4307

🤖 Generated with Claude Code

ptr727 and others added 3 commits November 20, 2026 06:52
A `.j2`, `.jinja`, or `.jinja2` template now reads through a Jinja lexer, so its
`{# ... #}` comments meet the comment rules. Pygments names the lexer for a template
whose inner suffix it knows, and the data file names one for a bare template suffix.
A comment block is matched by its closer as well as its opener, so a whitespace-control
`-` stays out of the comment text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pygments names a Jinja lexer for a CSS, JavaScript, or SQL template too, so the
language declares each, and a test reads Pygments' own list. A shebang now outranks
the template suffix, so a script template keeps its shell comments checked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings November 20, 2026 15:12
@ptr727

ptr727 commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 359b33e185d616ece4ac02a16dd5de7584f1b1bf, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 0d399c3 and 359b33e.

Files selected for processing: 3

  • .github/actions/prose-gate/prose-gate.json
  • .github/actions/prose-gate/prose_lint.py
  • tests/test_prose_lint.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are identified in the Jinja template lexer dispatch, comment extraction, or CLI integration changes.

No open issues 🎉

What changed in this PR

This PR extends the prose gate to inspect comments in bare and suffix-qualified Jinja templates while preserving embedded-language boundaries.

Changes:

  • Add Jinja template suffix mappings and lexer dispatch support.
  • Handle Jinja block comments with whitespace-control markers.
  • Add lexer, comment extraction, and CLI integration tests.
File Description
tests/​test_prose_lint.py Adds Jinja behavior, lexer-dispatch, comment-extraction, and CLI integration coverage.
.github/​actions/​prose-gate/​prose-gate.json Defines Jinja template suffix mappings, lexer configurations, and comment syntaxes.
.github/​actions/​prose-gate/​prose_lint.py Dispatches template files to the appropriate lexer and matches Jinja block-comment closers.

Review effort: Lite

@codecov

codecov Bot commented Nov 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.25%. Comparing base (0d399c3) to head (359b33e).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4325   +/-   ##
========================================
  Coverage    79.25%   79.25%           
========================================
  Files           44       44           
  Lines        15887    15887           
========================================
  Hits         12592    12592           
  Misses        3295     3295           
Flag Coverage Δ
python-3.13 79.25% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727

ptr727 commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@ptr727

ptr727 commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

/review

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ptr727
ptr727 merged commit bb060eb into develop Nov 20, 2026
15 checks passed
@ptr727
ptr727 deleted the burndown/prose-gate-jinja branch November 20, 2026 15:29
ptr727 added a commit that referenced this pull request Nov 22, 2026
…udit, Co-Author (#4330)

## Summary

Promotes `develop` to `main`. It carries four changes:

- [#4325](#4325) reads
Jinja template comments in the prose gate.
- [#4323](#4323) names the
registration grace refusal and routes a missing shared hook to the
maintainer.
- [#4326](#4326) audits
that a merge-bot caller stub subscribes to `auto_merge_disabled`.
- [#4324](#4324) allows a
co-author line by default and never a session link.

Closes #4308
Closes #3869
Closes #1264
Closes #4307
Closes #4313

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* The installer now sets `attribution.sessionUrl` to `false` when the
setting is absent, while preserving existing host values. Reports
identify missing settings and note host-owned values.
* Prose checks now recognize Jinja templates and handle their comments
more accurately.
* Workflow specifications can require tokens across entire workflows,
with validation for the new requirement.

* **Documentation**
* Updated guidance clarifies hook reporting, check-registration timing,
and commit and pull request attribution rules.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

2 participants