Skip to content

feat: support addon-defined Handlebars generators#1197

Open
gennaroprota wants to merge 6 commits intocppalliance:developfrom
gennaroprota:feat/template_only_generators
Open

feat: support addon-defined Handlebars generators#1197
gennaroprota wants to merge 6 commits intocppalliance:developfrom
gennaroprota:feat/template_only_generators

Conversation

@gennaroprota
Copy link
Copy Markdown
Collaborator

@gennaroprota gennaroprota commented May 8, 2026

This adds support for Handlebars-based generators that don't involve any C++ code. <addon>/generator/<name>/ directories are picked up at config-resolve time and installed as additional generators; escape rules can be provided via <name>/mrdocs-generator.yml.

This is a prerequisite for letting users add a Handlebars-based
generator (e.g. a Markdown one) by dropping a template folder in an
addon, without writing C++.
This moves `id`, `fileExtension`, and `displayName` from per-subclass
virtual overrides to base-class members set through the constructor.

That's a prerequisite for letting users add a Handlebars-based generator
without writing C++.
The function was failing on `!file.good()` which includes the `eof()`
case, so an empty file caused a failure. Test for "fail() but not just
because we hit EOF", instead.
An <addon>/generator/<name>/ directory that ships at least one
*.<name>.hbs layout is now installed as an additional
`HandlebarsGenerator` at config-resolve time. An optional
mrdocs-generator.yml next to the layouts supplies escape rules.

This way, a generator can be added without writing any C++.
Generator lookup happened once at `TestRunner` construction. With
addon-defined Handlebars generators now possible, a generator
contributed via a test's `addons-supplemental` was unreachable from the
test binary: the lookup ran before that test's mrdocs.yml had been
loaded, so the generator wasn't yet registered.

The runner now defers the lookup. The built-in generators are not
affected.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

⚠️ Warnings

Warning

Add a brief note about how this change was tested (or why tests are not needed).

🧾 Changes by Scope

Scope Lines Δ% Lines Δ Lines + Lines - Files Δ Files + Files ~ Files ↔ Files -
🛠️ Source 61% 755 537 218 17 2 13 - 2
🧪 Unit Tests 35% 434 411 23 11 7 4 - -
🏗️ Build 3% 38 38 - 1 - 1 - -
📄 Docs 1% 10 3 7 1 - 1 - -
🧰 Tooling <1% 1 - 1 1 - 1 - -
Total 100% 1238 989 249 31 9 20 - 2

Legend: Files + (added), Files ~ (modified), Files ↔ (renamed), Files - (removed)

🔝 Top Files

  • src/test/lib/Gen/hbs/AddonGenerators.cpp (Unit Tests): 290 lines Δ (+290 / -0)
  • src/lib/Gen/hbs/AddonGenerators.cpp (Source): 222 lines Δ (+222 / -0)
  • src/lib/Gen/adoc/AdocEscape.cpp (Source): 100 lines Δ (+0 / -100)

Generated by 🚫 dangerJS against b08c8a0

@gennaroprota gennaroprota force-pushed the feat/template_only_generators branch from 97fc42c to 1d5651d Compare May 8, 2026 10:47
@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.12%. Comparing base (ec99c4a) to head (b08c8a0).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1197   +/-   ##
========================================
  Coverage    82.12%   82.12%           
========================================
  Files           33       33           
  Lines         3149     3149           
  Branches       734      734           
========================================
  Hits          2586     2586           
  Misses         387      387           
  Partials       176      176           
Flag Coverage Δ
bootstrap 82.12% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cppalliance-bot
Copy link
Copy Markdown

cppalliance-bot commented May 8, 2026

An automated preview of the documentation is available at https://1197.mrdocs.prtest2.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-05-08 14:43:52 UTC

This adds a fixture under test-files/template-only-generators/mock-md
that ships its own mock "Markdown-like" generator via an addon-local
`addons-supplemental`: a one-line layout that emits the symbol name,
plus a single escape rule mapping `_` to `\_`.
@gennaroprota gennaroprota force-pushed the feat/template_only_generators branch from 1d5651d to b08c8a0 Compare May 8, 2026 14:35
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