feat: add options for generated header and generation stats#19
feat: add options for generated header and generation stats#19Jamie-Fairweather wants to merge 2 commits intosheldonj:mainfrom
Conversation
- 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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds two boolean plugin options— Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/types.ts (1)
137-148: CentralizeincludeGenerationStatsin shared render options.
includeGenerationStatsis a toggleable rendering control but isn’t inRenderOptions, so its defaulting logic is currently split across code paths. Consider moving it intoRenderOptions+resolveRenderOptions()for consistency with the other render toggles.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."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, }; }🤖 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
⛔ Files ignored due to path filters (1)
test/generator/__snapshots__/snapshot.test.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (15)
README.mdsrc/extractors.tssrc/generator.tssrc/renderers/common.tssrc/renderers/enum-page.tssrc/renderers/index-page.tssrc/renderers/model-page.tssrc/renderers/procedure-page.tssrc/renderers/relationships-page.tssrc/renderers/type-page.tssrc/renderers/view-page.tssrc/types.tstest/generator/common.test.tstest/generator/index-page.test.tstest/generator/snapshot.test.ts
includeGeneratedHeaderandincludeGenerationStatsoptions in the plugin configuration.#18
Summary by CodeRabbit
New Features
Documentation
Tests