Skip to content

feat: add options for generated header and generation stats#19

Open
Jamie-Fairweather wants to merge 2 commits intosheldonj:mainfrom
Jamie-Fairweather:issue/18
Open

feat: add options for generated header and generation stats#19
Jamie-Fairweather wants to merge 2 commits intosheldonj:mainfrom
Jamie-Fairweather:issue/18

Conversation

@Jamie-Fairweather
Copy link
Copy Markdown

@Jamie-Fairweather Jamie-Fairweather commented Apr 11, 2026

  • Introduced includeGeneratedHeader and includeGenerationStats options in the plugin configuration.
  • Updated relevant rendering functions to conditionally include the generated header and generation stats based on the new options.
  • Enhanced documentation in README to reflect the new configuration options.
  • Added tests to verify the behavior of the new options.

#18

Summary by CodeRabbit

  • New Features

    • Two new config flags: includeGeneratedHeader (controls top-of-file banner) and includeGenerationStats (controls collapsible generation stats); both enabled by default.
  • Documentation

    • README updated with examples, descriptions, and defaults for the new options.
  • Tests

    • New tests verify the banner and stats can be disabled; snapshots now normalize generated timestamps for stability.

- Introduced `includeGeneratedHeader` and `includeGenerationStats` options in the plugin configuration.
- Updated relevant rendering functions to conditionally include the generated header and generation stats based on the new options.
- Enhanced documentation in README to reflect the new configuration options.
- Added tests to verify the behavior of the new options.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 50f3287b-7c13-4b90-899f-ee8044791d14

📥 Commits

Reviewing files that changed from the base of the PR and between 7b991bd and 24ba837.

📒 Files selected for processing (3)
  • src/renderers/index-page.ts
  • test/generator/common.test.ts
  • test/generator/snapshot.test.ts
✅ Files skipped from review due to trivial changes (1)
  • test/generator/common.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/generator/snapshot.test.ts

📝 Walkthrough

Walkthrough

Adds two boolean plugin options—includeGeneratedHeader and includeGenerationStats—that are parsed, added to types, threaded through render options, and used to conditionally include a top-of-file generated banner and an index-page "Generation Stats" section.

Changes

Cohort / File(s) Summary
Config & docs
README.md
Documented two new plugin documentation options and updated the example configuration to set both flags to true.
Types
src/types.ts
Added optional includeGeneratedHeader?: boolean and includeGenerationStats?: boolean to PluginOptions; added required includeGeneratedHeader: boolean to RelationshipsPageProps and RenderOptions.
Option parsing & propagation
src/generator.ts, src/extractors.ts
resolvePluginOptions and resolveRenderOptions now parse/return includeGeneratedHeader and includeGenerationStats, defaulting to true unless explicitly false.
Header generation utility
src/renderers/common.ts
generatedHeader signature now accepts an includeBanner boolean (default true) and returns an empty array when false.
Page renderers
src/renderers/...
src/renderers/enum-page.ts, src/renderers/model-page.ts, src/renderers/procedure-page.ts, src/renderers/relationships-page.ts, src/renderers/type-page.ts, src/renderers/view-page.ts
All renderHeader callers now pass the includeGeneratedHeader flag into generatedHeader, enabling conditional header inclusion.
Index page & stats
src/renderers/index-page.ts
Threaded includeGeneratedHeader and includeGenerationStats through IndexData; renderGenerationStats now accepts an includeStats boolean and returns [] when disabled or when required genCtx fields are missing.
Tests & snapshots
test/generator/common.test.ts, test/generator/index-page.test.ts, test/generator/snapshot.test.ts
Added tests asserting banner omission when includeGeneratedHeader: false and stats omission when includeGenerationStats: false; snapshot stabilizer now redacts · Generated: YYYY-MM-DD dates.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hop through code with gentle taps,
Flags for banners, stats in maps,
Hide or show with boolean flair,
Generated notes — appear or spare! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding two new plugin configuration options (includeGeneratedHeader and includeGenerationStats) for controlling generated documentation features.
Docstring Coverage ✅ Passed Docstring coverage is 93.33% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/types.ts (1)

137-148: Centralize includeGenerationStats in shared render options.

includeGenerationStats is a toggleable rendering control but isn’t in RenderOptions, so its defaulting logic is currently split across code paths. Consider moving it into RenderOptions + resolveRenderOptions() for consistency with the other render toggles.

Suggested refactor
// src/types.ts
 export type RenderOptions = {
   fieldOrder: 'alphabetical' | 'declaration';
   genCtx?: GenerationContext;
   includeGeneratedHeader: boolean;
+  includeGenerationStats: boolean;
   includeIndexes: boolean;
   includePolicies: boolean;
   includeRelationships: boolean;
   includeValidation: boolean;
   schemaDir?: string;
 };
// src/extractors.ts
 export function resolveRenderOptions(options: PluginOptions): RenderOptions {
   return {
     fieldOrder:
       options.fieldOrder === 'alphabetical' ? 'alphabetical' : 'declaration',
     includeGeneratedHeader: options.includeGeneratedHeader !== false,
+    includeGenerationStats: options.includeGenerationStats !== false,
     includeIndexes: options.includeIndexes !== false,
     includePolicies: options.includePolicies !== false,
     includeRelationships: options.includeRelationships !== false,
     includeValidation: options.includeValidation !== false,
   };
 }
Based on learnings: "When adding a new plugin option: (1) Add to `PluginOptions` in `src/types.ts`, (2) Parse in `resolvePluginOptions()` in `src/generator.ts`, (3) If controlling rendering, add to `RenderOptions` and `resolveRenderOptions()` in `src/extractors.ts`, (4) Update `README.md` configuration table, (5) Add tests."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/types.ts` around lines 137 - 148, Add the missing includeGenerationStats
flag to the shared RenderOptions type and centralize its defaulting in
resolveRenderOptions(); also add it to PluginOptions and parse it in
resolvePluginOptions() so plugin-level config flows into render options (remove
any ad-hoc defaults elsewhere), update the README configuration table entry for
includeGenerationStats, and add/adjust tests to cover the new option propagation
and default behavior. Ensure you modify the RenderOptions type, the
PluginOptions type, resolvePluginOptions(), and resolveRenderOptions() symbols
so includeGenerationStats is passed through and resolved consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/generator/common.test.ts`:
- Line 73: Reformat the failing matcher call in the test so it conforms to
Prettier rules: update the expect(readDoc(noBanner, 'index.md')).toMatch(/^#
Schema Documentation\n/u); expression in test/generator/common.test.ts (the
readDoc/noBanner test) to the project's standard formatting (for example put
.toMatch on its own indented line or run the project's formatter) and run pnpm
run lint to verify the prettier error is resolved.

In `@test/generator/snapshot.test.ts`:
- Around line 6-9: Prettier is complaining about the formatting of the
.replaceAll(...) call inside stabilize() in snapshot.test.ts; reformat the
.replaceAll invocation (the /(· Generated: )\d{4}-\d{2}-\d{2}/gu regex and the
'$1<REDACTED>' replacement) to comply with Prettier rules (e.g. adjust line
breaks/spacing so the regex and replacement are styled consistently or put them
on the same line per project Prettier settings), save, and run pnpm run lint to
verify the prettier/prettier error is resolved.

---

Nitpick comments:
In `@src/types.ts`:
- Around line 137-148: Add the missing includeGenerationStats flag to the shared
RenderOptions type and centralize its defaulting in resolveRenderOptions(); also
add it to PluginOptions and parse it in resolvePluginOptions() so plugin-level
config flows into render options (remove any ad-hoc defaults elsewhere), update
the README configuration table entry for includeGenerationStats, and add/adjust
tests to cover the new option propagation and default behavior. Ensure you
modify the RenderOptions type, the PluginOptions type, resolvePluginOptions(),
and resolveRenderOptions() symbols so includeGenerationStats is passed through
and resolved consistently.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 189fb9d9-617c-4159-8faf-2d842afbde6b

📥 Commits

Reviewing files that changed from the base of the PR and between 2044d82 and 7b991bd.

⛔ Files ignored due to path filters (1)
  • test/generator/__snapshots__/snapshot.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (15)
  • README.md
  • src/extractors.ts
  • src/generator.ts
  • src/renderers/common.ts
  • src/renderers/enum-page.ts
  • src/renderers/index-page.ts
  • src/renderers/model-page.ts
  • src/renderers/procedure-page.ts
  • src/renderers/relationships-page.ts
  • src/renderers/type-page.ts
  • src/renderers/view-page.ts
  • src/types.ts
  • test/generator/common.test.ts
  • test/generator/index-page.test.ts
  • test/generator/snapshot.test.ts

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.

1 participant