Skip to content

feat: schema generation#1178

Open
gennaroprota wants to merge 5 commits intocppalliance:developfrom
gennaroprota:feat/schema_generation
Open

feat: schema generation#1178
gennaroprota wants to merge 5 commits intocppalliance:developfrom
gennaroprota:feat/schema_generation

Conversation

@gennaroprota
Copy link
Copy Markdown
Collaborator

@gennaroprota gennaroprota commented Apr 16, 2026

This PR addes a --schemas[=<dir>] option that generates a mrdocs-dom-schema.json (Handlebars DOM) and mrdocs.rnc (XML output). Both schemas are generated from the reflection metadata. The old, hand-written, mrdocs.rnc is replaced entirely in CI.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 16, 2026

🚧 Danger.js checks for MrDocs are experimental; expect some rough edges while we tune the rules.

⚠️ Warnings

Warning

PR description looks empty. Please add a short rationale and testing notes.

✨ Highlights

  • 🧪 Existing golden tests changed (behavior likely shifted)

🧾 Changes by Scope

Scope Lines Δ% Lines Δ Lines + Lines - Files Δ Files + Files ~ Files ↔ Files -
🥇 Golden Tests 38% 1853 1672 181 169 - 169 - -
🛠️ Source 36% 1782 1626 156 19 3 16 - -
🏗️ Build 20% 964 11 953 2 - 1 - 1
🧪 Unit Tests 7% 326 326 - 1 1 - - -
🔧 Toolchain <1% 12 10 2 2 - 2 - -
🔧 Toolchain Tests <1% 2 1 1 1 - 1 - -
Total 100% 4939 3646 1293 194 4 189 - 1

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

🔝 Top Files

  • mrdocs.rnc (Build): 949 lines Δ (+0 / -949)
  • include/mrdocs/Schemas/RncSchemaWriter.hpp (Source): 837 lines Δ (+837 / -0)
  • include/mrdocs/Schemas/DomSchemaWriter.hpp (Source): 507 lines Δ (+507 / -0)

Generated by 🚫 dangerJS against b9fac7c

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

❌ Patch coverage is 96.77419% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.07%. Comparing base (0246935) to head (b9fac7c).

Files with missing lines Patch % Lines
src/lib/Gen/xml/XMLWriter.cpp 18.18% 9 Missing ⚠️
include/mrdocs/Schemas/DomSchemaWriter.hpp 98.84% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1178      +/-   ##
===========================================
+ Coverage    78.85%   79.07%   +0.21%     
===========================================
  Files          308      306       -2     
  Lines        32157    32460     +303     
  Branches      6456     6441      -15     
===========================================
+ Hits         25359    25667     +308     
- Misses        4436     4438       +2     
+ Partials      2362     2355       -7     
Flag Coverage Δ
bootstrap 81.90% <100.00%> (+<0.01%) ⬆️
cpp 78.78% <96.75%> (+0.23%) ⬆️

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 Apr 16, 2026

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

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

2026-04-17 16:39:06 UTC

@gennaroprota gennaroprota changed the title Feat/schema generation feat: schema generation Apr 17, 2026
@gennaroprota gennaroprota force-pushed the feat/schema_generation branch 5 times, most recently from 762bc4d to cdda298 Compare April 17, 2026 16:10
Add a --schemas[=<dir>] option that writes a JSON Schema file
(mrdocs-dom-schema.json) describing every object and field available to
Handlebars templates. The schema is derived from the same compile-time
reflection metadata used by MapReflectedType.hpp, so it stays in sync
with the code automatically.

The option requires no config file or source files — it writes the
schema and exits immediately.
OperatorKind was the only enum serialized as a raw integer. All other
enums serialize as human-readable strings. Change tag_invoke to use
getOperatorName, consistent with the rest.
--schemas now writes both mrdocs-dom-schema.json (Handlebars DOM) and
mrdocs.rnc (XML output). The XML schema mirrors XMLWriter.cpp's
serialization.
…ClassKind

Replace manual toString and tag_invoke overloads with
MRDOCS_DESCRIBE_ENUM for four enums whose kebab-case names match the
existing string representations.

The XML writer now emits these fields (e.g. <access>public</access>,
<constexpr>constexpr</constexpr>) where they were previously silently
skipped. None/none sentinel values are suppressed via a generic
has_none_enumerator check.

TypeKind stays manual because toKebabCase("LValueReference") produces
"l-value-reference", not the established "lvalue-reference".
… --schemas

This guarantees the RELAX NG schema stays in sync with the C++ type
definitions. Every CI run now validates all golden test XML files
against a schema derived from the same reflection metadata that produces
the XML.
@gennaroprota gennaroprota force-pushed the feat/schema_generation branch from cdda298 to b9fac7c Compare April 17, 2026 16:31
@alandefreitas
Copy link
Copy Markdown
Collaborator

Screenshot 2026-04-21 at 12 49 48 AM Screenshot 2026-04-21 at 12 49 41 AM

:)

@gennaroprota
Copy link
Copy Markdown
Collaborator Author

Path coverage is OK, isn't it? I added the PR description.

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